2 * Sysfs attributes of bridge ports
3 * Linux ethernet bridge
6 * Stephen Hemminger <shemminger@osdl.org>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
14 #include <linux/capability.h>
15 #include <linux/kernel.h>
16 #include <linux/netdevice.h>
17 #include <linux/etherdevice.h>
18 #include <linux/if_bridge.h>
19 #include <linux/rtnetlink.h>
20 #include <linux/spinlock.h>
21 #include <linux/times.h>
23 #include "br_private.h"
25 #define to_dev(obj) container_of(obj, struct device, kobj)
26 #define to_bridge(cd) ((struct net_bridge *)netdev_priv(to_net_dev(cd)))
29 * Common code for storing bridge parameters.
31 static ssize_t
store_bridge_parm(struct device
*d
,
32 const char *buf
, size_t len
,
33 int (*set
)(struct net_bridge
*, unsigned long))
35 struct net_bridge
*br
= to_bridge(d
);
40 if (!ns_capable(dev_net(br
->dev
)->user_ns
, CAP_NET_ADMIN
))
43 val
= simple_strtoul(buf
, &endp
, 0);
47 err
= (*set
)(br
, val
);
48 return err
? err
: len
;
52 static ssize_t
show_forward_delay(struct device
*d
,
53 struct device_attribute
*attr
, char *buf
)
55 struct net_bridge
*br
= to_bridge(d
);
56 return sprintf(buf
, "%lu\n", jiffies_to_clock_t(br
->forward_delay
));
59 static ssize_t
store_forward_delay(struct device
*d
,
60 struct device_attribute
*attr
,
61 const char *buf
, size_t len
)
63 return store_bridge_parm(d
, buf
, len
, br_set_forward_delay
);
65 static DEVICE_ATTR(forward_delay
, S_IRUGO
| S_IWUSR
,
66 show_forward_delay
, store_forward_delay
);
68 static ssize_t
show_hello_time(struct device
*d
, struct device_attribute
*attr
,
71 return sprintf(buf
, "%lu\n",
72 jiffies_to_clock_t(to_bridge(d
)->hello_time
));
75 static ssize_t
store_hello_time(struct device
*d
,
76 struct device_attribute
*attr
, const char *buf
,
79 return store_bridge_parm(d
, buf
, len
, br_set_hello_time
);
81 static DEVICE_ATTR(hello_time
, S_IRUGO
| S_IWUSR
, show_hello_time
,
84 static ssize_t
show_max_age(struct device
*d
, struct device_attribute
*attr
,
87 return sprintf(buf
, "%lu\n",
88 jiffies_to_clock_t(to_bridge(d
)->max_age
));
91 static ssize_t
store_max_age(struct device
*d
, struct device_attribute
*attr
,
92 const char *buf
, size_t len
)
94 return store_bridge_parm(d
, buf
, len
, br_set_max_age
);
96 static DEVICE_ATTR(max_age
, S_IRUGO
| S_IWUSR
, show_max_age
, store_max_age
);
98 static ssize_t
show_ageing_time(struct device
*d
,
99 struct device_attribute
*attr
, char *buf
)
101 struct net_bridge
*br
= to_bridge(d
);
102 return sprintf(buf
, "%lu\n", jiffies_to_clock_t(br
->ageing_time
));
105 static int set_ageing_time(struct net_bridge
*br
, unsigned long val
)
107 br
->ageing_time
= clock_t_to_jiffies(val
);
111 static ssize_t
store_ageing_time(struct device
*d
,
112 struct device_attribute
*attr
,
113 const char *buf
, size_t len
)
115 return store_bridge_parm(d
, buf
, len
, set_ageing_time
);
117 static DEVICE_ATTR(ageing_time
, S_IRUGO
| S_IWUSR
, show_ageing_time
,
120 static ssize_t
show_stp_state(struct device
*d
,
121 struct device_attribute
*attr
, char *buf
)
123 struct net_bridge
*br
= to_bridge(d
);
124 return sprintf(buf
, "%d\n", br
->stp_enabled
);
128 static ssize_t
store_stp_state(struct device
*d
,
129 struct device_attribute
*attr
, const char *buf
,
132 struct net_bridge
*br
= to_bridge(d
);
136 if (!ns_capable(dev_net(br
->dev
)->user_ns
, CAP_NET_ADMIN
))
139 val
= simple_strtoul(buf
, &endp
, 0);
144 return restart_syscall();
145 br_stp_set_enabled(br
, val
);
150 static DEVICE_ATTR(stp_state
, S_IRUGO
| S_IWUSR
, show_stp_state
,
153 static ssize_t
show_group_fwd_mask(struct device
*d
,
154 struct device_attribute
*attr
, char *buf
)
156 struct net_bridge
*br
= to_bridge(d
);
157 return sprintf(buf
, "%#x\n", br
->group_fwd_mask
);
161 static ssize_t
store_group_fwd_mask(struct device
*d
,
162 struct device_attribute
*attr
, const char *buf
,
165 struct net_bridge
*br
= to_bridge(d
);
169 if (!ns_capable(dev_net(br
->dev
)->user_ns
, CAP_NET_ADMIN
))
172 val
= simple_strtoul(buf
, &endp
, 0);
176 if (val
& BR_GROUPFWD_RESTRICTED
)
179 br
->group_fwd_mask
= val
;
183 static DEVICE_ATTR(group_fwd_mask
, S_IRUGO
| S_IWUSR
, show_group_fwd_mask
,
184 store_group_fwd_mask
);
186 static ssize_t
show_priority(struct device
*d
, struct device_attribute
*attr
,
189 struct net_bridge
*br
= to_bridge(d
);
190 return sprintf(buf
, "%d\n",
191 (br
->bridge_id
.prio
[0] << 8) | br
->bridge_id
.prio
[1]);
194 static int set_priority(struct net_bridge
*br
, unsigned long val
)
196 br_stp_set_bridge_priority(br
, (u16
) val
);
200 static ssize_t
store_priority(struct device
*d
, struct device_attribute
*attr
,
201 const char *buf
, size_t len
)
203 return store_bridge_parm(d
, buf
, len
, set_priority
);
205 static DEVICE_ATTR(priority
, S_IRUGO
| S_IWUSR
, show_priority
, store_priority
);
207 static ssize_t
show_root_id(struct device
*d
, struct device_attribute
*attr
,
210 return br_show_bridge_id(buf
, &to_bridge(d
)->designated_root
);
212 static DEVICE_ATTR(root_id
, S_IRUGO
, show_root_id
, NULL
);
214 static ssize_t
show_bridge_id(struct device
*d
, struct device_attribute
*attr
,
217 return br_show_bridge_id(buf
, &to_bridge(d
)->bridge_id
);
219 static DEVICE_ATTR(bridge_id
, S_IRUGO
, show_bridge_id
, NULL
);
221 static ssize_t
show_root_port(struct device
*d
, struct device_attribute
*attr
,
224 return sprintf(buf
, "%d\n", to_bridge(d
)->root_port
);
226 static DEVICE_ATTR(root_port
, S_IRUGO
, show_root_port
, NULL
);
228 static ssize_t
show_root_path_cost(struct device
*d
,
229 struct device_attribute
*attr
, char *buf
)
231 return sprintf(buf
, "%d\n", to_bridge(d
)->root_path_cost
);
233 static DEVICE_ATTR(root_path_cost
, S_IRUGO
, show_root_path_cost
, NULL
);
235 static ssize_t
show_topology_change(struct device
*d
,
236 struct device_attribute
*attr
, char *buf
)
238 return sprintf(buf
, "%d\n", to_bridge(d
)->topology_change
);
240 static DEVICE_ATTR(topology_change
, S_IRUGO
, show_topology_change
, NULL
);
242 static ssize_t
show_topology_change_detected(struct device
*d
,
243 struct device_attribute
*attr
,
246 struct net_bridge
*br
= to_bridge(d
);
247 return sprintf(buf
, "%d\n", br
->topology_change_detected
);
249 static DEVICE_ATTR(topology_change_detected
, S_IRUGO
,
250 show_topology_change_detected
, NULL
);
252 static ssize_t
show_hello_timer(struct device
*d
,
253 struct device_attribute
*attr
, char *buf
)
255 struct net_bridge
*br
= to_bridge(d
);
256 return sprintf(buf
, "%ld\n", br_timer_value(&br
->hello_timer
));
258 static DEVICE_ATTR(hello_timer
, S_IRUGO
, show_hello_timer
, NULL
);
260 static ssize_t
show_tcn_timer(struct device
*d
, struct device_attribute
*attr
,
263 struct net_bridge
*br
= to_bridge(d
);
264 return sprintf(buf
, "%ld\n", br_timer_value(&br
->tcn_timer
));
266 static DEVICE_ATTR(tcn_timer
, S_IRUGO
, show_tcn_timer
, NULL
);
268 static ssize_t
show_topology_change_timer(struct device
*d
,
269 struct device_attribute
*attr
,
272 struct net_bridge
*br
= to_bridge(d
);
273 return sprintf(buf
, "%ld\n", br_timer_value(&br
->topology_change_timer
));
275 static DEVICE_ATTR(topology_change_timer
, S_IRUGO
, show_topology_change_timer
,
278 static ssize_t
show_gc_timer(struct device
*d
, struct device_attribute
*attr
,
281 struct net_bridge
*br
= to_bridge(d
);
282 return sprintf(buf
, "%ld\n", br_timer_value(&br
->gc_timer
));
284 static DEVICE_ATTR(gc_timer
, S_IRUGO
, show_gc_timer
, NULL
);
286 static ssize_t
show_group_addr(struct device
*d
,
287 struct device_attribute
*attr
, char *buf
)
289 struct net_bridge
*br
= to_bridge(d
);
290 return sprintf(buf
, "%x:%x:%x:%x:%x:%x\n",
291 br
->group_addr
[0], br
->group_addr
[1],
292 br
->group_addr
[2], br
->group_addr
[3],
293 br
->group_addr
[4], br
->group_addr
[5]);
296 static ssize_t
store_group_addr(struct device
*d
,
297 struct device_attribute
*attr
,
298 const char *buf
, size_t len
)
300 struct net_bridge
*br
= to_bridge(d
);
304 if (!ns_capable(dev_net(br
->dev
)->user_ns
, CAP_NET_ADMIN
))
307 if (sscanf(buf
, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
308 &new_addr
[0], &new_addr
[1], &new_addr
[2],
309 &new_addr
[3], &new_addr
[4], &new_addr
[5]) != 6)
312 if (!is_link_local_ether_addr(new_addr
))
315 if (new_addr
[5] == 1 || /* 802.3x Pause address */
316 new_addr
[5] == 2 || /* 802.3ad Slow protocols */
317 new_addr
[5] == 3) /* 802.1X PAE address */
320 spin_lock_bh(&br
->lock
);
321 for (i
= 0; i
< 6; i
++)
322 br
->group_addr
[i
] = new_addr
[i
];
323 spin_unlock_bh(&br
->lock
);
327 static DEVICE_ATTR(group_addr
, S_IRUGO
| S_IWUSR
,
328 show_group_addr
, store_group_addr
);
330 static ssize_t
store_flush(struct device
*d
,
331 struct device_attribute
*attr
,
332 const char *buf
, size_t len
)
334 struct net_bridge
*br
= to_bridge(d
);
336 if (!ns_capable(dev_net(br
->dev
)->user_ns
, CAP_NET_ADMIN
))
342 static DEVICE_ATTR(flush
, S_IWUSR
, NULL
, store_flush
);
344 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
345 static ssize_t
show_multicast_router(struct device
*d
,
346 struct device_attribute
*attr
, char *buf
)
348 struct net_bridge
*br
= to_bridge(d
);
349 return sprintf(buf
, "%d\n", br
->multicast_router
);
352 static ssize_t
store_multicast_router(struct device
*d
,
353 struct device_attribute
*attr
,
354 const char *buf
, size_t len
)
356 return store_bridge_parm(d
, buf
, len
, br_multicast_set_router
);
358 static DEVICE_ATTR(multicast_router
, S_IRUGO
| S_IWUSR
, show_multicast_router
,
359 store_multicast_router
);
361 static ssize_t
show_multicast_snooping(struct device
*d
,
362 struct device_attribute
*attr
,
365 struct net_bridge
*br
= to_bridge(d
);
366 return sprintf(buf
, "%d\n", !br
->multicast_disabled
);
369 static ssize_t
store_multicast_snooping(struct device
*d
,
370 struct device_attribute
*attr
,
371 const char *buf
, size_t len
)
373 return store_bridge_parm(d
, buf
, len
, br_multicast_toggle
);
375 static DEVICE_ATTR(multicast_snooping
, S_IRUGO
| S_IWUSR
,
376 show_multicast_snooping
, store_multicast_snooping
);
378 static ssize_t
show_multicast_querier(struct device
*d
,
379 struct device_attribute
*attr
,
382 struct net_bridge
*br
= to_bridge(d
);
383 return sprintf(buf
, "%d\n", br
->multicast_querier
);
386 static ssize_t
store_multicast_querier(struct device
*d
,
387 struct device_attribute
*attr
,
388 const char *buf
, size_t len
)
390 return store_bridge_parm(d
, buf
, len
, br_multicast_set_querier
);
392 static DEVICE_ATTR(multicast_querier
, S_IRUGO
| S_IWUSR
,
393 show_multicast_querier
, store_multicast_querier
);
395 static ssize_t
show_hash_elasticity(struct device
*d
,
396 struct device_attribute
*attr
, char *buf
)
398 struct net_bridge
*br
= to_bridge(d
);
399 return sprintf(buf
, "%u\n", br
->hash_elasticity
);
402 static int set_elasticity(struct net_bridge
*br
, unsigned long val
)
404 br
->hash_elasticity
= val
;
408 static ssize_t
store_hash_elasticity(struct device
*d
,
409 struct device_attribute
*attr
,
410 const char *buf
, size_t len
)
412 return store_bridge_parm(d
, buf
, len
, set_elasticity
);
414 static DEVICE_ATTR(hash_elasticity
, S_IRUGO
| S_IWUSR
, show_hash_elasticity
,
415 store_hash_elasticity
);
417 static ssize_t
show_hash_max(struct device
*d
, struct device_attribute
*attr
,
420 struct net_bridge
*br
= to_bridge(d
);
421 return sprintf(buf
, "%u\n", br
->hash_max
);
424 static ssize_t
store_hash_max(struct device
*d
, struct device_attribute
*attr
,
425 const char *buf
, size_t len
)
427 return store_bridge_parm(d
, buf
, len
, br_multicast_set_hash_max
);
429 static DEVICE_ATTR(hash_max
, S_IRUGO
| S_IWUSR
, show_hash_max
,
432 static ssize_t
show_multicast_last_member_count(struct device
*d
,
433 struct device_attribute
*attr
,
436 struct net_bridge
*br
= to_bridge(d
);
437 return sprintf(buf
, "%u\n", br
->multicast_last_member_count
);
440 static int set_last_member_count(struct net_bridge
*br
, unsigned long val
)
442 br
->multicast_last_member_count
= val
;
446 static ssize_t
store_multicast_last_member_count(struct device
*d
,
447 struct device_attribute
*attr
,
448 const char *buf
, size_t len
)
450 return store_bridge_parm(d
, buf
, len
, set_last_member_count
);
452 static DEVICE_ATTR(multicast_last_member_count
, S_IRUGO
| S_IWUSR
,
453 show_multicast_last_member_count
,
454 store_multicast_last_member_count
);
456 static ssize_t
show_multicast_startup_query_count(
457 struct device
*d
, struct device_attribute
*attr
, char *buf
)
459 struct net_bridge
*br
= to_bridge(d
);
460 return sprintf(buf
, "%u\n", br
->multicast_startup_query_count
);
463 static int set_startup_query_count(struct net_bridge
*br
, unsigned long val
)
465 br
->multicast_startup_query_count
= val
;
469 static ssize_t
store_multicast_startup_query_count(
470 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
473 return store_bridge_parm(d
, buf
, len
, set_startup_query_count
);
475 static DEVICE_ATTR(multicast_startup_query_count
, S_IRUGO
| S_IWUSR
,
476 show_multicast_startup_query_count
,
477 store_multicast_startup_query_count
);
479 static ssize_t
show_multicast_last_member_interval(
480 struct device
*d
, struct device_attribute
*attr
, char *buf
)
482 struct net_bridge
*br
= to_bridge(d
);
483 return sprintf(buf
, "%lu\n",
484 jiffies_to_clock_t(br
->multicast_last_member_interval
));
487 static int set_last_member_interval(struct net_bridge
*br
, unsigned long val
)
489 br
->multicast_last_member_interval
= clock_t_to_jiffies(val
);
493 static ssize_t
store_multicast_last_member_interval(
494 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
497 return store_bridge_parm(d
, buf
, len
, set_last_member_interval
);
499 static DEVICE_ATTR(multicast_last_member_interval
, S_IRUGO
| S_IWUSR
,
500 show_multicast_last_member_interval
,
501 store_multicast_last_member_interval
);
503 static ssize_t
show_multicast_membership_interval(
504 struct device
*d
, struct device_attribute
*attr
, char *buf
)
506 struct net_bridge
*br
= to_bridge(d
);
507 return sprintf(buf
, "%lu\n",
508 jiffies_to_clock_t(br
->multicast_membership_interval
));
511 static int set_membership_interval(struct net_bridge
*br
, unsigned long val
)
513 br
->multicast_membership_interval
= clock_t_to_jiffies(val
);
517 static ssize_t
store_multicast_membership_interval(
518 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
521 return store_bridge_parm(d
, buf
, len
, set_membership_interval
);
523 static DEVICE_ATTR(multicast_membership_interval
, S_IRUGO
| S_IWUSR
,
524 show_multicast_membership_interval
,
525 store_multicast_membership_interval
);
527 static ssize_t
show_multicast_querier_interval(struct device
*d
,
528 struct device_attribute
*attr
,
531 struct net_bridge
*br
= to_bridge(d
);
532 return sprintf(buf
, "%lu\n",
533 jiffies_to_clock_t(br
->multicast_querier_interval
));
536 static int set_querier_interval(struct net_bridge
*br
, unsigned long val
)
538 br
->multicast_querier_interval
= clock_t_to_jiffies(val
);
542 static ssize_t
store_multicast_querier_interval(struct device
*d
,
543 struct device_attribute
*attr
,
544 const char *buf
, size_t len
)
546 return store_bridge_parm(d
, buf
, len
, set_querier_interval
);
548 static DEVICE_ATTR(multicast_querier_interval
, S_IRUGO
| S_IWUSR
,
549 show_multicast_querier_interval
,
550 store_multicast_querier_interval
);
552 static ssize_t
show_multicast_query_interval(struct device
*d
,
553 struct device_attribute
*attr
,
556 struct net_bridge
*br
= to_bridge(d
);
557 return sprintf(buf
, "%lu\n",
558 jiffies_to_clock_t(br
->multicast_query_interval
));
561 static int set_query_interval(struct net_bridge
*br
, unsigned long val
)
563 br
->multicast_query_interval
= clock_t_to_jiffies(val
);
567 static ssize_t
store_multicast_query_interval(struct device
*d
,
568 struct device_attribute
*attr
,
569 const char *buf
, size_t len
)
571 return store_bridge_parm(d
, buf
, len
, set_query_interval
);
573 static DEVICE_ATTR(multicast_query_interval
, S_IRUGO
| S_IWUSR
,
574 show_multicast_query_interval
,
575 store_multicast_query_interval
);
577 static ssize_t
show_multicast_query_response_interval(
578 struct device
*d
, struct device_attribute
*attr
, char *buf
)
580 struct net_bridge
*br
= to_bridge(d
);
583 jiffies_to_clock_t(br
->multicast_query_response_interval
));
586 static int set_query_response_interval(struct net_bridge
*br
, unsigned long val
)
588 br
->multicast_query_response_interval
= clock_t_to_jiffies(val
);
592 static ssize_t
store_multicast_query_response_interval(
593 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
596 return store_bridge_parm(d
, buf
, len
, set_query_response_interval
);
598 static DEVICE_ATTR(multicast_query_response_interval
, S_IRUGO
| S_IWUSR
,
599 show_multicast_query_response_interval
,
600 store_multicast_query_response_interval
);
602 static ssize_t
show_multicast_startup_query_interval(
603 struct device
*d
, struct device_attribute
*attr
, char *buf
)
605 struct net_bridge
*br
= to_bridge(d
);
608 jiffies_to_clock_t(br
->multicast_startup_query_interval
));
611 static int set_startup_query_interval(struct net_bridge
*br
, unsigned long val
)
613 br
->multicast_startup_query_interval
= clock_t_to_jiffies(val
);
617 static ssize_t
store_multicast_startup_query_interval(
618 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
621 return store_bridge_parm(d
, buf
, len
, set_startup_query_interval
);
623 static DEVICE_ATTR(multicast_startup_query_interval
, S_IRUGO
| S_IWUSR
,
624 show_multicast_startup_query_interval
,
625 store_multicast_startup_query_interval
);
627 #ifdef CONFIG_BRIDGE_NETFILTER
628 static ssize_t
show_nf_call_iptables(
629 struct device
*d
, struct device_attribute
*attr
, char *buf
)
631 struct net_bridge
*br
= to_bridge(d
);
632 return sprintf(buf
, "%u\n", br
->nf_call_iptables
);
635 static int set_nf_call_iptables(struct net_bridge
*br
, unsigned long val
)
637 br
->nf_call_iptables
= val
? true : false;
641 static ssize_t
store_nf_call_iptables(
642 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
645 return store_bridge_parm(d
, buf
, len
, set_nf_call_iptables
);
647 static DEVICE_ATTR(nf_call_iptables
, S_IRUGO
| S_IWUSR
,
648 show_nf_call_iptables
, store_nf_call_iptables
);
650 static ssize_t
show_nf_call_ip6tables(
651 struct device
*d
, struct device_attribute
*attr
, char *buf
)
653 struct net_bridge
*br
= to_bridge(d
);
654 return sprintf(buf
, "%u\n", br
->nf_call_ip6tables
);
657 static int set_nf_call_ip6tables(struct net_bridge
*br
, unsigned long val
)
659 br
->nf_call_ip6tables
= val
? true : false;
663 static ssize_t
store_nf_call_ip6tables(
664 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
667 return store_bridge_parm(d
, buf
, len
, set_nf_call_ip6tables
);
669 static DEVICE_ATTR(nf_call_ip6tables
, S_IRUGO
| S_IWUSR
,
670 show_nf_call_ip6tables
, store_nf_call_ip6tables
);
672 static ssize_t
show_nf_call_arptables(
673 struct device
*d
, struct device_attribute
*attr
, char *buf
)
675 struct net_bridge
*br
= to_bridge(d
);
676 return sprintf(buf
, "%u\n", br
->nf_call_arptables
);
679 static int set_nf_call_arptables(struct net_bridge
*br
, unsigned long val
)
681 br
->nf_call_arptables
= val
? true : false;
685 static ssize_t
store_nf_call_arptables(
686 struct device
*d
, struct device_attribute
*attr
, const char *buf
,
689 return store_bridge_parm(d
, buf
, len
, set_nf_call_arptables
);
691 static DEVICE_ATTR(nf_call_arptables
, S_IRUGO
| S_IWUSR
,
692 show_nf_call_arptables
, store_nf_call_arptables
);
695 static struct attribute
*bridge_attrs
[] = {
696 &dev_attr_forward_delay
.attr
,
697 &dev_attr_hello_time
.attr
,
698 &dev_attr_max_age
.attr
,
699 &dev_attr_ageing_time
.attr
,
700 &dev_attr_stp_state
.attr
,
701 &dev_attr_group_fwd_mask
.attr
,
702 &dev_attr_priority
.attr
,
703 &dev_attr_bridge_id
.attr
,
704 &dev_attr_root_id
.attr
,
705 &dev_attr_root_path_cost
.attr
,
706 &dev_attr_root_port
.attr
,
707 &dev_attr_topology_change
.attr
,
708 &dev_attr_topology_change_detected
.attr
,
709 &dev_attr_hello_timer
.attr
,
710 &dev_attr_tcn_timer
.attr
,
711 &dev_attr_topology_change_timer
.attr
,
712 &dev_attr_gc_timer
.attr
,
713 &dev_attr_group_addr
.attr
,
714 &dev_attr_flush
.attr
,
715 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
716 &dev_attr_multicast_router
.attr
,
717 &dev_attr_multicast_snooping
.attr
,
718 &dev_attr_multicast_querier
.attr
,
719 &dev_attr_hash_elasticity
.attr
,
720 &dev_attr_hash_max
.attr
,
721 &dev_attr_multicast_last_member_count
.attr
,
722 &dev_attr_multicast_startup_query_count
.attr
,
723 &dev_attr_multicast_last_member_interval
.attr
,
724 &dev_attr_multicast_membership_interval
.attr
,
725 &dev_attr_multicast_querier_interval
.attr
,
726 &dev_attr_multicast_query_interval
.attr
,
727 &dev_attr_multicast_query_response_interval
.attr
,
728 &dev_attr_multicast_startup_query_interval
.attr
,
730 #ifdef CONFIG_BRIDGE_NETFILTER
731 &dev_attr_nf_call_iptables
.attr
,
732 &dev_attr_nf_call_ip6tables
.attr
,
733 &dev_attr_nf_call_arptables
.attr
,
738 static struct attribute_group bridge_group
= {
739 .name
= SYSFS_BRIDGE_ATTR
,
740 .attrs
= bridge_attrs
,
744 * Export the forwarding information table as a binary file
745 * The records are struct __fdb_entry.
747 * Returns the number of bytes read.
749 static ssize_t
brforward_read(struct file
*filp
, struct kobject
*kobj
,
750 struct bin_attribute
*bin_attr
,
751 char *buf
, loff_t off
, size_t count
)
753 struct device
*dev
= to_dev(kobj
);
754 struct net_bridge
*br
= to_bridge(dev
);
757 /* must read whole records */
758 if (off
% sizeof(struct __fdb_entry
) != 0)
761 n
= br_fdb_fillbuf(br
, buf
,
762 count
/ sizeof(struct __fdb_entry
),
763 off
/ sizeof(struct __fdb_entry
));
766 n
*= sizeof(struct __fdb_entry
);
771 static struct bin_attribute bridge_forward
= {
772 .attr
= { .name
= SYSFS_BRIDGE_FDB
,
774 .read
= brforward_read
,
778 * Add entries in sysfs onto the existing network class device
780 * Adds a attribute group "bridge" containing tuning parameters.
781 * Binary attribute containing the forward table
782 * Sub directory to hold links to interfaces.
784 * Note: the ifobj exists only to be a subdirectory
785 * to hold links. The ifobj exists in same data structure
786 * as it's parent the bridge so reference counting works.
788 int br_sysfs_addbr(struct net_device
*dev
)
790 struct kobject
*brobj
= &dev
->dev
.kobj
;
791 struct net_bridge
*br
= netdev_priv(dev
);
794 err
= sysfs_create_group(brobj
, &bridge_group
);
796 pr_info("%s: can't create group %s/%s\n",
797 __func__
, dev
->name
, bridge_group
.name
);
801 err
= sysfs_create_bin_file(brobj
, &bridge_forward
);
803 pr_info("%s: can't create attribute file %s/%s\n",
804 __func__
, dev
->name
, bridge_forward
.attr
.name
);
808 br
->ifobj
= kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR
, brobj
);
810 pr_info("%s: can't add kobject (directory) %s/%s\n",
811 __func__
, dev
->name
, SYSFS_BRIDGE_PORT_SUBDIR
);
816 sysfs_remove_bin_file(&dev
->dev
.kobj
, &bridge_forward
);
818 sysfs_remove_group(&dev
->dev
.kobj
, &bridge_group
);
824 void br_sysfs_delbr(struct net_device
*dev
)
826 struct kobject
*kobj
= &dev
->dev
.kobj
;
827 struct net_bridge
*br
= netdev_priv(dev
);
829 kobject_put(br
->ifobj
);
830 sysfs_remove_bin_file(kobj
, &bridge_forward
);
831 sysfs_remove_group(kobj
, &bridge_group
);