1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Linux ethernet bridge
6 * Lennert Buytenhek <buytenh@gnu.org>
12 #include <linux/netdevice.h>
13 #include <linux/if_bridge.h>
14 #include <linux/netpoll.h>
15 #include <linux/u64_stats_sync.h>
16 #include <net/route.h>
17 #include <net/ip6_fib.h>
18 #include <net/pkt_cls.h>
19 #include <linux/if_vlan.h>
20 #include <linux/rhashtable.h>
21 #include <linux/refcount.h>
23 #define BR_HASH_BITS 8
24 #define BR_HASH_SIZE (1 << BR_HASH_BITS)
26 #define BR_HOLD_TIME (1*HZ)
28 #define BR_PORT_BITS 10
29 #define BR_MAX_PORTS (1<<BR_PORT_BITS)
31 #define BR_MULTICAST_DEFAULT_HASH_MAX 4096
32 #define BR_MULTICAST_QUERY_INTVL_MIN msecs_to_jiffies(1000)
33 #define BR_MULTICAST_STARTUP_QUERY_INTVL_MIN BR_MULTICAST_QUERY_INTVL_MIN
35 #define BR_HWDOM_MAX BITS_PER_LONG
37 #define BR_VERSION "2.3"
39 /* Control of forwarding link local multicast */
40 #define BR_GROUPFWD_DEFAULT 0
41 /* Don't allow forwarding of control protocols like STP, MAC PAUSE and LACP */
43 BR_GROUPFWD_STP = BIT(0),
44 BR_GROUPFWD_MACPAUSE = BIT(1),
45 BR_GROUPFWD_LACP = BIT(2),
48 #define BR_GROUPFWD_RESTRICTED (BR_GROUPFWD_STP | BR_GROUPFWD_MACPAUSE | \
50 /* The Nearest Customer Bridge Group Address, 01-80-C2-00-00-[00,0B,0C,0D,0F] */
51 #define BR_GROUPFWD_8021AD 0xB801u
53 /* Path to usermode spanning tree program */
54 #define BR_STP_PROG "/sbin/bridge-stp"
56 #define BR_FDB_NOTIFY_SETTABLE_BITS (FDB_NOTIFY_BIT | FDB_NOTIFY_INACTIVE_BIT)
58 typedef struct bridge_id bridge_id;
59 typedef struct mac_addr mac_addr;
60 typedef __u16 port_id;
63 unsigned char prio[2];
64 unsigned char addr[ETH_ALEN];
68 unsigned char addr[ETH_ALEN];
71 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
73 struct bridge_mcast_own_query {
74 struct timer_list timer;
79 struct bridge_mcast_other_query {
80 struct timer_list timer;
81 struct timer_list delay_timer;
84 /* selected querier */
85 struct bridge_mcast_querier {
88 seqcount_spinlock_t seq;
91 /* IGMP/MLD statistics */
92 struct bridge_mcast_stats {
93 struct br_mcast_stats mstats;
94 struct u64_stats_sync syncp;
97 struct br_mdb_src_entry {
101 struct br_mdb_config {
102 struct net_bridge *br;
103 struct net_bridge_port *p;
104 struct br_mdb_entry *entry;
109 struct br_mdb_src_entry *src_entries;
115 /* net_bridge_mcast_port must be always defined due to forwarding stubs */
116 struct net_bridge_mcast_port {
117 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
118 struct net_bridge_port *port;
119 struct net_bridge_vlan *vlan;
121 struct bridge_mcast_own_query ip4_own_query;
122 struct timer_list ip4_mc_router_timer;
123 struct hlist_node ip4_rlist;
124 #if IS_ENABLED(CONFIG_IPV6)
125 struct bridge_mcast_own_query ip6_own_query;
126 struct timer_list ip6_mc_router_timer;
127 struct hlist_node ip6_rlist;
128 #endif /* IS_ENABLED(CONFIG_IPV6) */
129 unsigned char multicast_router;
132 #endif /* CONFIG_BRIDGE_IGMP_SNOOPING */
135 /* net_bridge_mcast must be always defined due to forwarding stubs */
136 struct net_bridge_mcast {
137 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
138 struct net_bridge *br;
139 struct net_bridge_vlan *vlan;
141 u32 multicast_last_member_count;
142 u32 multicast_startup_query_count;
144 u8 multicast_querier;
145 u8 multicast_igmp_version;
147 #if IS_ENABLED(CONFIG_IPV6)
148 u8 multicast_mld_version;
150 unsigned long multicast_last_member_interval;
151 unsigned long multicast_membership_interval;
152 unsigned long multicast_querier_interval;
153 unsigned long multicast_query_interval;
154 unsigned long multicast_query_response_interval;
155 unsigned long multicast_startup_query_interval;
156 struct hlist_head ip4_mc_router_list;
157 struct timer_list ip4_mc_router_timer;
158 struct bridge_mcast_other_query ip4_other_query;
159 struct bridge_mcast_own_query ip4_own_query;
160 struct bridge_mcast_querier ip4_querier;
161 #if IS_ENABLED(CONFIG_IPV6)
162 struct hlist_head ip6_mc_router_list;
163 struct timer_list ip6_mc_router_timer;
164 struct bridge_mcast_other_query ip6_other_query;
165 struct bridge_mcast_own_query ip6_own_query;
166 struct bridge_mcast_querier ip6_querier;
167 #endif /* IS_ENABLED(CONFIG_IPV6) */
168 #endif /* CONFIG_BRIDGE_IGMP_SNOOPING */
171 struct br_tunnel_info {
173 struct metadata_dst __rcu *tunnel_dst;
176 /* private vlan flags */
178 BR_VLFLAG_PER_PORT_STATS = BIT(0),
179 BR_VLFLAG_ADDED_BY_SWITCHDEV = BIT(1),
180 BR_VLFLAG_MCAST_ENABLED = BIT(2),
181 BR_VLFLAG_GLOBAL_MCAST_ENABLED = BIT(3),
182 BR_VLFLAG_NEIGH_SUPPRESS_ENABLED = BIT(4),
186 * struct net_bridge_vlan - per-vlan entry
188 * @vnode: rhashtable member
190 * @flags: bridge vlan flags
191 * @priv_flags: private (in-kernel) bridge vlan flags
192 * @state: STP state (e.g. blocking, learning, forwarding)
193 * @stats: per-cpu VLAN statistics
194 * @br: if MASTER flag set, this points to a bridge struct
195 * @port: if MASTER flag unset, this points to a port struct
196 * @refcnt: if MASTER flag set, this is bumped for each port referencing it
197 * @brvlan: if MASTER flag unset, this points to the global per-VLAN context
198 * for this VLAN entry
199 * @br_mcast_ctx: if MASTER flag set, this is the global vlan multicast context
200 * @port_mcast_ctx: if MASTER flag unset, this is the per-port/vlan multicast
202 * @msti: if MASTER flag set, this holds the VLANs MST instance
203 * @vlist: sorted list of VLAN entries
204 * @rcu: used for entry destruction
206 * This structure is shared between the global per-VLAN entries contained in
207 * the bridge rhashtable and the local per-port per-VLAN entries contained in
208 * the port's rhashtable. The union entries should be interpreted depending on
209 * the entry flags that are set.
211 struct net_bridge_vlan {
212 struct rhash_head vnode;
213 struct rhash_head tnode;
218 struct pcpu_sw_netstats __percpu *stats;
220 struct net_bridge *br;
221 struct net_bridge_port *port;
225 struct net_bridge_vlan *brvlan;
228 struct br_tunnel_info tinfo;
231 struct net_bridge_mcast br_mcast_ctx;
232 struct net_bridge_mcast_port port_mcast_ctx;
237 struct list_head vlist;
243 * struct net_bridge_vlan_group
245 * @vlan_hash: VLAN entry rhashtable
246 * @vlan_list: sorted VLAN entry list
247 * @num_vlans: number of total VLAN entries
248 * @pvid: PVID VLAN id
249 * @pvid_state: PVID's STP state (e.g. forwarding, learning, blocking)
251 * IMPORTANT: Be careful when checking if there're VLAN entries using list
252 * primitives because the bridge can have entries in its list which
253 * are just for global context but not for filtering, i.e. they have
254 * the master flag set but not the brentry flag. If you have to check
255 * if there're "real" entries in the bridge please test @num_vlans
257 struct net_bridge_vlan_group {
258 struct rhashtable vlan_hash;
259 struct rhashtable tunnel_hash;
260 struct list_head vlan_list;
266 /* bridge fdb flags */
271 BR_FDB_ADDED_BY_USER,
272 BR_FDB_ADDED_BY_EXT_LEARN,
275 BR_FDB_NOTIFY_INACTIVE,
279 struct net_bridge_fdb_key {
284 struct net_bridge_fdb_entry {
285 struct rhash_head rhnode;
286 struct net_bridge_port *dst;
288 struct net_bridge_fdb_key key;
289 struct hlist_node fdb_node;
292 /* write-heavy members should not affect lookups */
293 unsigned long updated ____cacheline_aligned_in_smp;
299 struct net_bridge_fdb_flush_desc {
301 unsigned long flags_mask;
306 #define MDB_PG_FLAGS_PERMANENT BIT(0)
307 #define MDB_PG_FLAGS_OFFLOAD BIT(1)
308 #define MDB_PG_FLAGS_FAST_LEAVE BIT(2)
309 #define MDB_PG_FLAGS_STAR_EXCL BIT(3)
310 #define MDB_PG_FLAGS_BLOCKED BIT(4)
312 #define PG_SRC_ENT_LIMIT 32
314 #define BR_SGRP_F_DELETE BIT(0)
315 #define BR_SGRP_F_SEND BIT(1)
316 #define BR_SGRP_F_INSTALLED BIT(2)
317 #define BR_SGRP_F_USER_ADDED BIT(3)
319 struct net_bridge_mcast_gc {
320 struct hlist_node gc_node;
321 void (*destroy)(struct net_bridge_mcast_gc *gc);
324 struct net_bridge_group_src {
325 struct hlist_node node;
328 struct net_bridge_port_group *pg;
330 u8 src_query_rexmit_cnt;
331 struct timer_list timer;
333 struct net_bridge *br;
334 struct net_bridge_mcast_gc mcast_gc;
338 struct net_bridge_port_group_sg_key {
339 struct net_bridge_port *port;
343 struct net_bridge_port_group {
344 struct net_bridge_port_group __rcu *next;
345 struct net_bridge_port_group_sg_key key;
346 unsigned char eth_addr[ETH_ALEN] __aligned(2);
348 unsigned char filter_mode;
349 unsigned char grp_query_rexmit_cnt;
350 unsigned char rt_protocol;
352 struct hlist_head src_list;
353 unsigned int src_ents;
354 struct timer_list timer;
355 struct timer_list rexmit_timer;
356 struct hlist_node mglist;
357 struct rb_root eht_set_tree;
358 struct rb_root eht_host_tree;
360 struct rhash_head rhnode;
361 struct net_bridge_mcast_gc mcast_gc;
365 struct net_bridge_mdb_entry {
366 struct rhash_head rhnode;
367 struct net_bridge *br;
368 struct net_bridge_port_group __rcu *ports;
372 struct timer_list timer;
373 struct hlist_node mdb_node;
375 struct net_bridge_mcast_gc mcast_gc;
379 struct net_bridge_port {
380 struct net_bridge *br;
381 struct net_device *dev;
382 netdevice_tracker dev_tracker;
383 struct list_head list;
386 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
387 struct net_bridge_vlan_group __rcu *vlgrp;
389 struct net_bridge_port __rcu *backup_port;
396 unsigned char topology_change_ack;
397 unsigned char config_pending;
399 port_id designated_port;
400 bridge_id designated_root;
401 bridge_id designated_bridge;
404 unsigned long designated_age;
406 struct timer_list forward_delay_timer;
407 struct timer_list hold_timer;
408 struct timer_list message_age_timer;
412 struct net_bridge_mcast_port multicast_ctx;
414 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
415 struct bridge_mcast_stats __percpu *mcast_stats;
417 u32 multicast_eht_hosts_limit;
418 u32 multicast_eht_hosts_cnt;
419 struct hlist_head mglist;
423 char sysfs_name[IFNAMSIZ];
426 #ifdef CONFIG_NET_POLL_CONTROLLER
429 #ifdef CONFIG_NET_SWITCHDEV
430 /* Identifier used to group ports that share the same switchdev
435 struct netdev_phys_item_id ppid;
438 u16 backup_redirected_cnt;
440 struct bridge_stp_xstats stp_xstats;
443 #define kobj_to_brport(obj) container_of(obj, struct net_bridge_port, kobj)
445 #define br_auto_port(p) ((p)->flags & BR_AUTO_MASK)
446 #define br_promisc_port(p) ((p)->flags & BR_PROMISC)
448 static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev)
450 return rcu_dereference(dev->rx_handler_data);
453 static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)
455 return netif_is_bridge_port(dev) ?
456 rtnl_dereference(dev->rx_handler_data) : NULL;
459 static inline struct net_bridge_port *br_port_get_rtnl_rcu(const struct net_device *dev)
461 return netif_is_bridge_port(dev) ?
462 rcu_dereference_rtnl(dev->rx_handler_data) : NULL;
465 enum net_bridge_opts {
467 BROPT_VLAN_STATS_ENABLED,
468 BROPT_NF_CALL_IPTABLES,
469 BROPT_NF_CALL_IP6TABLES,
470 BROPT_NF_CALL_ARPTABLES,
471 BROPT_GROUP_ADDR_SET,
472 BROPT_MULTICAST_ENABLED,
473 BROPT_MULTICAST_QUERY_USE_IFADDR,
474 BROPT_MULTICAST_STATS_ENABLED,
476 BROPT_NEIGH_SUPPRESS_ENABLED,
477 BROPT_MTU_SET_BY_USER,
478 BROPT_VLAN_STATS_PER_PORT,
480 BROPT_VLAN_BRIDGE_BINDING,
481 BROPT_MCAST_VLAN_SNOOPING_ENABLED,
487 spinlock_t hash_lock;
488 struct hlist_head frame_type_list;
489 struct net_device *dev;
490 unsigned long options;
491 /* These fields are accessed on each packet */
492 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
495 struct net_bridge_vlan_group __rcu *vlgrp;
498 struct rhashtable fdb_hash_tbl;
499 struct list_head port_list;
500 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
502 struct rtable fake_rtable;
503 struct rt6_info fake_rt6_info;
507 u16 group_fwd_mask_required;
510 bridge_id designated_root;
512 unsigned char topology_change;
513 unsigned char topology_change_detected;
515 unsigned long max_age;
516 unsigned long hello_time;
517 unsigned long forward_delay;
518 unsigned long ageing_time;
519 unsigned long bridge_max_age;
520 unsigned long bridge_hello_time;
521 unsigned long bridge_forward_delay;
522 unsigned long bridge_ageing_time;
525 u8 group_addr[ETH_ALEN];
528 BR_NO_STP, /* no spanning tree */
529 BR_KERNEL_STP, /* old STP in kernel */
530 BR_USER_STP, /* new RSTP in userspace */
533 struct net_bridge_mcast multicast_ctx;
535 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
536 struct bridge_mcast_stats __percpu *mcast_stats;
540 spinlock_t multicast_lock;
542 struct rhashtable mdb_hash_tbl;
543 struct rhashtable sg_port_tbl;
545 struct hlist_head mcast_gc_list;
546 struct hlist_head mdb_list;
548 struct work_struct mcast_gc_work;
551 struct timer_list hello_timer;
552 struct timer_list tcn_timer;
553 struct timer_list topology_change_timer;
554 struct delayed_work gc_work;
555 struct kobject *ifobj;
558 #ifdef CONFIG_NET_SWITCHDEV
559 /* Counter used to make sure that hardware domains get unique
560 * identifiers in case a bridge spans multiple switchdev instances.
563 /* Bit mask of hardware domain numbers in use */
564 unsigned long busy_hwdoms;
566 struct hlist_head fdb_list;
568 #if IS_ENABLED(CONFIG_BRIDGE_MRP)
569 struct hlist_head mrp_list;
571 #if IS_ENABLED(CONFIG_BRIDGE_CFM)
572 struct hlist_head mep_list;
576 struct br_input_skb_cb {
577 struct net_device *brdev;
580 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
584 u8 proxyarp_replied:1;
585 u8 src_port_isolated:1;
586 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
589 #ifdef CONFIG_NETFILTER_FAMILY_BRIDGE
590 u8 br_netfilter_broute:1;
593 #ifdef CONFIG_NET_SWITCHDEV
594 /* Set if TX data plane offloading is used towards at least one
598 /* The switchdev hardware domain from which this packet was received.
599 * If skb->offload_fwd_mark was set, then this packet was already
600 * forwarded by hardware to the other ports in the source hardware
601 * domain, otherwise it wasn't.
604 /* Bit mask of hardware domains towards this packet has already been
605 * transmitted using the TX data plane offload.
607 unsigned long fwd_hwdoms;
613 #define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb)
615 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
616 # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (BR_INPUT_SKB_CB(__skb)->mrouters_only)
618 # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (0)
621 #define br_printk(level, br, format, args...) \
622 printk(level "%s: " format, (br)->dev->name, ##args)
624 #define br_err(__br, format, args...) \
625 br_printk(KERN_ERR, __br, format, ##args)
626 #define br_warn(__br, format, args...) \
627 br_printk(KERN_WARNING, __br, format, ##args)
628 #define br_notice(__br, format, args...) \
629 br_printk(KERN_NOTICE, __br, format, ##args)
630 #define br_info(__br, format, args...) \
631 br_printk(KERN_INFO, __br, format, ##args)
633 #define br_debug(br, format, args...) \
634 pr_debug("%s: " format, (br)->dev->name, ##args)
636 /* called under bridge lock */
637 static inline int br_is_root_bridge(const struct net_bridge *br)
639 return !memcmp(&br->bridge_id, &br->designated_root, 8);
642 /* check if a VLAN entry is global */
643 static inline bool br_vlan_is_master(const struct net_bridge_vlan *v)
645 return v->flags & BRIDGE_VLAN_INFO_MASTER;
648 /* check if a VLAN entry is used by the bridge */
649 static inline bool br_vlan_is_brentry(const struct net_bridge_vlan *v)
651 return v->flags & BRIDGE_VLAN_INFO_BRENTRY;
654 /* check if we should use the vlan entry, returns false if it's only context */
655 static inline bool br_vlan_should_use(const struct net_bridge_vlan *v)
657 if (br_vlan_is_master(v)) {
658 if (br_vlan_is_brentry(v))
667 static inline bool nbp_state_should_learn(const struct net_bridge_port *p)
669 return p->state == BR_STATE_LEARNING || p->state == BR_STATE_FORWARDING;
672 static inline bool br_vlan_valid_id(u16 vid, struct netlink_ext_ack *extack)
674 bool ret = vid > 0 && vid < VLAN_VID_MASK;
677 NL_SET_ERR_MSG_MOD(extack, "Vlan id is invalid");
682 static inline bool br_vlan_valid_range(const struct bridge_vlan_info *cur,
683 const struct bridge_vlan_info *last,
684 struct netlink_ext_ack *extack)
686 /* pvid flag is not allowed in ranges */
687 if (cur->flags & BRIDGE_VLAN_INFO_PVID) {
688 NL_SET_ERR_MSG_MOD(extack, "Pvid isn't allowed in a range");
692 /* when cur is the range end, check if:
693 * - it has range start flag
694 * - range ids are invalid (end is equal to or before start)
697 if (cur->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) {
698 NL_SET_ERR_MSG_MOD(extack, "Found a new vlan range start while processing one");
700 } else if (!(cur->flags & BRIDGE_VLAN_INFO_RANGE_END)) {
701 NL_SET_ERR_MSG_MOD(extack, "Vlan range end flag is missing");
703 } else if (cur->vid <= last->vid) {
704 NL_SET_ERR_MSG_MOD(extack, "End vlan id is less than or equal to start vlan id");
709 /* check for required range flags */
710 if (!(cur->flags & (BRIDGE_VLAN_INFO_RANGE_BEGIN |
711 BRIDGE_VLAN_INFO_RANGE_END))) {
712 NL_SET_ERR_MSG_MOD(extack, "Both vlan range flags are missing");
719 static inline u8 br_vlan_multicast_router(const struct net_bridge_vlan *v)
721 u8 mcast_router = MDB_RTR_TYPE_DISABLED;
723 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
724 if (!br_vlan_is_master(v))
725 mcast_router = v->port_mcast_ctx.multicast_router;
727 mcast_router = v->br_mcast_ctx.multicast_router;
733 static inline int br_afspec_cmd_to_rtm(int cmd)
745 static inline int br_opt_get(const struct net_bridge *br,
746 enum net_bridge_opts opt)
748 return test_bit(opt, &br->options);
751 int br_boolopt_toggle(struct net_bridge *br, enum br_boolopt_id opt, bool on,
752 struct netlink_ext_ack *extack);
753 int br_boolopt_get(const struct net_bridge *br, enum br_boolopt_id opt);
754 int br_boolopt_multi_toggle(struct net_bridge *br,
755 struct br_boolopt_multi *bm,
756 struct netlink_ext_ack *extack);
757 void br_boolopt_multi_get(const struct net_bridge *br,
758 struct br_boolopt_multi *bm);
759 void br_opt_toggle(struct net_bridge *br, enum net_bridge_opts opt, bool on);
761 #if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
762 static inline void br_tc_skb_miss_set(struct sk_buff *skb, bool miss)
764 struct tc_skb_ext *ext;
766 if (!tc_skb_ext_tc_enabled())
769 ext = skb_ext_find(skb, TC_SKB_EXT);
776 ext = tc_skb_ext_alloc(skb);
782 static inline void br_tc_skb_miss_set(struct sk_buff *skb, bool miss)
788 void br_dev_setup(struct net_device *dev);
789 void br_dev_delete(struct net_device *dev, struct list_head *list);
790 netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev);
791 #ifdef CONFIG_NET_POLL_CONTROLLER
792 static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
795 netpoll_send_skb(p->np, skb);
798 int br_netpoll_enable(struct net_bridge_port *p);
799 void br_netpoll_disable(struct net_bridge_port *p);
801 static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
806 static inline int br_netpoll_enable(struct net_bridge_port *p)
811 static inline void br_netpoll_disable(struct net_bridge_port *p)
817 #define FDB_FLUSH_IGNORED_NDM_FLAGS (NTF_MASTER | NTF_SELF)
818 #define FDB_FLUSH_ALLOWED_NDM_STATES (NUD_PERMANENT | NUD_NOARP)
819 #define FDB_FLUSH_ALLOWED_NDM_FLAGS (NTF_USE | NTF_EXT_LEARNED | \
820 NTF_STICKY | NTF_OFFLOADED)
822 int br_fdb_init(void);
823 void br_fdb_fini(void);
824 int br_fdb_hash_init(struct net_bridge *br);
825 void br_fdb_hash_fini(struct net_bridge *br);
826 void br_fdb_flush(struct net_bridge *br,
827 const struct net_bridge_fdb_flush_desc *desc);
828 void br_fdb_find_delete_local(struct net_bridge *br,
829 const struct net_bridge_port *p,
830 const unsigned char *addr, u16 vid);
831 void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr);
832 void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);
833 void br_fdb_cleanup(struct work_struct *work);
834 void br_fdb_delete_by_port(struct net_bridge *br,
835 const struct net_bridge_port *p, u16 vid, int do_all);
836 struct net_bridge_fdb_entry *br_fdb_find_rcu(struct net_bridge *br,
837 const unsigned char *addr,
839 int br_fdb_test_addr(struct net_device *dev, unsigned char *addr);
840 int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count,
842 int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,
843 const unsigned char *addr, u16 vid);
844 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
845 const unsigned char *addr, u16 vid, unsigned long flags);
847 int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
848 struct net_device *dev, const unsigned char *addr, u16 vid,
849 struct netlink_ext_ack *extack);
850 int br_fdb_delete_bulk(struct ndmsg *ndm, struct nlattr *tb[],
851 struct net_device *dev, u16 vid,
852 struct netlink_ext_ack *extack);
853 int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev,
854 const unsigned char *addr, u16 vid, u16 nlh_flags,
855 struct netlink_ext_ack *extack);
856 int br_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
857 struct net_device *dev, struct net_device *fdev, int *idx);
858 int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[], struct net_device *dev,
859 const unsigned char *addr, u16 vid, u32 portid, u32 seq,
860 struct netlink_ext_ack *extack);
861 int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p);
862 void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p);
863 int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
864 const unsigned char *addr, u16 vid,
865 bool locked, bool swdev_notify);
866 int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
867 const unsigned char *addr, u16 vid,
869 void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p,
870 const unsigned char *addr, u16 vid, bool offloaded);
878 int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);
879 void br_forward(const struct net_bridge_port *to, struct sk_buff *skb,
880 bool local_rcv, bool local_orig);
881 int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
882 void br_flood(struct net_bridge *br, struct sk_buff *skb,
883 enum br_pkt_type pkt_type, bool local_rcv, bool local_orig,
886 /* return true if both source port and dest port are isolated */
887 static inline bool br_skb_isolated(const struct net_bridge_port *to,
888 const struct sk_buff *skb)
890 return BR_INPUT_SKB_CB(skb)->src_port_isolated &&
891 (to->flags & BR_ISOLATED);
895 void br_port_carrier_check(struct net_bridge_port *p, bool *notified);
896 int br_add_bridge(struct net *net, const char *name);
897 int br_del_bridge(struct net *net, const char *name);
898 int br_add_if(struct net_bridge *br, struct net_device *dev,
899 struct netlink_ext_ack *extack);
900 int br_del_if(struct net_bridge *br, struct net_device *dev);
901 void br_mtu_auto_adjust(struct net_bridge *br);
902 netdev_features_t br_features_recompute(struct net_bridge *br,
903 netdev_features_t features);
904 void br_port_flags_change(struct net_bridge_port *port, unsigned long mask);
905 void br_manage_promisc(struct net_bridge *br);
906 int nbp_backup_change(struct net_bridge_port *p, struct net_device *backup_dev);
909 int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
910 rx_handler_func_t *br_get_rx_handler(const struct net_device *dev);
912 struct br_frame_type {
914 int (*frame_handler)(struct net_bridge_port *port,
915 struct sk_buff *skb);
916 struct hlist_node list;
919 void br_add_frame(struct net_bridge *br, struct br_frame_type *ft);
920 void br_del_frame(struct net_bridge *br, struct br_frame_type *ft);
922 static inline bool br_rx_handler_check_rcu(const struct net_device *dev)
924 return rcu_dereference(dev->rx_handler) == br_get_rx_handler(dev);
927 static inline bool br_rx_handler_check_rtnl(const struct net_device *dev)
929 return rcu_dereference_rtnl(dev->rx_handler) == br_get_rx_handler(dev);
932 static inline struct net_bridge_port *br_port_get_check_rcu(const struct net_device *dev)
934 return br_rx_handler_check_rcu(dev) ? br_port_get_rcu(dev) : NULL;
937 static inline struct net_bridge_port *
938 br_port_get_check_rtnl(const struct net_device *dev)
940 return br_rx_handler_check_rtnl(dev) ? br_port_get_rtnl_rcu(dev) : NULL;
944 int br_dev_siocdevprivate(struct net_device *dev, struct ifreq *rq,
945 void __user *data, int cmd);
946 int br_ioctl_stub(struct net *net, struct net_bridge *br, unsigned int cmd,
947 struct ifreq *ifr, void __user *uarg);
950 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
951 int br_multicast_rcv(struct net_bridge_mcast **brmctx,
952 struct net_bridge_mcast_port **pmctx,
953 struct net_bridge_vlan *vlan,
954 struct sk_buff *skb, u16 vid);
955 struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge_mcast *brmctx,
956 struct sk_buff *skb, u16 vid);
957 int br_multicast_add_port(struct net_bridge_port *port);
958 void br_multicast_del_port(struct net_bridge_port *port);
959 void br_multicast_enable_port(struct net_bridge_port *port);
960 void br_multicast_disable_port(struct net_bridge_port *port);
961 void br_multicast_init(struct net_bridge *br);
962 void br_multicast_join_snoopers(struct net_bridge *br);
963 void br_multicast_leave_snoopers(struct net_bridge *br);
964 void br_multicast_open(struct net_bridge *br);
965 void br_multicast_stop(struct net_bridge *br);
966 void br_multicast_dev_del(struct net_bridge *br);
967 void br_multicast_flood(struct net_bridge_mdb_entry *mdst, struct sk_buff *skb,
968 struct net_bridge_mcast *brmctx,
969 bool local_rcv, bool local_orig);
970 int br_multicast_set_router(struct net_bridge_mcast *brmctx, unsigned long val);
971 int br_multicast_set_port_router(struct net_bridge_mcast_port *pmctx,
973 int br_multicast_set_vlan_router(struct net_bridge_vlan *v, u8 mcast_router);
974 int br_multicast_toggle(struct net_bridge *br, unsigned long val,
975 struct netlink_ext_ack *extack);
976 int br_multicast_set_querier(struct net_bridge_mcast *brmctx, unsigned long val);
977 int br_multicast_set_igmp_version(struct net_bridge_mcast *brmctx,
979 #if IS_ENABLED(CONFIG_IPV6)
980 int br_multicast_set_mld_version(struct net_bridge_mcast *brmctx,
983 struct net_bridge_mdb_entry *
984 br_mdb_ip_get(struct net_bridge *br, struct br_ip *dst);
985 struct net_bridge_mdb_entry *
986 br_multicast_new_group(struct net_bridge *br, struct br_ip *group);
987 struct net_bridge_port_group *
988 br_multicast_new_port_group(struct net_bridge_port *port,
989 const struct br_ip *group,
990 struct net_bridge_port_group __rcu *next,
991 unsigned char flags, const unsigned char *src,
992 u8 filter_mode, u8 rt_protocol,
993 struct netlink_ext_ack *extack);
994 void br_multicast_del_port_group(struct net_bridge_port_group *p);
995 int br_mdb_hash_init(struct net_bridge *br);
996 void br_mdb_hash_fini(struct net_bridge *br);
997 void br_mdb_notify(struct net_device *dev, struct net_bridge_mdb_entry *mp,
998 struct net_bridge_port_group *pg, int type);
999 void br_rtr_notify(struct net_device *dev, struct net_bridge_mcast_port *pmctx,
1001 void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
1002 struct net_bridge_port_group *pg,
1003 struct net_bridge_port_group __rcu **pp);
1004 void br_multicast_count(struct net_bridge *br,
1005 const struct net_bridge_port *p,
1006 const struct sk_buff *skb, u8 type, u8 dir);
1007 int br_multicast_init_stats(struct net_bridge *br);
1008 void br_multicast_uninit_stats(struct net_bridge *br);
1009 void br_multicast_get_stats(const struct net_bridge *br,
1010 const struct net_bridge_port *p,
1011 struct br_mcast_stats *dest);
1012 u32 br_multicast_ngroups_get(const struct net_bridge_mcast_port *pmctx);
1013 void br_multicast_ngroups_set_max(struct net_bridge_mcast_port *pmctx, u32 max);
1014 u32 br_multicast_ngroups_get_max(const struct net_bridge_mcast_port *pmctx);
1015 int br_mdb_add(struct net_device *dev, struct nlattr *tb[], u16 nlmsg_flags,
1016 struct netlink_ext_ack *extack);
1017 int br_mdb_del(struct net_device *dev, struct nlattr *tb[],
1018 struct netlink_ext_ack *extack);
1019 int br_mdb_dump(struct net_device *dev, struct sk_buff *skb,
1020 struct netlink_callback *cb);
1021 void br_multicast_host_join(const struct net_bridge_mcast *brmctx,
1022 struct net_bridge_mdb_entry *mp, bool notify);
1023 void br_multicast_host_leave(struct net_bridge_mdb_entry *mp, bool notify);
1024 void br_multicast_star_g_handle_mode(struct net_bridge_port_group *pg,
1026 void br_multicast_sg_add_exclude_ports(struct net_bridge_mdb_entry *star_mp,
1027 struct net_bridge_port_group *sg);
1028 struct net_bridge_group_src *
1029 br_multicast_find_group_src(struct net_bridge_port_group *pg, struct br_ip *ip);
1030 struct net_bridge_group_src *
1031 br_multicast_new_group_src(struct net_bridge_port_group *pg,
1032 struct br_ip *src_ip);
1033 void __br_multicast_del_group_src(struct net_bridge_group_src *src);
1034 void br_multicast_del_group_src(struct net_bridge_group_src *src,
1036 void br_multicast_ctx_init(struct net_bridge *br,
1037 struct net_bridge_vlan *vlan,
1038 struct net_bridge_mcast *brmctx);
1039 void br_multicast_ctx_deinit(struct net_bridge_mcast *brmctx);
1040 void br_multicast_port_ctx_init(struct net_bridge_port *port,
1041 struct net_bridge_vlan *vlan,
1042 struct net_bridge_mcast_port *pmctx);
1043 void br_multicast_port_ctx_deinit(struct net_bridge_mcast_port *pmctx);
1044 void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan, bool on);
1045 int br_multicast_toggle_vlan_snooping(struct net_bridge *br, bool on,
1046 struct netlink_ext_ack *extack);
1047 bool br_multicast_toggle_global_vlan(struct net_bridge_vlan *vlan, bool on);
1049 int br_rports_fill_info(struct sk_buff *skb,
1050 const struct net_bridge_mcast *brmctx);
1051 int br_multicast_dump_querier_state(struct sk_buff *skb,
1052 const struct net_bridge_mcast *brmctx,
1054 size_t br_multicast_querier_state_size(void);
1055 size_t br_rports_size(const struct net_bridge_mcast *brmctx);
1056 void br_multicast_set_query_intvl(struct net_bridge_mcast *brmctx,
1058 void br_multicast_set_startup_query_intvl(struct net_bridge_mcast *brmctx,
1061 static inline bool br_group_is_l2(const struct br_ip *group)
1063 return group->proto == 0;
1066 #define mlock_dereference(X, br) \
1067 rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock))
1069 static inline struct hlist_node *
1070 br_multicast_get_first_rport_node(struct net_bridge_mcast *brmctx,
1071 struct sk_buff *skb)
1073 #if IS_ENABLED(CONFIG_IPV6)
1074 if (skb->protocol == htons(ETH_P_IPV6))
1075 return rcu_dereference(hlist_first_rcu(&brmctx->ip6_mc_router_list));
1077 return rcu_dereference(hlist_first_rcu(&brmctx->ip4_mc_router_list));
1080 static inline struct net_bridge_port *
1081 br_multicast_rport_from_node_skb(struct hlist_node *rp, struct sk_buff *skb)
1083 struct net_bridge_mcast_port *mctx;
1085 #if IS_ENABLED(CONFIG_IPV6)
1086 if (skb->protocol == htons(ETH_P_IPV6))
1087 mctx = hlist_entry_safe(rp, struct net_bridge_mcast_port,
1091 mctx = hlist_entry_safe(rp, struct net_bridge_mcast_port,
1100 static inline bool br_ip4_multicast_is_router(struct net_bridge_mcast *brmctx)
1102 return timer_pending(&brmctx->ip4_mc_router_timer);
1105 static inline bool br_ip6_multicast_is_router(struct net_bridge_mcast *brmctx)
1107 #if IS_ENABLED(CONFIG_IPV6)
1108 return timer_pending(&brmctx->ip6_mc_router_timer);
1115 br_multicast_is_router(struct net_bridge_mcast *brmctx, struct sk_buff *skb)
1117 switch (brmctx->multicast_router) {
1118 case MDB_RTR_TYPE_PERM:
1120 case MDB_RTR_TYPE_TEMP_QUERY:
1122 if (skb->protocol == htons(ETH_P_IP))
1123 return br_ip4_multicast_is_router(brmctx);
1124 else if (skb->protocol == htons(ETH_P_IPV6))
1125 return br_ip6_multicast_is_router(brmctx);
1127 return br_ip4_multicast_is_router(brmctx) ||
1128 br_ip6_multicast_is_router(brmctx);
1137 __br_multicast_querier_exists(struct net_bridge_mcast *brmctx,
1138 struct bridge_mcast_other_query *querier,
1141 bool own_querier_enabled;
1143 if (brmctx->multicast_querier) {
1144 if (is_ipv6 && !br_opt_get(brmctx->br, BROPT_HAS_IPV6_ADDR))
1145 own_querier_enabled = false;
1147 own_querier_enabled = true;
1149 own_querier_enabled = false;
1152 return !timer_pending(&querier->delay_timer) &&
1153 (own_querier_enabled || timer_pending(&querier->timer));
1156 static inline bool br_multicast_querier_exists(struct net_bridge_mcast *brmctx,
1158 const struct net_bridge_mdb_entry *mdb)
1160 switch (eth->h_proto) {
1161 case (htons(ETH_P_IP)):
1162 return __br_multicast_querier_exists(brmctx,
1163 &brmctx->ip4_other_query, false);
1164 #if IS_ENABLED(CONFIG_IPV6)
1165 case (htons(ETH_P_IPV6)):
1166 return __br_multicast_querier_exists(brmctx,
1167 &brmctx->ip6_other_query, true);
1170 return !!mdb && br_group_is_l2(&mdb->addr);
1174 static inline bool br_multicast_is_star_g(const struct br_ip *ip)
1176 switch (ip->proto) {
1177 case htons(ETH_P_IP):
1178 return ipv4_is_zeronet(ip->src.ip4);
1179 #if IS_ENABLED(CONFIG_IPV6)
1180 case htons(ETH_P_IPV6):
1181 return ipv6_addr_any(&ip->src.ip6);
1189 br_multicast_should_handle_mode(const struct net_bridge_mcast *brmctx,
1193 case htons(ETH_P_IP):
1194 return !!(brmctx->multicast_igmp_version == 3);
1195 #if IS_ENABLED(CONFIG_IPV6)
1196 case htons(ETH_P_IPV6):
1197 return !!(brmctx->multicast_mld_version == 2);
1204 static inline int br_multicast_igmp_type(const struct sk_buff *skb)
1206 return BR_INPUT_SKB_CB(skb)->igmp;
1209 static inline unsigned long br_multicast_lmqt(const struct net_bridge_mcast *brmctx)
1211 return brmctx->multicast_last_member_interval *
1212 brmctx->multicast_last_member_count;
1215 static inline unsigned long br_multicast_gmi(const struct net_bridge_mcast *brmctx)
1217 return brmctx->multicast_membership_interval;
1221 br_multicast_ctx_is_vlan(const struct net_bridge_mcast *brmctx)
1223 return !!brmctx->vlan;
1227 br_multicast_port_ctx_is_vlan(const struct net_bridge_mcast_port *pmctx)
1229 return !!pmctx->vlan;
1232 static inline struct net_bridge_mcast *
1233 br_multicast_port_ctx_get_global(const struct net_bridge_mcast_port *pmctx)
1235 if (!br_multicast_port_ctx_is_vlan(pmctx))
1236 return &pmctx->port->br->multicast_ctx;
1238 return &pmctx->vlan->brvlan->br_mcast_ctx;
1242 br_multicast_ctx_vlan_global_disabled(const struct net_bridge_mcast *brmctx)
1244 return br_multicast_ctx_is_vlan(brmctx) &&
1245 (!br_opt_get(brmctx->br, BROPT_MCAST_VLAN_SNOOPING_ENABLED) ||
1246 !(brmctx->vlan->priv_flags & BR_VLFLAG_GLOBAL_MCAST_ENABLED));
1250 br_multicast_ctx_vlan_disabled(const struct net_bridge_mcast *brmctx)
1252 return br_multicast_ctx_is_vlan(brmctx) &&
1253 !(brmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED);
1257 br_multicast_port_ctx_vlan_disabled(const struct net_bridge_mcast_port *pmctx)
1259 return br_multicast_port_ctx_is_vlan(pmctx) &&
1260 !(pmctx->vlan->priv_flags & BR_VLFLAG_MCAST_ENABLED);
1264 br_multicast_port_ctx_state_disabled(const struct net_bridge_mcast_port *pmctx)
1266 return pmctx->port->state == BR_STATE_DISABLED ||
1267 (br_multicast_port_ctx_is_vlan(pmctx) &&
1268 (br_multicast_port_ctx_vlan_disabled(pmctx) ||
1269 pmctx->vlan->state == BR_STATE_DISABLED));
1273 br_multicast_port_ctx_state_stopped(const struct net_bridge_mcast_port *pmctx)
1275 return br_multicast_port_ctx_state_disabled(pmctx) ||
1276 pmctx->port->state == BR_STATE_BLOCKING ||
1277 (br_multicast_port_ctx_is_vlan(pmctx) &&
1278 pmctx->vlan->state == BR_STATE_BLOCKING);
1282 br_rports_have_mc_router(const struct net_bridge_mcast *brmctx)
1284 #if IS_ENABLED(CONFIG_IPV6)
1285 return !hlist_empty(&brmctx->ip4_mc_router_list) ||
1286 !hlist_empty(&brmctx->ip6_mc_router_list);
1288 return !hlist_empty(&brmctx->ip4_mc_router_list);
1293 br_multicast_ctx_options_equal(const struct net_bridge_mcast *brmctx1,
1294 const struct net_bridge_mcast *brmctx2)
1296 return brmctx1->multicast_igmp_version ==
1297 brmctx2->multicast_igmp_version &&
1298 brmctx1->multicast_last_member_count ==
1299 brmctx2->multicast_last_member_count &&
1300 brmctx1->multicast_startup_query_count ==
1301 brmctx2->multicast_startup_query_count &&
1302 brmctx1->multicast_last_member_interval ==
1303 brmctx2->multicast_last_member_interval &&
1304 brmctx1->multicast_membership_interval ==
1305 brmctx2->multicast_membership_interval &&
1306 brmctx1->multicast_querier_interval ==
1307 brmctx2->multicast_querier_interval &&
1308 brmctx1->multicast_query_interval ==
1309 brmctx2->multicast_query_interval &&
1310 brmctx1->multicast_query_response_interval ==
1311 brmctx2->multicast_query_response_interval &&
1312 brmctx1->multicast_startup_query_interval ==
1313 brmctx2->multicast_startup_query_interval &&
1314 brmctx1->multicast_querier == brmctx2->multicast_querier &&
1315 brmctx1->multicast_router == brmctx2->multicast_router &&
1316 !br_rports_have_mc_router(brmctx1) &&
1317 !br_rports_have_mc_router(brmctx2) &&
1318 #if IS_ENABLED(CONFIG_IPV6)
1319 brmctx1->multicast_mld_version ==
1320 brmctx2->multicast_mld_version &&
1326 br_multicast_ctx_matches_vlan_snooping(const struct net_bridge_mcast *brmctx)
1328 bool vlan_snooping_enabled;
1330 vlan_snooping_enabled = !!br_opt_get(brmctx->br,
1331 BROPT_MCAST_VLAN_SNOOPING_ENABLED);
1333 return !!(vlan_snooping_enabled == br_multicast_ctx_is_vlan(brmctx));
1336 static inline int br_multicast_rcv(struct net_bridge_mcast **brmctx,
1337 struct net_bridge_mcast_port **pmctx,
1338 struct net_bridge_vlan *vlan,
1339 struct sk_buff *skb,
1345 static inline struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge_mcast *brmctx,
1346 struct sk_buff *skb, u16 vid)
1351 static inline int br_multicast_add_port(struct net_bridge_port *port)
1356 static inline void br_multicast_del_port(struct net_bridge_port *port)
1360 static inline void br_multicast_enable_port(struct net_bridge_port *port)
1364 static inline void br_multicast_disable_port(struct net_bridge_port *port)
1368 static inline void br_multicast_init(struct net_bridge *br)
1372 static inline void br_multicast_join_snoopers(struct net_bridge *br)
1376 static inline void br_multicast_leave_snoopers(struct net_bridge *br)
1380 static inline void br_multicast_open(struct net_bridge *br)
1384 static inline void br_multicast_stop(struct net_bridge *br)
1388 static inline void br_multicast_dev_del(struct net_bridge *br)
1392 static inline void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
1393 struct sk_buff *skb,
1394 struct net_bridge_mcast *brmctx,
1395 bool local_rcv, bool local_orig)
1399 static inline bool br_multicast_is_router(struct net_bridge_mcast *brmctx,
1400 struct sk_buff *skb)
1405 static inline bool br_multicast_querier_exists(struct net_bridge_mcast *brmctx,
1407 const struct net_bridge_mdb_entry *mdb)
1412 static inline int br_mdb_add(struct net_device *dev, struct nlattr *tb[],
1413 u16 nlmsg_flags, struct netlink_ext_ack *extack)
1418 static inline int br_mdb_del(struct net_device *dev, struct nlattr *tb[],
1419 struct netlink_ext_ack *extack)
1424 static inline int br_mdb_dump(struct net_device *dev, struct sk_buff *skb,
1425 struct netlink_callback *cb)
1430 static inline int br_mdb_hash_init(struct net_bridge *br)
1435 static inline void br_mdb_hash_fini(struct net_bridge *br)
1439 static inline void br_multicast_count(struct net_bridge *br,
1440 const struct net_bridge_port *p,
1441 const struct sk_buff *skb,
1446 static inline int br_multicast_init_stats(struct net_bridge *br)
1451 static inline void br_multicast_uninit_stats(struct net_bridge *br)
1455 static inline int br_multicast_igmp_type(const struct sk_buff *skb)
1460 static inline void br_multicast_ctx_init(struct net_bridge *br,
1461 struct net_bridge_vlan *vlan,
1462 struct net_bridge_mcast *brmctx)
1466 static inline void br_multicast_ctx_deinit(struct net_bridge_mcast *brmctx)
1470 static inline void br_multicast_port_ctx_init(struct net_bridge_port *port,
1471 struct net_bridge_vlan *vlan,
1472 struct net_bridge_mcast_port *pmctx)
1476 static inline void br_multicast_port_ctx_deinit(struct net_bridge_mcast_port *pmctx)
1480 static inline void br_multicast_toggle_one_vlan(struct net_bridge_vlan *vlan,
1485 static inline int br_multicast_toggle_vlan_snooping(struct net_bridge *br,
1487 struct netlink_ext_ack *extack)
1492 static inline bool br_multicast_toggle_global_vlan(struct net_bridge_vlan *vlan,
1499 br_multicast_ctx_options_equal(const struct net_bridge_mcast *brmctx1,
1500 const struct net_bridge_mcast *brmctx2)
1507 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
1508 bool br_allowed_ingress(const struct net_bridge *br,
1509 struct net_bridge_vlan_group *vg, struct sk_buff *skb,
1510 u16 *vid, u8 *state,
1511 struct net_bridge_vlan **vlan);
1512 bool br_allowed_egress(struct net_bridge_vlan_group *vg,
1513 const struct sk_buff *skb);
1514 bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid);
1515 struct sk_buff *br_handle_vlan(struct net_bridge *br,
1516 const struct net_bridge_port *port,
1517 struct net_bridge_vlan_group *vg,
1518 struct sk_buff *skb);
1519 int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags,
1520 bool *changed, struct netlink_ext_ack *extack);
1521 int br_vlan_delete(struct net_bridge *br, u16 vid);
1522 void br_vlan_flush(struct net_bridge *br);
1523 struct net_bridge_vlan *br_vlan_find(struct net_bridge_vlan_group *vg, u16 vid);
1524 void br_recalculate_fwd_mask(struct net_bridge *br);
1525 int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val,
1526 struct netlink_ext_ack *extack);
1527 int __br_vlan_set_proto(struct net_bridge *br, __be16 proto,
1528 struct netlink_ext_ack *extack);
1529 int br_vlan_set_proto(struct net_bridge *br, unsigned long val,
1530 struct netlink_ext_ack *extack);
1531 int br_vlan_set_stats(struct net_bridge *br, unsigned long val);
1532 int br_vlan_set_stats_per_port(struct net_bridge *br, unsigned long val);
1533 int br_vlan_init(struct net_bridge *br);
1534 int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val,
1535 struct netlink_ext_ack *extack);
1536 int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid,
1537 struct netlink_ext_ack *extack);
1538 int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
1539 bool *changed, struct netlink_ext_ack *extack);
1540 int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);
1541 void nbp_vlan_flush(struct net_bridge_port *port);
1542 int nbp_vlan_init(struct net_bridge_port *port, struct netlink_ext_ack *extack);
1543 int nbp_get_num_vlan_infos(struct net_bridge_port *p, u32 filter_mask);
1544 void br_vlan_get_stats(const struct net_bridge_vlan *v,
1545 struct pcpu_sw_netstats *stats);
1546 void br_vlan_port_event(struct net_bridge_port *p, unsigned long event);
1547 int br_vlan_bridge_event(struct net_device *dev, unsigned long event,
1549 void br_vlan_rtnl_init(void);
1550 void br_vlan_rtnl_uninit(void);
1551 void br_vlan_notify(const struct net_bridge *br,
1552 const struct net_bridge_port *p,
1553 u16 vid, u16 vid_range,
1555 bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr,
1556 const struct net_bridge_vlan *range_end);
1558 void br_vlan_fill_forward_path_pvid(struct net_bridge *br,
1559 struct net_device_path_ctx *ctx,
1560 struct net_device_path *path);
1561 int br_vlan_fill_forward_path_mode(struct net_bridge *br,
1562 struct net_bridge_port *dst,
1563 struct net_device_path *path);
1565 static inline struct net_bridge_vlan_group *br_vlan_group(
1566 const struct net_bridge *br)
1568 return rtnl_dereference(br->vlgrp);
1571 static inline struct net_bridge_vlan_group *nbp_vlan_group(
1572 const struct net_bridge_port *p)
1574 return rtnl_dereference(p->vlgrp);
1577 static inline struct net_bridge_vlan_group *br_vlan_group_rcu(
1578 const struct net_bridge *br)
1580 return rcu_dereference(br->vlgrp);
1583 static inline struct net_bridge_vlan_group *nbp_vlan_group_rcu(
1584 const struct net_bridge_port *p)
1586 return rcu_dereference(p->vlgrp);
1589 /* Since bridge now depends on 8021Q module, but the time bridge sees the
1590 * skb, the vlan tag will always be present if the frame was tagged.
1592 static inline int br_vlan_get_tag(const struct sk_buff *skb, u16 *vid)
1596 if (skb_vlan_tag_present(skb)) {
1597 *vid = skb_vlan_tag_get_id(skb);
1606 static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
1615 static inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid)
1617 return v->vid == pvid ? v->flags | BRIDGE_VLAN_INFO_PVID : v->flags;
1620 static inline bool br_allowed_ingress(const struct net_bridge *br,
1621 struct net_bridge_vlan_group *vg,
1622 struct sk_buff *skb,
1623 u16 *vid, u8 *state,
1624 struct net_bridge_vlan **vlan)
1631 static inline bool br_allowed_egress(struct net_bridge_vlan_group *vg,
1632 const struct sk_buff *skb)
1637 static inline bool br_should_learn(struct net_bridge_port *p,
1638 struct sk_buff *skb, u16 *vid)
1643 static inline struct sk_buff *br_handle_vlan(struct net_bridge *br,
1644 const struct net_bridge_port *port,
1645 struct net_bridge_vlan_group *vg,
1646 struct sk_buff *skb)
1651 static inline int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags,
1652 bool *changed, struct netlink_ext_ack *extack)
1658 static inline int br_vlan_delete(struct net_bridge *br, u16 vid)
1663 static inline void br_vlan_flush(struct net_bridge *br)
1667 static inline void br_recalculate_fwd_mask(struct net_bridge *br)
1671 static inline int br_vlan_init(struct net_bridge *br)
1676 static inline int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
1677 bool *changed, struct netlink_ext_ack *extack)
1683 static inline int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
1688 static inline void nbp_vlan_flush(struct net_bridge_port *port)
1692 static inline struct net_bridge_vlan *br_vlan_find(struct net_bridge_vlan_group *vg,
1698 static inline int nbp_vlan_init(struct net_bridge_port *port,
1699 struct netlink_ext_ack *extack)
1704 static inline u16 br_vlan_get_tag(const struct sk_buff *skb, u16 *tag)
1709 static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
1714 static inline int br_vlan_filter_toggle(struct net_bridge *br,
1716 struct netlink_ext_ack *extack)
1721 static inline int nbp_get_num_vlan_infos(struct net_bridge_port *p,
1727 static inline void br_vlan_fill_forward_path_pvid(struct net_bridge *br,
1728 struct net_device_path_ctx *ctx,
1729 struct net_device_path *path)
1733 static inline int br_vlan_fill_forward_path_mode(struct net_bridge *br,
1734 struct net_bridge_port *dst,
1735 struct net_device_path *path)
1740 static inline struct net_bridge_vlan_group *br_vlan_group(
1741 const struct net_bridge *br)
1746 static inline struct net_bridge_vlan_group *nbp_vlan_group(
1747 const struct net_bridge_port *p)
1752 static inline struct net_bridge_vlan_group *br_vlan_group_rcu(
1753 const struct net_bridge *br)
1758 static inline struct net_bridge_vlan_group *nbp_vlan_group_rcu(
1759 const struct net_bridge_port *p)
1764 static inline void br_vlan_get_stats(const struct net_bridge_vlan *v,
1765 struct pcpu_sw_netstats *stats)
1769 static inline void br_vlan_port_event(struct net_bridge_port *p,
1770 unsigned long event)
1774 static inline int br_vlan_bridge_event(struct net_device *dev,
1775 unsigned long event, void *ptr)
1780 static inline void br_vlan_rtnl_init(void)
1784 static inline void br_vlan_rtnl_uninit(void)
1788 static inline void br_vlan_notify(const struct net_bridge *br,
1789 const struct net_bridge_port *p,
1790 u16 vid, u16 vid_range,
1795 static inline bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr,
1796 const struct net_bridge_vlan *range_end)
1801 static inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid)
1808 /* br_vlan_options.c */
1809 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
1810 bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr,
1811 const struct net_bridge_vlan *range_end);
1812 bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v,
1813 const struct net_bridge_port *p);
1814 size_t br_vlan_opts_nl_size(void);
1815 int br_vlan_process_options(const struct net_bridge *br,
1816 const struct net_bridge_port *p,
1817 struct net_bridge_vlan *range_start,
1818 struct net_bridge_vlan *range_end,
1820 struct netlink_ext_ack *extack);
1821 int br_vlan_rtm_process_global_options(struct net_device *dev,
1822 const struct nlattr *attr,
1824 struct netlink_ext_ack *extack);
1825 bool br_vlan_global_opts_can_enter_range(const struct net_bridge_vlan *v_curr,
1826 const struct net_bridge_vlan *r_end);
1827 bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range,
1828 const struct net_bridge_vlan *v_opts);
1830 /* vlan state manipulation helpers using *_ONCE to annotate lock-free access */
1831 static inline u8 br_vlan_get_state(const struct net_bridge_vlan *v)
1833 return READ_ONCE(v->state);
1836 static inline void br_vlan_set_state(struct net_bridge_vlan *v, u8 state)
1838 WRITE_ONCE(v->state, state);
1841 static inline u8 br_vlan_get_pvid_state(const struct net_bridge_vlan_group *vg)
1843 return READ_ONCE(vg->pvid_state);
1846 static inline void br_vlan_set_pvid_state(struct net_bridge_vlan_group *vg,
1849 WRITE_ONCE(vg->pvid_state, state);
1852 /* learn_allow is true at ingress and false at egress */
1853 static inline bool br_vlan_state_allowed(u8 state, bool learn_allow)
1856 case BR_STATE_LEARNING:
1858 case BR_STATE_FORWARDING:
1867 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
1868 DECLARE_STATIC_KEY_FALSE(br_mst_used);
1869 static inline bool br_mst_is_enabled(struct net_bridge *br)
1871 return static_branch_unlikely(&br_mst_used) &&
1872 br_opt_get(br, BROPT_MST_ENABLED);
1875 int br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state,
1876 struct netlink_ext_ack *extack);
1877 int br_mst_vlan_set_msti(struct net_bridge_vlan *v, u16 msti);
1878 void br_mst_vlan_init_state(struct net_bridge_vlan *v);
1879 int br_mst_set_enabled(struct net_bridge *br, bool on,
1880 struct netlink_ext_ack *extack);
1881 size_t br_mst_info_size(const struct net_bridge_vlan_group *vg);
1882 int br_mst_fill_info(struct sk_buff *skb,
1883 const struct net_bridge_vlan_group *vg);
1884 int br_mst_process(struct net_bridge_port *p, const struct nlattr *mst_attr,
1885 struct netlink_ext_ack *extack);
1887 static inline bool br_mst_is_enabled(struct net_bridge *br)
1892 static inline int br_mst_set_state(struct net_bridge_port *p, u16 msti,
1893 u8 state, struct netlink_ext_ack *extack)
1898 static inline int br_mst_set_enabled(struct net_bridge *br, bool on,
1899 struct netlink_ext_ack *extack)
1904 static inline size_t br_mst_info_size(const struct net_bridge_vlan_group *vg)
1909 static inline int br_mst_fill_info(struct sk_buff *skb,
1910 const struct net_bridge_vlan_group *vg)
1915 static inline int br_mst_process(struct net_bridge_port *p,
1916 const struct nlattr *mst_attr,
1917 struct netlink_ext_ack *extack)
1924 int (*br_dev_xmit_hook)(struct sk_buff *skb);
1926 extern const struct nf_br_ops __rcu *nf_br_ops;
1928 /* br_netfilter.c */
1929 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
1930 int br_nf_core_init(void);
1931 void br_nf_core_fini(void);
1932 void br_netfilter_rtable_init(struct net_bridge *);
1934 static inline int br_nf_core_init(void) { return 0; }
1935 static inline void br_nf_core_fini(void) {}
1936 #define br_netfilter_rtable_init(x)
1940 void br_set_state(struct net_bridge_port *p, unsigned int state);
1941 struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no);
1942 void br_init_port(struct net_bridge_port *p);
1943 void br_become_designated_port(struct net_bridge_port *p);
1945 void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
1946 int br_set_forward_delay(struct net_bridge *br, unsigned long x);
1947 int br_set_hello_time(struct net_bridge *br, unsigned long x);
1948 int br_set_max_age(struct net_bridge *br, unsigned long x);
1949 int __set_ageing_time(struct net_device *dev, unsigned long t);
1950 int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time);
1954 void br_stp_enable_bridge(struct net_bridge *br);
1955 void br_stp_disable_bridge(struct net_bridge *br);
1956 int br_stp_set_enabled(struct net_bridge *br, unsigned long val,
1957 struct netlink_ext_ack *extack);
1958 void br_stp_enable_port(struct net_bridge_port *p);
1959 void br_stp_disable_port(struct net_bridge_port *p);
1960 bool br_stp_recalculate_bridge_id(struct net_bridge *br);
1961 void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *a);
1962 void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio);
1963 int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio);
1964 int br_stp_set_path_cost(struct net_bridge_port *p, unsigned long path_cost);
1965 ssize_t br_show_bridge_id(char *buf, const struct bridge_id *id);
1969 void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
1970 struct net_device *dev);
1972 /* br_stp_timer.c */
1973 void br_stp_timer_init(struct net_bridge *br);
1974 void br_stp_port_timer_init(struct net_bridge_port *p);
1975 unsigned long br_timer_value(const struct timer_list *timer);
1978 #if IS_ENABLED(CONFIG_ATM_LANE)
1979 extern int (*br_fdb_test_addr_hook)(struct net_device *dev, unsigned char *addr);
1983 #if IS_ENABLED(CONFIG_BRIDGE_MRP)
1984 int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
1985 struct nlattr *attr, int cmd, struct netlink_ext_ack *extack);
1986 bool br_mrp_enabled(struct net_bridge *br);
1987 void br_mrp_port_del(struct net_bridge *br, struct net_bridge_port *p);
1988 int br_mrp_fill_info(struct sk_buff *skb, struct net_bridge *br);
1990 static inline int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
1991 struct nlattr *attr, int cmd,
1992 struct netlink_ext_ack *extack)
1997 static inline bool br_mrp_enabled(struct net_bridge *br)
2002 static inline void br_mrp_port_del(struct net_bridge *br,
2003 struct net_bridge_port *p)
2007 static inline int br_mrp_fill_info(struct sk_buff *skb, struct net_bridge *br)
2015 #if IS_ENABLED(CONFIG_BRIDGE_CFM)
2016 int br_cfm_parse(struct net_bridge *br, struct net_bridge_port *p,
2017 struct nlattr *attr, int cmd, struct netlink_ext_ack *extack);
2018 bool br_cfm_created(struct net_bridge *br);
2019 void br_cfm_port_del(struct net_bridge *br, struct net_bridge_port *p);
2020 int br_cfm_config_fill_info(struct sk_buff *skb, struct net_bridge *br);
2021 int br_cfm_status_fill_info(struct sk_buff *skb,
2022 struct net_bridge *br,
2024 int br_cfm_mep_count(struct net_bridge *br, u32 *count);
2025 int br_cfm_peer_mep_count(struct net_bridge *br, u32 *count);
2027 static inline int br_cfm_parse(struct net_bridge *br, struct net_bridge_port *p,
2028 struct nlattr *attr, int cmd,
2029 struct netlink_ext_ack *extack)
2034 static inline bool br_cfm_created(struct net_bridge *br)
2039 static inline void br_cfm_port_del(struct net_bridge *br,
2040 struct net_bridge_port *p)
2044 static inline int br_cfm_config_fill_info(struct sk_buff *skb, struct net_bridge *br)
2049 static inline int br_cfm_status_fill_info(struct sk_buff *skb,
2050 struct net_bridge *br,
2056 static inline int br_cfm_mep_count(struct net_bridge *br, u32 *count)
2062 static inline int br_cfm_peer_mep_count(struct net_bridge *br, u32 *count)
2070 extern struct rtnl_link_ops br_link_ops;
2071 int br_netlink_init(void);
2072 void br_netlink_fini(void);
2073 void br_ifinfo_notify(int event, const struct net_bridge *br,
2074 const struct net_bridge_port *port);
2075 void br_info_notify(int event, const struct net_bridge *br,
2076 const struct net_bridge_port *port, u32 filter);
2077 int br_setlink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags,
2078 struct netlink_ext_ack *extack);
2079 int br_dellink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags);
2080 int br_getlink(struct sk_buff *skb, u32 pid, u32 seq, struct net_device *dev,
2081 u32 filter_mask, int nlflags);
2082 int br_process_vlan_info(struct net_bridge *br,
2083 struct net_bridge_port *p, int cmd,
2084 struct bridge_vlan_info *vinfo_curr,
2085 struct bridge_vlan_info **vinfo_last,
2087 struct netlink_ext_ack *extack);
2091 extern const struct sysfs_ops brport_sysfs_ops;
2092 int br_sysfs_addif(struct net_bridge_port *p);
2093 int br_sysfs_renameif(struct net_bridge_port *p);
2096 int br_sysfs_addbr(struct net_device *dev);
2097 void br_sysfs_delbr(struct net_device *dev);
2101 static inline int br_sysfs_addif(struct net_bridge_port *p) { return 0; }
2102 static inline int br_sysfs_renameif(struct net_bridge_port *p) { return 0; }
2103 static inline int br_sysfs_addbr(struct net_device *dev) { return 0; }
2104 static inline void br_sysfs_delbr(struct net_device *dev) { return; }
2105 #endif /* CONFIG_SYSFS */
2107 /* br_switchdev.c */
2108 #ifdef CONFIG_NET_SWITCHDEV
2109 int br_switchdev_port_offload(struct net_bridge_port *p,
2110 struct net_device *dev, const void *ctx,
2111 struct notifier_block *atomic_nb,
2112 struct notifier_block *blocking_nb,
2113 bool tx_fwd_offload,
2114 struct netlink_ext_ack *extack);
2116 void br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx,
2117 struct notifier_block *atomic_nb,
2118 struct notifier_block *blocking_nb);
2120 int br_switchdev_port_replay(struct net_bridge_port *p,
2121 struct net_device *dev, const void *ctx,
2122 struct notifier_block *atomic_nb,
2123 struct notifier_block *blocking_nb,
2124 struct netlink_ext_ack *extack);
2126 bool br_switchdev_frame_uses_tx_fwd_offload(struct sk_buff *skb);
2128 void br_switchdev_frame_set_offload_fwd_mark(struct sk_buff *skb);
2130 void nbp_switchdev_frame_mark_tx_fwd_offload(const struct net_bridge_port *p,
2131 struct sk_buff *skb);
2132 void nbp_switchdev_frame_mark_tx_fwd_to_hwdom(const struct net_bridge_port *p,
2133 struct sk_buff *skb);
2134 void nbp_switchdev_frame_mark(const struct net_bridge_port *p,
2135 struct sk_buff *skb);
2136 bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
2137 const struct sk_buff *skb);
2138 int br_switchdev_set_port_flag(struct net_bridge_port *p,
2139 unsigned long flags,
2141 struct netlink_ext_ack *extack);
2142 void br_switchdev_fdb_notify(struct net_bridge *br,
2143 const struct net_bridge_fdb_entry *fdb, int type);
2144 void br_switchdev_mdb_notify(struct net_device *dev,
2145 struct net_bridge_mdb_entry *mp,
2146 struct net_bridge_port_group *pg,
2148 int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags,
2149 bool changed, struct netlink_ext_ack *extack);
2150 int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid);
2151 void br_switchdev_init(struct net_bridge *br);
2153 static inline void br_switchdev_frame_unmark(struct sk_buff *skb)
2155 skb->offload_fwd_mark = 0;
2159 br_switchdev_port_offload(struct net_bridge_port *p,
2160 struct net_device *dev, const void *ctx,
2161 struct notifier_block *atomic_nb,
2162 struct notifier_block *blocking_nb,
2163 bool tx_fwd_offload,
2164 struct netlink_ext_ack *extack)
2170 br_switchdev_port_unoffload(struct net_bridge_port *p, const void *ctx,
2171 struct notifier_block *atomic_nb,
2172 struct notifier_block *blocking_nb)
2177 br_switchdev_port_replay(struct net_bridge_port *p,
2178 struct net_device *dev, const void *ctx,
2179 struct notifier_block *atomic_nb,
2180 struct notifier_block *blocking_nb,
2181 struct netlink_ext_ack *extack)
2186 static inline bool br_switchdev_frame_uses_tx_fwd_offload(struct sk_buff *skb)
2191 static inline void br_switchdev_frame_set_offload_fwd_mark(struct sk_buff *skb)
2196 nbp_switchdev_frame_mark_tx_fwd_offload(const struct net_bridge_port *p,
2197 struct sk_buff *skb)
2202 nbp_switchdev_frame_mark_tx_fwd_to_hwdom(const struct net_bridge_port *p,
2203 struct sk_buff *skb)
2207 static inline void nbp_switchdev_frame_mark(const struct net_bridge_port *p,
2208 struct sk_buff *skb)
2212 static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
2213 const struct sk_buff *skb)
2218 static inline int br_switchdev_set_port_flag(struct net_bridge_port *p,
2219 unsigned long flags,
2221 struct netlink_ext_ack *extack)
2226 static inline int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid,
2227 u16 flags, bool changed,
2228 struct netlink_ext_ack *extack)
2233 static inline int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid)
2239 br_switchdev_fdb_notify(struct net_bridge *br,
2240 const struct net_bridge_fdb_entry *fdb, int type)
2244 static inline void br_switchdev_mdb_notify(struct net_device *dev,
2245 struct net_bridge_mdb_entry *mp,
2246 struct net_bridge_port_group *pg,
2251 static inline void br_switchdev_frame_unmark(struct sk_buff *skb)
2255 static inline void br_switchdev_init(struct net_bridge *br)
2259 #endif /* CONFIG_NET_SWITCHDEV */
2261 /* br_arp_nd_proxy.c */
2262 void br_recalculate_neigh_suppress_enabled(struct net_bridge *br);
2263 void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
2264 u16 vid, struct net_bridge_port *p);
2265 void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
2266 u16 vid, struct net_bridge_port *p, struct nd_msg *msg);
2267 struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb, struct nd_msg *m);
2268 bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p, u16 vid);