14 #include <linux/capability.h>
15 #include <linux/kernel.h>
16 #include <linux/netdevice.h>
17 #include <linux/if_bridge.h>
18 #include <linux/rtnetlink.h>
24 #define to_dev(obj) container_of(obj, struct device, kobj)
25 #define to_bridge(cd) ((struct net_bridge *)netdev_priv(to_net_dev(cd)))
31 const char *
buf,
size_t len,
32 int (*
set)(
struct net_bridge *,
unsigned long))
46 err = (*set)(br,
val);
47 return err ? err : len;
60 const char *buf,
size_t len)
65 show_forward_delay, store_forward_delay);
91 const char *buf,
size_t len)
104 static int set_ageing_time(
struct net_bridge *br,
unsigned long val)
112 const char *buf,
size_t len)
114 return store_bridge_parm(d, buf, len, set_ageing_time);
143 return restart_syscall();
183 store_group_fwd_mask);
193 static int set_priority(
struct net_bridge *br,
unsigned long val)
200 const char *buf,
size_t len)
202 return store_bridge_parm(d, buf, len, set_priority);
241 static ssize_t show_topology_change_detected(
struct device *d,
249 show_topology_change_detected,
NULL);
289 return sprintf(buf,
"%x:%x:%x:%x:%x:%x\n",
297 const char *buf,
size_t len)
300 unsigned int new_addr[6];
306 if (
sscanf(buf,
"%x:%x:%x:%x:%x:%x",
307 &new_addr[0], &new_addr[1], &new_addr[2],
308 &new_addr[3], &new_addr[4], &new_addr[5]) != 6)
312 for (i = 0; i < 5; i++)
316 if (new_addr[5] & ~0xf)
319 if (new_addr[5] == 1 ||
324 spin_lock_bh(&br->
lock);
325 for (i = 0; i < 6; i++)
327 spin_unlock_bh(&br->
lock);
332 show_group_addr, store_group_addr);
336 const char *buf,
size_t len)
348 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
353 return sprintf(buf,
"%d\n", br->multicast_router);
358 const char *buf,
size_t len)
363 store_multicast_router);
370 return sprintf(buf,
"%d\n", !br->multicast_disabled);
375 const char *buf,
size_t len)
380 show_multicast_snooping, store_multicast_snooping);
387 return sprintf(buf,
"%d\n", br->multicast_querier);
392 const char *buf,
size_t len)
397 show_multicast_querier, store_multicast_querier);
403 return sprintf(buf,
"%u\n", br->hash_elasticity);
406 static int set_elasticity(
struct net_bridge *br,
unsigned long val)
408 br->hash_elasticity =
val;
414 const char *buf,
size_t len)
416 return store_bridge_parm(d, buf, len, set_elasticity);
419 store_hash_elasticity);
425 return sprintf(buf,
"%u\n", br->hash_max);
429 const char *buf,
size_t len)
436 static ssize_t show_multicast_last_member_count(
struct device *d,
441 return sprintf(buf,
"%u\n", br->multicast_last_member_count);
444 static int set_last_member_count(
struct net_bridge *br,
unsigned long val)
446 br->multicast_last_member_count =
val;
450 static ssize_t store_multicast_last_member_count(
struct device *d,
452 const char *buf,
size_t len)
454 return store_bridge_parm(d, buf, len, set_last_member_count);
457 show_multicast_last_member_count,
458 store_multicast_last_member_count);
460 static ssize_t show_multicast_startup_query_count(
464 return sprintf(buf,
"%u\n", br->multicast_startup_query_count);
467 static int set_startup_query_count(
struct net_bridge *br,
unsigned long val)
469 br->multicast_startup_query_count =
val;
473 static ssize_t store_multicast_startup_query_count(
477 return store_bridge_parm(d, buf, len, set_startup_query_count);
480 show_multicast_startup_query_count,
481 store_multicast_startup_query_count);
483 static ssize_t show_multicast_last_member_interval(
491 static int set_last_member_interval(
struct net_bridge *br,
unsigned long val)
497 static ssize_t store_multicast_last_member_interval(
501 return store_bridge_parm(d, buf, len, set_last_member_interval);
504 show_multicast_last_member_interval,
505 store_multicast_last_member_interval);
507 static ssize_t show_multicast_membership_interval(
515 static int set_membership_interval(
struct net_bridge *br,
unsigned long val)
521 static ssize_t store_multicast_membership_interval(
525 return store_bridge_parm(d, buf, len, set_membership_interval);
528 show_multicast_membership_interval,
529 store_multicast_membership_interval);
531 static ssize_t show_multicast_querier_interval(
struct device *d,
540 static int set_querier_interval(
struct net_bridge *br,
unsigned long val)
546 static ssize_t store_multicast_querier_interval(
struct device *d,
548 const char *buf,
size_t len)
550 return store_bridge_parm(d, buf, len, set_querier_interval);
553 show_multicast_querier_interval,
554 store_multicast_querier_interval);
556 static ssize_t show_multicast_query_interval(
struct device *d,
565 static int set_query_interval(
struct net_bridge *br,
unsigned long val)
571 static ssize_t store_multicast_query_interval(
struct device *d,
573 const char *buf,
size_t len)
575 return store_bridge_parm(d, buf, len, set_query_interval);
578 show_multicast_query_interval,
579 store_multicast_query_interval);
581 static ssize_t show_multicast_query_response_interval(
590 static int set_query_response_interval(
struct net_bridge *br,
unsigned long val)
596 static ssize_t store_multicast_query_response_interval(
600 return store_bridge_parm(d, buf, len, set_query_response_interval);
603 show_multicast_query_response_interval,
604 store_multicast_query_response_interval);
606 static ssize_t show_multicast_startup_query_interval(
615 static int set_startup_query_interval(
struct net_bridge *br,
unsigned long val)
621 static ssize_t store_multicast_startup_query_interval(
625 return store_bridge_parm(d, buf, len, set_startup_query_interval);
628 show_multicast_startup_query_interval,
629 store_multicast_startup_query_interval);
631 #ifdef CONFIG_BRIDGE_NETFILTER
632 static ssize_t show_nf_call_iptables(
636 return sprintf(buf,
"%u\n", br->nf_call_iptables);
639 static int set_nf_call_iptables(
struct net_bridge *br,
unsigned long val)
641 br->nf_call_iptables = val ?
true :
false;
645 static ssize_t store_nf_call_iptables(
649 return store_bridge_parm(d, buf, len, set_nf_call_iptables);
652 show_nf_call_iptables, store_nf_call_iptables);
654 static ssize_t show_nf_call_ip6tables(
658 return sprintf(buf,
"%u\n", br->nf_call_ip6tables);
661 static int set_nf_call_ip6tables(
struct net_bridge *br,
unsigned long val)
663 br->nf_call_ip6tables = val ?
true :
false;
667 static ssize_t store_nf_call_ip6tables(
671 return store_bridge_parm(d, buf, len, set_nf_call_ip6tables);
674 show_nf_call_ip6tables, store_nf_call_ip6tables);
676 static ssize_t show_nf_call_arptables(
680 return sprintf(buf,
"%u\n", br->nf_call_arptables);
683 static int set_nf_call_arptables(
struct net_bridge *br,
unsigned long val)
685 br->nf_call_arptables = val ?
true :
false;
689 static ssize_t store_nf_call_arptables(
693 return store_bridge_parm(d, buf, len, set_nf_call_arptables);
696 show_nf_call_arptables, store_nf_call_arptables);
699 static struct attribute *bridge_attrs[] = {
700 &dev_attr_forward_delay.attr,
701 &dev_attr_hello_time.attr,
702 &dev_attr_max_age.attr,
703 &dev_attr_ageing_time.attr,
704 &dev_attr_stp_state.attr,
705 &dev_attr_group_fwd_mask.attr,
706 &dev_attr_priority.attr,
707 &dev_attr_bridge_id.attr,
708 &dev_attr_root_id.attr,
709 &dev_attr_root_path_cost.attr,
710 &dev_attr_root_port.attr,
711 &dev_attr_topology_change.attr,
712 &dev_attr_topology_change_detected.attr,
713 &dev_attr_hello_timer.attr,
714 &dev_attr_tcn_timer.attr,
715 &dev_attr_topology_change_timer.attr,
716 &dev_attr_gc_timer.attr,
717 &dev_attr_group_addr.attr,
718 &dev_attr_flush.attr,
719 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
720 &dev_attr_multicast_router.attr,
721 &dev_attr_multicast_snooping.attr,
722 &dev_attr_multicast_querier.attr,
723 &dev_attr_hash_elasticity.attr,
724 &dev_attr_hash_max.attr,
725 &dev_attr_multicast_last_member_count.attr,
726 &dev_attr_multicast_startup_query_count.attr,
727 &dev_attr_multicast_last_member_interval.attr,
728 &dev_attr_multicast_membership_interval.attr,
729 &dev_attr_multicast_querier_interval.attr,
730 &dev_attr_multicast_query_interval.attr,
731 &dev_attr_multicast_query_response_interval.attr,
732 &dev_attr_multicast_startup_query_interval.attr,
734 #ifdef CONFIG_BRIDGE_NETFILTER
735 &dev_attr_nf_call_iptables.attr,
736 &dev_attr_nf_call_ip6tables.attr,
737 &dev_attr_nf_call_arptables.attr,
744 .attrs = bridge_attrs,
755 char *buf, loff_t off,
size_t count)
778 .read = brforward_read,
800 pr_info(
"%s: can't create group %s/%s\n",
801 __func__, dev->
name, bridge_group.
name);
807 pr_info(
"%s: can't create attribute file %s/%s\n",
808 __func__, dev->
name, bridge_forward.
attr.name);
814 pr_info(
"%s: can't add kobject (directory) %s/%s\n",