xref: /openbmc/linux/net/bridge/br_private.h (revision 3922285d)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *	Linux ethernet bridge
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *	Authors:
51da177e4SLinus Torvalds  *	Lennert Buytenhek		<buytenh@gnu.org>
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  *	This program is free software; you can redistribute it and/or
81da177e4SLinus Torvalds  *	modify it under the terms of the GNU General Public License
91da177e4SLinus Torvalds  *	as published by the Free Software Foundation; either version
101da177e4SLinus Torvalds  *	2 of the License, or (at your option) any later version.
111da177e4SLinus Torvalds  */
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds #ifndef _BR_PRIVATE_H
141da177e4SLinus Torvalds #define _BR_PRIVATE_H
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds #include <linux/netdevice.h>
171da177e4SLinus Torvalds #include <linux/if_bridge.h>
1891d2c34aSHerbert Xu #include <linux/netpoll.h>
19406818ffSEric Dumazet #include <linux/u64_stats_sync.h>
204adf0af6SSimon Wunderlich #include <net/route.h>
21efb6de9bSBernhard Thaler #include <net/ip6_fib.h>
22243a2e63SVlad Yasevich #include <linux/if_vlan.h>
232594e906SNikolay Aleksandrov #include <linux/rhashtable.h>
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds #define BR_HASH_BITS 8
261da177e4SLinus Torvalds #define BR_HASH_SIZE (1 << BR_HASH_BITS)
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds #define BR_HOLD_TIME (1*HZ)
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds #define BR_PORT_BITS	10
311da177e4SLinus Torvalds #define BR_MAX_PORTS	(1<<BR_PORT_BITS)
321da177e4SLinus Torvalds 
339cde0708SStephen Hemminger #define BR_VERSION	"2.3"
349cde0708SStephen Hemminger 
35515853ccSstephen hemminger /* Control of forwarding link local multicast */
36515853ccSstephen hemminger #define BR_GROUPFWD_DEFAULT	0
37784b58a3SBernhard Thaler /* Don't allow forwarding of control protocols like STP, MAC PAUSE and LACP */
38784b58a3SBernhard Thaler #define BR_GROUPFWD_RESTRICTED	0x0007u
39f2808d22SToshiaki Makita /* The Nearest Customer Bridge Group Address, 01-80-C2-00-00-[00,0B,0C,0D,0F] */
40f2808d22SToshiaki Makita #define BR_GROUPFWD_8021AD	0xB801u
41515853ccSstephen hemminger 
429cde0708SStephen Hemminger /* Path to usermode spanning tree program */
439cde0708SStephen Hemminger #define BR_STP_PROG	"/sbin/bridge-stp"
448cbb512eSStephen Hemminger 
451da177e4SLinus Torvalds typedef struct bridge_id bridge_id;
461da177e4SLinus Torvalds typedef struct mac_addr mac_addr;
471da177e4SLinus Torvalds typedef __u16 port_id;
481da177e4SLinus Torvalds 
491da177e4SLinus Torvalds struct bridge_id
501da177e4SLinus Torvalds {
511da177e4SLinus Torvalds 	unsigned char	prio[2];
52e5a727f6SJoe Perches 	unsigned char	addr[ETH_ALEN];
531da177e4SLinus Torvalds };
541da177e4SLinus Torvalds 
551da177e4SLinus Torvalds struct mac_addr
561da177e4SLinus Torvalds {
57e5a727f6SJoe Perches 	unsigned char	addr[ETH_ALEN];
581da177e4SLinus Torvalds };
591da177e4SLinus Torvalds 
60cc0fdd80SLinus Lüssing #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
61cc0fdd80SLinus Lüssing /* our own querier */
6290010b36SLinus Lüssing struct bridge_mcast_own_query {
63cc0fdd80SLinus Lüssing 	struct timer_list	timer;
64cc0fdd80SLinus Lüssing 	u32			startup_sent;
65cc0fdd80SLinus Lüssing };
66cc0fdd80SLinus Lüssing 
67cc0fdd80SLinus Lüssing /* other querier */
6890010b36SLinus Lüssing struct bridge_mcast_other_query {
69cc0fdd80SLinus Lüssing 	struct timer_list		timer;
70cc0fdd80SLinus Lüssing 	unsigned long			delay_time;
71cc0fdd80SLinus Lüssing };
72dc4eb53aSLinus Lüssing 
73dc4eb53aSLinus Lüssing /* selected querier */
74dc4eb53aSLinus Lüssing struct bridge_mcast_querier {
75dc4eb53aSLinus Lüssing 	struct br_ip addr;
762cd41431SLinus Lüssing 	struct net_bridge_port __rcu	*port;
77dc4eb53aSLinus Lüssing };
781080ab95SNikolay Aleksandrov 
791080ab95SNikolay Aleksandrov /* IGMP/MLD statistics */
801080ab95SNikolay Aleksandrov struct bridge_mcast_stats {
811080ab95SNikolay Aleksandrov 	struct br_mcast_stats mstats;
821080ab95SNikolay Aleksandrov 	struct u64_stats_sync syncp;
831080ab95SNikolay Aleksandrov };
84cc0fdd80SLinus Lüssing #endif
85cc0fdd80SLinus Lüssing 
866dada9b1SNikolay Aleksandrov struct br_vlan_stats {
876dada9b1SNikolay Aleksandrov 	u64 rx_bytes;
886dada9b1SNikolay Aleksandrov 	u64 rx_packets;
896dada9b1SNikolay Aleksandrov 	u64 tx_bytes;
906dada9b1SNikolay Aleksandrov 	u64 tx_packets;
916dada9b1SNikolay Aleksandrov 	struct u64_stats_sync syncp;
926dada9b1SNikolay Aleksandrov };
936dada9b1SNikolay Aleksandrov 
94efa5356bSRoopa Prabhu struct br_tunnel_info {
95efa5356bSRoopa Prabhu 	__be64			tunnel_id;
96efa5356bSRoopa Prabhu 	struct metadata_dst	*tunnel_dst;
97efa5356bSRoopa Prabhu };
98efa5356bSRoopa Prabhu 
992594e906SNikolay Aleksandrov /**
1002594e906SNikolay Aleksandrov  * struct net_bridge_vlan - per-vlan entry
1012594e906SNikolay Aleksandrov  *
1022594e906SNikolay Aleksandrov  * @vnode: rhashtable member
1032594e906SNikolay Aleksandrov  * @vid: VLAN id
1042594e906SNikolay Aleksandrov  * @flags: bridge vlan flags
1056dada9b1SNikolay Aleksandrov  * @stats: per-cpu VLAN statistics
1062594e906SNikolay Aleksandrov  * @br: if MASTER flag set, this points to a bridge struct
1072594e906SNikolay Aleksandrov  * @port: if MASTER flag unset, this points to a port struct
1082594e906SNikolay Aleksandrov  * @refcnt: if MASTER flag set, this is bumped for each port referencing it
1092594e906SNikolay Aleksandrov  * @brvlan: if MASTER flag unset, this points to the global per-VLAN context
1102594e906SNikolay Aleksandrov  *          for this VLAN entry
1112594e906SNikolay Aleksandrov  * @vlist: sorted list of VLAN entries
1122594e906SNikolay Aleksandrov  * @rcu: used for entry destruction
1132594e906SNikolay Aleksandrov  *
1142594e906SNikolay Aleksandrov  * This structure is shared between the global per-VLAN entries contained in
1152594e906SNikolay Aleksandrov  * the bridge rhashtable and the local per-port per-VLAN entries contained in
1162594e906SNikolay Aleksandrov  * the port's rhashtable. The union entries should be interpreted depending on
1172594e906SNikolay Aleksandrov  * the entry flags that are set.
1182594e906SNikolay Aleksandrov  */
1192594e906SNikolay Aleksandrov struct net_bridge_vlan {
1202594e906SNikolay Aleksandrov 	struct rhash_head		vnode;
121efa5356bSRoopa Prabhu 	struct rhash_head		tnode;
1222594e906SNikolay Aleksandrov 	u16				vid;
1232594e906SNikolay Aleksandrov 	u16				flags;
1246dada9b1SNikolay Aleksandrov 	struct br_vlan_stats __percpu	*stats;
125243a2e63SVlad Yasevich 	union {
126243a2e63SVlad Yasevich 		struct net_bridge	*br;
1272594e906SNikolay Aleksandrov 		struct net_bridge_port	*port;
1282594e906SNikolay Aleksandrov 	};
1292594e906SNikolay Aleksandrov 	union {
1302594e906SNikolay Aleksandrov 		atomic_t		refcnt;
1312594e906SNikolay Aleksandrov 		struct net_bridge_vlan	*brvlan;
1322594e906SNikolay Aleksandrov 	};
133efa5356bSRoopa Prabhu 
134efa5356bSRoopa Prabhu 	struct br_tunnel_info		tinfo;
135efa5356bSRoopa Prabhu 
1362594e906SNikolay Aleksandrov 	struct list_head		vlist;
1372594e906SNikolay Aleksandrov 
138243a2e63SVlad Yasevich 	struct rcu_head			rcu;
1392594e906SNikolay Aleksandrov };
1402594e906SNikolay Aleksandrov 
1412594e906SNikolay Aleksandrov /**
1422594e906SNikolay Aleksandrov  * struct net_bridge_vlan_group
1432594e906SNikolay Aleksandrov  *
1442594e906SNikolay Aleksandrov  * @vlan_hash: VLAN entry rhashtable
1452594e906SNikolay Aleksandrov  * @vlan_list: sorted VLAN entry list
1462594e906SNikolay Aleksandrov  * @num_vlans: number of total VLAN entries
14777751ee8SNikolay Aleksandrov  * @pvid: PVID VLAN id
1482594e906SNikolay Aleksandrov  *
1492594e906SNikolay Aleksandrov  * IMPORTANT: Be careful when checking if there're VLAN entries using list
1502594e906SNikolay Aleksandrov  *            primitives because the bridge can have entries in its list which
1512594e906SNikolay Aleksandrov  *            are just for global context but not for filtering, i.e. they have
1522594e906SNikolay Aleksandrov  *            the master flag set but not the brentry flag. If you have to check
1532594e906SNikolay Aleksandrov  *            if there're "real" entries in the bridge please test @num_vlans
1542594e906SNikolay Aleksandrov  */
1552594e906SNikolay Aleksandrov struct net_bridge_vlan_group {
1562594e906SNikolay Aleksandrov 	struct rhashtable		vlan_hash;
157efa5356bSRoopa Prabhu 	struct rhashtable		tunnel_hash;
1582594e906SNikolay Aleksandrov 	struct list_head		vlan_list;
1596cbdceebSVlad Yasevich 	u16				num_vlans;
16077751ee8SNikolay Aleksandrov 	u16				pvid;
161243a2e63SVlad Yasevich };
162243a2e63SVlad Yasevich 
1631214628cSNikolay Aleksandrov struct net_bridge_fdb_entry {
1641da177e4SLinus Torvalds 	struct hlist_node		hlist;
1651da177e4SLinus Torvalds 	struct net_bridge_port		*dst;
1661da177e4SLinus Torvalds 
1671da177e4SLinus Torvalds 	mac_addr			addr;
168b22fbf22SNikolay Aleksandrov 	__u16				vlan_id;
16993859b13SJiri Pirko 	unsigned char			is_local:1,
17093859b13SJiri Pirko 					is_static:1,
171cf6b8e1eSScott Feldman 					added_by_user:1,
172cf6b8e1eSScott Feldman 					added_by_external_learn:1;
1731214628cSNikolay Aleksandrov 
1741214628cSNikolay Aleksandrov 	/* write-heavy members should not affect lookups */
1751214628cSNikolay Aleksandrov 	unsigned long			updated ____cacheline_aligned_in_smp;
1761214628cSNikolay Aleksandrov 	unsigned long			used;
1771214628cSNikolay Aleksandrov 
178b22fbf22SNikolay Aleksandrov 	struct rcu_head			rcu;
1791da177e4SLinus Torvalds };
1801da177e4SLinus Torvalds 
1819d06b6d8SElad Raz #define MDB_PG_FLAGS_PERMANENT	BIT(0)
1829d06b6d8SElad Raz #define MDB_PG_FLAGS_OFFLOAD	BIT(1)
1839d06b6d8SElad Raz 
184eb1d1641SHerbert Xu struct net_bridge_port_group {
185eb1d1641SHerbert Xu 	struct net_bridge_port		*port;
186e8051688SEric Dumazet 	struct net_bridge_port_group __rcu *next;
187eb1d1641SHerbert Xu 	struct hlist_node		mglist;
188eb1d1641SHerbert Xu 	struct rcu_head			rcu;
189eb1d1641SHerbert Xu 	struct timer_list		timer;
1908ef2a9a5SYOSHIFUJI Hideaki 	struct br_ip			addr;
1919d06b6d8SElad Raz 	unsigned char			flags;
1926db6f0eaSFelix Fietkau 	unsigned char			eth_addr[ETH_ALEN];
193eb1d1641SHerbert Xu };
194eb1d1641SHerbert Xu 
195eb1d1641SHerbert Xu struct net_bridge_mdb_entry
196eb1d1641SHerbert Xu {
197eb1d1641SHerbert Xu 	struct hlist_node		hlist[2];
198eb1d1641SHerbert Xu 	struct net_bridge		*br;
199e8051688SEric Dumazet 	struct net_bridge_port_group __rcu *ports;
200eb1d1641SHerbert Xu 	struct rcu_head			rcu;
201eb1d1641SHerbert Xu 	struct timer_list		timer;
2028ef2a9a5SYOSHIFUJI Hideaki 	struct br_ip			addr;
2038a870178SHerbert Xu 	bool				mglist;
204eb1d1641SHerbert Xu };
205eb1d1641SHerbert Xu 
206eb1d1641SHerbert Xu struct net_bridge_mdb_htable
207eb1d1641SHerbert Xu {
208eb1d1641SHerbert Xu 	struct hlist_head		*mhash;
209eb1d1641SHerbert Xu 	struct rcu_head			rcu;
210eb1d1641SHerbert Xu 	struct net_bridge_mdb_htable	*old;
211eb1d1641SHerbert Xu 	u32				size;
212eb1d1641SHerbert Xu 	u32				max;
213eb1d1641SHerbert Xu 	u32				secret;
214eb1d1641SHerbert Xu 	u32				ver;
215eb1d1641SHerbert Xu };
216eb1d1641SHerbert Xu 
2171f90c7f3SNikolay Aleksandrov struct net_bridge_port {
2181da177e4SLinus Torvalds 	struct net_bridge		*br;
2191da177e4SLinus Torvalds 	struct net_device		*dev;
2201da177e4SLinus Torvalds 	struct list_head		list;
2211da177e4SLinus Torvalds 
2221f90c7f3SNikolay Aleksandrov 	unsigned long			flags;
2231f90c7f3SNikolay Aleksandrov #ifdef CONFIG_BRIDGE_VLAN_FILTERING
2241f90c7f3SNikolay Aleksandrov 	struct net_bridge_vlan_group	__rcu *vlgrp;
2251f90c7f3SNikolay Aleksandrov #endif
2261f90c7f3SNikolay Aleksandrov 
2271da177e4SLinus Torvalds 	/* STP */
2281da177e4SLinus Torvalds 	u8				priority;
2291da177e4SLinus Torvalds 	u8				state;
2301da177e4SLinus Torvalds 	u16				port_no;
2311da177e4SLinus Torvalds 	unsigned char			topology_change_ack;
2321da177e4SLinus Torvalds 	unsigned char			config_pending;
2331da177e4SLinus Torvalds 	port_id				port_id;
2341da177e4SLinus Torvalds 	port_id				designated_port;
2351da177e4SLinus Torvalds 	bridge_id			designated_root;
2361da177e4SLinus Torvalds 	bridge_id			designated_bridge;
2371da177e4SLinus Torvalds 	u32				path_cost;
2381da177e4SLinus Torvalds 	u32				designated_cost;
2390c03150eSstephen hemminger 	unsigned long			designated_age;
2401da177e4SLinus Torvalds 
2411da177e4SLinus Torvalds 	struct timer_list		forward_delay_timer;
2421da177e4SLinus Torvalds 	struct timer_list		hold_timer;
2431da177e4SLinus Torvalds 	struct timer_list		message_age_timer;
2441da177e4SLinus Torvalds 	struct kobject			kobj;
2451da177e4SLinus Torvalds 	struct rcu_head			rcu;
2463982d3d2SFischer, Anna 
247eb1d1641SHerbert Xu #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
24890010b36SLinus Lüssing 	struct bridge_mcast_own_query	ip4_own_query;
249cc0fdd80SLinus Lüssing #if IS_ENABLED(CONFIG_IPV6)
25090010b36SLinus Lüssing 	struct bridge_mcast_own_query	ip6_own_query;
251cc0fdd80SLinus Lüssing #endif /* IS_ENABLED(CONFIG_IPV6) */
252eb1d1641SHerbert Xu 	unsigned char			multicast_router;
2531080ab95SNikolay Aleksandrov 	struct bridge_mcast_stats	__percpu *mcast_stats;
254eb1d1641SHerbert Xu 	struct timer_list		multicast_router_timer;
255eb1d1641SHerbert Xu 	struct hlist_head		mglist;
256eb1d1641SHerbert Xu 	struct hlist_node		rlist;
257eb1d1641SHerbert Xu #endif
258e0f43752SSimon Arlott 
259e0f43752SSimon Arlott #ifdef CONFIG_SYSFS
260e0f43752SSimon Arlott 	char				sysfs_name[IFNAMSIZ];
261e0f43752SSimon Arlott #endif
26291d2c34aSHerbert Xu 
26391d2c34aSHerbert Xu #ifdef CONFIG_NET_POLL_CONTROLLER
26491d2c34aSHerbert Xu 	struct netpoll			*np;
26591d2c34aSHerbert Xu #endif
2666bc506b4SIdo Schimmel #ifdef CONFIG_NET_SWITCHDEV
2676bc506b4SIdo Schimmel 	int				offload_fwd_mark;
2686bc506b4SIdo Schimmel #endif
2691da177e4SLinus Torvalds };
2701da177e4SLinus Torvalds 
271e028e4b8SVlad Yasevich #define br_auto_port(p) ((p)->flags & BR_AUTO_MASK)
272f3a6ddf1SVlad Yasevich #define br_promisc_port(p) ((p)->flags & BR_PROMISC)
273e028e4b8SVlad Yasevich 
274f350a0a8SJiri Pirko #define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
275f350a0a8SJiri Pirko 
276b5ed54e9Sstephen hemminger static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev)
277b5ed54e9Sstephen hemminger {
278716ec052SHong Zhiguo 	return rcu_dereference(dev->rx_handler_data);
279b5ed54e9Sstephen hemminger }
280b5ed54e9Sstephen hemminger 
2811fb1754aSHong Zhiguo static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)
282b5ed54e9Sstephen hemminger {
283ec1e5610SEric Dumazet 	return br_port_exists(dev) ?
284ec1e5610SEric Dumazet 		rtnl_dereference(dev->rx_handler_data) : NULL;
285b5ed54e9Sstephen hemminger }
286b5ed54e9Sstephen hemminger 
2871f90c7f3SNikolay Aleksandrov struct net_bridge {
2881da177e4SLinus Torvalds 	spinlock_t			lock;
2891f90c7f3SNikolay Aleksandrov 	spinlock_t			hash_lock;
2901da177e4SLinus Torvalds 	struct list_head		port_list;
2911da177e4SLinus Torvalds 	struct net_device		*dev;
2928f84985fSLi RongQing 	struct pcpu_sw_netstats		__percpu *stats;
2931f90c7f3SNikolay Aleksandrov 	/* These fields are accessed on each packet */
2941f90c7f3SNikolay Aleksandrov #ifdef CONFIG_BRIDGE_VLAN_FILTERING
2951f90c7f3SNikolay Aleksandrov 	u8				vlan_enabled;
2961f90c7f3SNikolay Aleksandrov 	u8				vlan_stats_enabled;
2971f90c7f3SNikolay Aleksandrov 	__be16				vlan_proto;
2981f90c7f3SNikolay Aleksandrov 	u16				default_pvid;
2991f90c7f3SNikolay Aleksandrov 	struct net_bridge_vlan_group	__rcu *vlgrp;
3001f90c7f3SNikolay Aleksandrov #endif
3011f90c7f3SNikolay Aleksandrov 
3021da177e4SLinus Torvalds 	struct hlist_head		hash[BR_HASH_SIZE];
30334666d46SPablo Neira Ayuso #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
304efb6de9bSBernhard Thaler 	union {
3054adf0af6SSimon Wunderlich 		struct rtable		fake_rtable;
306efb6de9bSBernhard Thaler 		struct rt6_info		fake_rt6_info;
307efb6de9bSBernhard Thaler 	};
3084df53d8bSPatrick McHardy 	bool				nf_call_iptables;
3094df53d8bSPatrick McHardy 	bool				nf_call_ip6tables;
3104df53d8bSPatrick McHardy 	bool				nf_call_arptables;
3114adf0af6SSimon Wunderlich #endif
312515853ccSstephen hemminger 	u16				group_fwd_mask;
313f2808d22SToshiaki Makita 	u16				group_fwd_mask_required;
314515853ccSstephen hemminger 
3151da177e4SLinus Torvalds 	/* STP */
3161da177e4SLinus Torvalds 	bridge_id			designated_root;
3171da177e4SLinus Torvalds 	bridge_id			bridge_id;
3181da177e4SLinus Torvalds 	u32				root_path_cost;
3191f90c7f3SNikolay Aleksandrov 	unsigned char			topology_change;
3201f90c7f3SNikolay Aleksandrov 	unsigned char			topology_change_detected;
3211f90c7f3SNikolay Aleksandrov 	u16				root_port;
3221da177e4SLinus Torvalds 	unsigned long			max_age;
3231da177e4SLinus Torvalds 	unsigned long			hello_time;
3241da177e4SLinus Torvalds 	unsigned long			forward_delay;
3251da177e4SLinus Torvalds 	unsigned long			ageing_time;
32634d8acd8SVivien Didelot 	unsigned long			bridge_max_age;
3271da177e4SLinus Torvalds 	unsigned long			bridge_hello_time;
3281da177e4SLinus Torvalds 	unsigned long			bridge_forward_delay;
32934d8acd8SVivien Didelot 	unsigned long			bridge_ageing_time;
3301da177e4SLinus Torvalds 
331fda93d92SStephen Hemminger 	u8				group_addr[ETH_ALEN];
332204177f3SToshiaki Makita 	bool				group_addr_set;
3339cde0708SStephen Hemminger 
3349cde0708SStephen Hemminger 	enum {
3359cde0708SStephen Hemminger 		BR_NO_STP, 		/* no spanning tree */
3369cde0708SStephen Hemminger 		BR_KERNEL_STP,		/* old STP in kernel */
3379cde0708SStephen Hemminger 		BR_USER_STP,		/* new RSTP in userspace */
3389cde0708SStephen Hemminger 	} stp_enabled;
3399cde0708SStephen Hemminger 
340eb1d1641SHerbert Xu #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
341eb1d1641SHerbert Xu 	unsigned char			multicast_router;
342eb1d1641SHerbert Xu 
343eb1d1641SHerbert Xu 	u8				multicast_disabled:1;
344c5c23260SHerbert Xu 	u8				multicast_querier:1;
3451c8ad5bfSCong Wang 	u8				multicast_query_use_ifaddr:1;
3460888d5f3Sdaniel 	u8				has_ipv6_addr:1;
3471080ab95SNikolay Aleksandrov 	u8				multicast_stats_enabled:1;
348eb1d1641SHerbert Xu 
349eb1d1641SHerbert Xu 	u32				hash_elasticity;
350eb1d1641SHerbert Xu 	u32				hash_max;
351eb1d1641SHerbert Xu 
352eb1d1641SHerbert Xu 	u32				multicast_last_member_count;
353eb1d1641SHerbert Xu 	u32				multicast_startup_query_count;
354eb1d1641SHerbert Xu 
3555e923585SNikolay Aleksandrov 	u8				multicast_igmp_version;
3565e923585SNikolay Aleksandrov 
357eb1d1641SHerbert Xu 	unsigned long			multicast_last_member_interval;
358eb1d1641SHerbert Xu 	unsigned long			multicast_membership_interval;
359eb1d1641SHerbert Xu 	unsigned long			multicast_querier_interval;
360eb1d1641SHerbert Xu 	unsigned long			multicast_query_interval;
361eb1d1641SHerbert Xu 	unsigned long			multicast_query_response_interval;
362eb1d1641SHerbert Xu 	unsigned long			multicast_startup_query_interval;
363eb1d1641SHerbert Xu 
364eb1d1641SHerbert Xu 	spinlock_t			multicast_lock;
365e8051688SEric Dumazet 	struct net_bridge_mdb_htable __rcu *mdb;
366eb1d1641SHerbert Xu 	struct hlist_head		router_list;
367eb1d1641SHerbert Xu 
368eb1d1641SHerbert Xu 	struct timer_list		multicast_router_timer;
36990010b36SLinus Lüssing 	struct bridge_mcast_other_query	ip4_other_query;
37090010b36SLinus Lüssing 	struct bridge_mcast_own_query	ip4_own_query;
371dc4eb53aSLinus Lüssing 	struct bridge_mcast_querier	ip4_querier;
3721080ab95SNikolay Aleksandrov 	struct bridge_mcast_stats	__percpu *mcast_stats;
373cc0fdd80SLinus Lüssing #if IS_ENABLED(CONFIG_IPV6)
37490010b36SLinus Lüssing 	struct bridge_mcast_other_query	ip6_other_query;
37590010b36SLinus Lüssing 	struct bridge_mcast_own_query	ip6_own_query;
376dc4eb53aSLinus Lüssing 	struct bridge_mcast_querier	ip6_querier;
377aa2ae3e7SNikolay Aleksandrov 	u8				multicast_mld_version;
378cc0fdd80SLinus Lüssing #endif /* IS_ENABLED(CONFIG_IPV6) */
379eb1d1641SHerbert Xu #endif
380eb1d1641SHerbert Xu 
3811da177e4SLinus Torvalds 	struct timer_list		hello_timer;
3821da177e4SLinus Torvalds 	struct timer_list		tcn_timer;
3831da177e4SLinus Torvalds 	struct timer_list		topology_change_timer;
384f7cdee8aSNikolay Aleksandrov 	struct delayed_work		gc_work;
38543b98c4aSGreg Kroah-Hartman 	struct kobject			*ifobj;
386e028e4b8SVlad Yasevich 	u32				auto_cnt;
3876bc506b4SIdo Schimmel 
3886bc506b4SIdo Schimmel #ifdef CONFIG_NET_SWITCHDEV
3896bc506b4SIdo Schimmel 	int offload_fwd_mark;
3906bc506b4SIdo Schimmel #endif
3911da177e4SLinus Torvalds };
3921da177e4SLinus Torvalds 
39368b7c895SHerbert Xu struct br_input_skb_cb {
39468b7c895SHerbert Xu 	struct net_device *brdev;
39593fdd47eSHerbert Xu 
39632dec5ddSYOSHIFUJI Hideaki / 吉藤英明 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
397eb1d1641SHerbert Xu 	int igmp;
398eb1d1641SHerbert Xu 	int mrouters_only;
39932dec5ddSYOSHIFUJI Hideaki / 吉藤英明 #endif
40093fdd47eSHerbert Xu 
401842a9ae0SJouni Malinen 	bool proxyarp_replied;
40293fdd47eSHerbert Xu 
40320adfa1aSVlad Yasevich #ifdef CONFIG_BRIDGE_VLAN_FILTERING
40420adfa1aSVlad Yasevich 	bool vlan_filtered;
40520adfa1aSVlad Yasevich #endif
4066bc506b4SIdo Schimmel 
4076bc506b4SIdo Schimmel #ifdef CONFIG_NET_SWITCHDEV
4086bc506b4SIdo Schimmel 	int offload_fwd_mark;
4096bc506b4SIdo Schimmel #endif
41068b7c895SHerbert Xu };
41168b7c895SHerbert Xu 
41268b7c895SHerbert Xu #define BR_INPUT_SKB_CB(__skb)	((struct br_input_skb_cb *)(__skb)->cb)
41368b7c895SHerbert Xu 
41432dec5ddSYOSHIFUJI Hideaki / 吉藤英明 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
41532dec5ddSYOSHIFUJI Hideaki / 吉藤英明 # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb)	(BR_INPUT_SKB_CB(__skb)->mrouters_only)
41632dec5ddSYOSHIFUJI Hideaki / 吉藤英明 #else
41732dec5ddSYOSHIFUJI Hideaki / 吉藤英明 # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb)	(0)
41832dec5ddSYOSHIFUJI Hideaki / 吉藤英明 #endif
41932dec5ddSYOSHIFUJI Hideaki / 吉藤英明 
42028a16c97Sstephen hemminger #define br_printk(level, br, format, args...)	\
42128a16c97Sstephen hemminger 	printk(level "%s: " format, (br)->dev->name, ##args)
42228a16c97Sstephen hemminger 
42328a16c97Sstephen hemminger #define br_err(__br, format, args...)			\
42428a16c97Sstephen hemminger 	br_printk(KERN_ERR, __br, format, ##args)
42528a16c97Sstephen hemminger #define br_warn(__br, format, args...)			\
42628a16c97Sstephen hemminger 	br_printk(KERN_WARNING, __br, format, ##args)
42728a16c97Sstephen hemminger #define br_notice(__br, format, args...)		\
42828a16c97Sstephen hemminger 	br_printk(KERN_NOTICE, __br, format, ##args)
42928a16c97Sstephen hemminger #define br_info(__br, format, args...)			\
43028a16c97Sstephen hemminger 	br_printk(KERN_INFO, __br, format, ##args)
43128a16c97Sstephen hemminger 
43228a16c97Sstephen hemminger #define br_debug(br, format, args...)			\
43328a16c97Sstephen hemminger 	pr_debug("%s: " format,  (br)->dev->name, ##args)
43428a16c97Sstephen hemminger 
4351da177e4SLinus Torvalds /* called under bridge lock */
4361da177e4SLinus Torvalds static inline int br_is_root_bridge(const struct net_bridge *br)
4371da177e4SLinus Torvalds {
4381da177e4SLinus Torvalds 	return !memcmp(&br->bridge_id, &br->designated_root, 8);
4391da177e4SLinus Torvalds }
4401da177e4SLinus Torvalds 
4412594e906SNikolay Aleksandrov /* check if a VLAN entry is global */
4422594e906SNikolay Aleksandrov static inline bool br_vlan_is_master(const struct net_bridge_vlan *v)
4432594e906SNikolay Aleksandrov {
4442594e906SNikolay Aleksandrov 	return v->flags & BRIDGE_VLAN_INFO_MASTER;
4452594e906SNikolay Aleksandrov }
4462594e906SNikolay Aleksandrov 
4472594e906SNikolay Aleksandrov /* check if a VLAN entry is used by the bridge */
4482594e906SNikolay Aleksandrov static inline bool br_vlan_is_brentry(const struct net_bridge_vlan *v)
4492594e906SNikolay Aleksandrov {
4502594e906SNikolay Aleksandrov 	return v->flags & BRIDGE_VLAN_INFO_BRENTRY;
4512594e906SNikolay Aleksandrov }
4522594e906SNikolay Aleksandrov 
4536be144f6SNikolay Aleksandrov /* check if we should use the vlan entry, returns false if it's only context */
4542594e906SNikolay Aleksandrov static inline bool br_vlan_should_use(const struct net_bridge_vlan *v)
4552594e906SNikolay Aleksandrov {
4562594e906SNikolay Aleksandrov 	if (br_vlan_is_master(v)) {
4572594e906SNikolay Aleksandrov 		if (br_vlan_is_brentry(v))
4582594e906SNikolay Aleksandrov 			return true;
4592594e906SNikolay Aleksandrov 		else
4602594e906SNikolay Aleksandrov 			return false;
4612594e906SNikolay Aleksandrov 	}
4622594e906SNikolay Aleksandrov 
4632594e906SNikolay Aleksandrov 	return true;
4642594e906SNikolay Aleksandrov }
4652594e906SNikolay Aleksandrov 
4661da177e4SLinus Torvalds /* br_device.c */
467348662a1SJoe Perches void br_dev_setup(struct net_device *dev);
468348662a1SJoe Perches void br_dev_delete(struct net_device *dev, struct list_head *list);
469348662a1SJoe Perches netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev);
470cfb478daSstephen hemminger #ifdef CONFIG_NET_POLL_CONTROLLER
47191d2c34aSHerbert Xu static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
47291d2c34aSHerbert Xu 				       struct sk_buff *skb)
47391d2c34aSHerbert Xu {
47491d2c34aSHerbert Xu 	struct netpoll *np = p->np;
47591d2c34aSHerbert Xu 
47691d2c34aSHerbert Xu 	if (np)
47791d2c34aSHerbert Xu 		netpoll_send_skb(np, skb);
47891d2c34aSHerbert Xu }
47991d2c34aSHerbert Xu 
480a8779ec1SEric W. Biederman int br_netpoll_enable(struct net_bridge_port *p);
481348662a1SJoe Perches void br_netpoll_disable(struct net_bridge_port *p);
48291d2c34aSHerbert Xu #else
4839f70b0fcSHerbert Xu static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
48491d2c34aSHerbert Xu 				       struct sk_buff *skb)
48591d2c34aSHerbert Xu {
48691d2c34aSHerbert Xu }
48791d2c34aSHerbert Xu 
488a8779ec1SEric W. Biederman static inline int br_netpoll_enable(struct net_bridge_port *p)
48991d2c34aSHerbert Xu {
49091d2c34aSHerbert Xu 	return 0;
49191d2c34aSHerbert Xu }
49291d2c34aSHerbert Xu 
49391d2c34aSHerbert Xu static inline void br_netpoll_disable(struct net_bridge_port *p)
49491d2c34aSHerbert Xu {
49591d2c34aSHerbert Xu }
496cfb478daSstephen hemminger #endif
4971da177e4SLinus Torvalds 
4981da177e4SLinus Torvalds /* br_fdb.c */
499348662a1SJoe Perches int br_fdb_init(void);
500348662a1SJoe Perches void br_fdb_fini(void);
501348662a1SJoe Perches void br_fdb_flush(struct net_bridge *br);
502424bb9c9SToshiaki Makita void br_fdb_find_delete_local(struct net_bridge *br,
503424bb9c9SToshiaki Makita 			      const struct net_bridge_port *p,
504424bb9c9SToshiaki Makita 			      const unsigned char *addr, u16 vid);
505348662a1SJoe Perches void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr);
506348662a1SJoe Perches void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);
507f7cdee8aSNikolay Aleksandrov void br_fdb_cleanup(struct work_struct *work);
508348662a1SJoe Perches void br_fdb_delete_by_port(struct net_bridge *br,
5091ea2d020SNikolay Aleksandrov 			   const struct net_bridge_port *p, u16 vid, int do_all);
510bfd0aeacSNikolay Aleksandrov struct net_bridge_fdb_entry *br_fdb_find_rcu(struct net_bridge *br,
511bfd0aeacSNikolay Aleksandrov 					     const unsigned char *addr,
512bfd0aeacSNikolay Aleksandrov 					     __u16 vid);
513348662a1SJoe Perches int br_fdb_test_addr(struct net_device *dev, unsigned char *addr);
514348662a1SJoe Perches int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count,
515348662a1SJoe Perches 		   unsigned long off);
516348662a1SJoe Perches int br_fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
517348662a1SJoe Perches 		  const unsigned char *addr, u16 vid);
518348662a1SJoe Perches void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
519a5642ab4SToshiaki Makita 		   const unsigned char *addr, u16 vid, bool added_by_user);
52077162022SJohn Fastabend 
521348662a1SJoe Perches int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
522f6f6424bSJiri Pirko 		  struct net_device *dev, const unsigned char *addr, u16 vid);
523348662a1SJoe Perches int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev,
524f6f6424bSJiri Pirko 	       const unsigned char *addr, u16 vid, u16 nlh_flags);
525348662a1SJoe Perches int br_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
526d297653dSRoopa Prabhu 		struct net_device *dev, struct net_device *fdev, int *idx);
5278db24af7SVlad Yasevich int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p);
5288db24af7SVlad Yasevich void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p);
5293aeb6617SJiri Pirko int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
5303aeb6617SJiri Pirko 			      const unsigned char *addr, u16 vid);
5313aeb6617SJiri Pirko int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
5323aeb6617SJiri Pirko 			      const unsigned char *addr, u16 vid);
5331da177e4SLinus Torvalds 
5341da177e4SLinus Torvalds /* br_forward.c */
5358addd5e7SNikolay Aleksandrov enum br_pkt_type {
5368addd5e7SNikolay Aleksandrov 	BR_PKT_UNICAST,
5378addd5e7SNikolay Aleksandrov 	BR_PKT_MULTICAST,
5388addd5e7SNikolay Aleksandrov 	BR_PKT_BROADCAST
5398addd5e7SNikolay Aleksandrov };
5400c4b51f0SEric W. Biederman int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);
541b35c5f63SNikolay Aleksandrov void br_forward(const struct net_bridge_port *to, struct sk_buff *skb,
54237b090e6SNikolay Aleksandrov 		bool local_rcv, bool local_orig);
5430c4b51f0SEric W. Biederman int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
54437b090e6SNikolay Aleksandrov void br_flood(struct net_bridge *br, struct sk_buff *skb,
5458addd5e7SNikolay Aleksandrov 	      enum br_pkt_type pkt_type, bool local_rcv, bool local_orig);
5461da177e4SLinus Torvalds 
5471da177e4SLinus Torvalds /* br_if.c */
548348662a1SJoe Perches void br_port_carrier_check(struct net_bridge_port *p);
549348662a1SJoe Perches int br_add_bridge(struct net *net, const char *name);
550348662a1SJoe Perches int br_del_bridge(struct net *net, const char *name);
551348662a1SJoe Perches int br_add_if(struct net_bridge *br, struct net_device *dev);
552348662a1SJoe Perches int br_del_if(struct net_bridge *br, struct net_device *dev);
553348662a1SJoe Perches int br_min_mtu(const struct net_bridge *br);
554348662a1SJoe Perches netdev_features_t br_features_recompute(struct net_bridge *br,
555c8f44affSMichał Mirosław 					netdev_features_t features);
556e028e4b8SVlad Yasevich void br_port_flags_change(struct net_bridge_port *port, unsigned long mask);
5572796d0c6SVlad Yasevich void br_manage_promisc(struct net_bridge *br);
5581da177e4SLinus Torvalds 
5591da177e4SLinus Torvalds /* br_input.c */
5600c4b51f0SEric W. Biederman int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
561348662a1SJoe Perches rx_handler_result_t br_handle_frame(struct sk_buff **pskb);
5621da177e4SLinus Torvalds 
563859828c0SJiri Pirko static inline bool br_rx_handler_check_rcu(const struct net_device *dev)
564859828c0SJiri Pirko {
565859828c0SJiri Pirko 	return rcu_dereference(dev->rx_handler) == br_handle_frame;
566859828c0SJiri Pirko }
567859828c0SJiri Pirko 
568859828c0SJiri Pirko static inline struct net_bridge_port *br_port_get_check_rcu(const struct net_device *dev)
569859828c0SJiri Pirko {
570859828c0SJiri Pirko 	return br_rx_handler_check_rcu(dev) ? br_port_get_rcu(dev) : NULL;
571859828c0SJiri Pirko }
572859828c0SJiri Pirko 
5731da177e4SLinus Torvalds /* br_ioctl.c */
574348662a1SJoe Perches int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
575348662a1SJoe Perches int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd,
576348662a1SJoe Perches 			     void __user *arg);
5771da177e4SLinus Torvalds 
578eb1d1641SHerbert Xu /* br_multicast.c */
579eb1d1641SHerbert Xu #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
5802ce297fcSCong Wang extern unsigned int br_mdb_rehash_seq;
581348662a1SJoe Perches int br_multicast_rcv(struct net_bridge *br, struct net_bridge_port *port,
582fbca58a2SCong Wang 		     struct sk_buff *skb, u16 vid);
583348662a1SJoe Perches struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
584eb1d1641SHerbert Xu 					struct sk_buff *skb, u16 vid);
5851080ab95SNikolay Aleksandrov int br_multicast_add_port(struct net_bridge_port *port);
586348662a1SJoe Perches void br_multicast_del_port(struct net_bridge_port *port);
587348662a1SJoe Perches void br_multicast_enable_port(struct net_bridge_port *port);
588348662a1SJoe Perches void br_multicast_disable_port(struct net_bridge_port *port);
589348662a1SJoe Perches void br_multicast_init(struct net_bridge *br);
590348662a1SJoe Perches void br_multicast_open(struct net_bridge *br);
591348662a1SJoe Perches void br_multicast_stop(struct net_bridge *br);
592e10177abSSatish Ashok void br_multicast_dev_del(struct net_bridge *br);
59337b090e6SNikolay Aleksandrov void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
59437b090e6SNikolay Aleksandrov 			struct sk_buff *skb, bool local_rcv, bool local_orig);
595348662a1SJoe Perches int br_multicast_set_router(struct net_bridge *br, unsigned long val);
596348662a1SJoe Perches int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val);
597348662a1SJoe Perches int br_multicast_toggle(struct net_bridge *br, unsigned long val);
598348662a1SJoe Perches int br_multicast_set_querier(struct net_bridge *br, unsigned long val);
599348662a1SJoe Perches int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val);
6005e923585SNikolay Aleksandrov int br_multicast_set_igmp_version(struct net_bridge *br, unsigned long val);
601aa2ae3e7SNikolay Aleksandrov #if IS_ENABLED(CONFIG_IPV6)
602aa2ae3e7SNikolay Aleksandrov int br_multicast_set_mld_version(struct net_bridge *br, unsigned long val);
603aa2ae3e7SNikolay Aleksandrov #endif
604348662a1SJoe Perches struct net_bridge_mdb_entry *
605348662a1SJoe Perches br_mdb_ip_get(struct net_bridge_mdb_htable *mdb, struct br_ip *dst);
606348662a1SJoe Perches struct net_bridge_mdb_entry *
607348662a1SJoe Perches br_multicast_new_group(struct net_bridge *br, struct net_bridge_port *port,
608348662a1SJoe Perches 		       struct br_ip *group);
609348662a1SJoe Perches void br_multicast_free_pg(struct rcu_head *head);
610348662a1SJoe Perches struct net_bridge_port_group *
611348662a1SJoe Perches br_multicast_new_port_group(struct net_bridge_port *port, struct br_ip *group,
612762a3d89Sstephen hemminger 			    struct net_bridge_port_group __rcu *next,
6136db6f0eaSFelix Fietkau 			    unsigned char flags, const unsigned char *src);
614348662a1SJoe Perches void br_mdb_init(void);
615348662a1SJoe Perches void br_mdb_uninit(void);
61645ebcce5SElad Raz void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port,
61745ebcce5SElad Raz 		   struct br_ip *group, int type, u8 flags);
618949f1e39SSatish Ashok void br_rtr_notify(struct net_device *dev, struct net_bridge_port *port,
619949f1e39SSatish Ashok 		   int type);
6201080ab95SNikolay Aleksandrov void br_multicast_count(struct net_bridge *br, const struct net_bridge_port *p,
621a65056ecSNikolay Aleksandrov 			const struct sk_buff *skb, u8 type, u8 dir);
6221080ab95SNikolay Aleksandrov int br_multicast_init_stats(struct net_bridge *br);
623b6fe0440SIdo Schimmel void br_multicast_uninit_stats(struct net_bridge *br);
6241080ab95SNikolay Aleksandrov void br_multicast_get_stats(const struct net_bridge *br,
6251080ab95SNikolay Aleksandrov 			    const struct net_bridge_port *p,
6261080ab95SNikolay Aleksandrov 			    struct br_mcast_stats *dest);
62785b35269SSridhar Samudrala 
628cfd56754SCong Wang #define mlock_dereference(X, br) \
629cfd56754SCong Wang 	rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock))
630cfd56754SCong Wang 
63185b35269SSridhar Samudrala static inline bool br_multicast_is_router(struct net_bridge *br)
63285b35269SSridhar Samudrala {
63385b35269SSridhar Samudrala 	return br->multicast_router == 2 ||
63485b35269SSridhar Samudrala 	       (br->multicast_router == 1 &&
63585b35269SSridhar Samudrala 		timer_pending(&br->multicast_router_timer));
63685b35269SSridhar Samudrala }
637b00589afSLinus Lüssing 
638cc0fdd80SLinus Lüssing static inline bool
639cc0fdd80SLinus Lüssing __br_multicast_querier_exists(struct net_bridge *br,
6400888d5f3Sdaniel 				struct bridge_mcast_other_query *querier,
6410888d5f3Sdaniel 				const bool is_ipv6)
642b00589afSLinus Lüssing {
6430888d5f3Sdaniel 	bool own_querier_enabled;
6440888d5f3Sdaniel 
6450888d5f3Sdaniel 	if (br->multicast_querier) {
6460888d5f3Sdaniel 		if (is_ipv6 && !br->has_ipv6_addr)
6470888d5f3Sdaniel 			own_querier_enabled = false;
6480888d5f3Sdaniel 		else
6490888d5f3Sdaniel 			own_querier_enabled = true;
6500888d5f3Sdaniel 	} else {
6510888d5f3Sdaniel 		own_querier_enabled = false;
6520888d5f3Sdaniel 	}
6530888d5f3Sdaniel 
654cc0fdd80SLinus Lüssing 	return time_is_before_jiffies(querier->delay_time) &&
6550888d5f3Sdaniel 	       (own_querier_enabled || timer_pending(&querier->timer));
656cc0fdd80SLinus Lüssing }
657cc0fdd80SLinus Lüssing 
658cc0fdd80SLinus Lüssing static inline bool br_multicast_querier_exists(struct net_bridge *br,
659cc0fdd80SLinus Lüssing 					       struct ethhdr *eth)
660cc0fdd80SLinus Lüssing {
661cc0fdd80SLinus Lüssing 	switch (eth->h_proto) {
662cc0fdd80SLinus Lüssing 	case (htons(ETH_P_IP)):
6630888d5f3Sdaniel 		return __br_multicast_querier_exists(br,
6640888d5f3Sdaniel 			&br->ip4_other_query, false);
665cc0fdd80SLinus Lüssing #if IS_ENABLED(CONFIG_IPV6)
666cc0fdd80SLinus Lüssing 	case (htons(ETH_P_IPV6)):
6670888d5f3Sdaniel 		return __br_multicast_querier_exists(br,
6680888d5f3Sdaniel 			&br->ip6_other_query, true);
669cc0fdd80SLinus Lüssing #endif
670cc0fdd80SLinus Lüssing 	default:
671cc0fdd80SLinus Lüssing 		return false;
672cc0fdd80SLinus Lüssing 	}
673b00589afSLinus Lüssing }
6741080ab95SNikolay Aleksandrov 
6751080ab95SNikolay Aleksandrov static inline int br_multicast_igmp_type(const struct sk_buff *skb)
6761080ab95SNikolay Aleksandrov {
6771080ab95SNikolay Aleksandrov 	return BR_INPUT_SKB_CB(skb)->igmp;
6781080ab95SNikolay Aleksandrov }
679eb1d1641SHerbert Xu #else
680eb1d1641SHerbert Xu static inline int br_multicast_rcv(struct net_bridge *br,
681eb1d1641SHerbert Xu 				   struct net_bridge_port *port,
68206499098SVlad Yasevich 				   struct sk_buff *skb,
68306499098SVlad Yasevich 				   u16 vid)
684eb1d1641SHerbert Xu {
685eb1d1641SHerbert Xu 	return 0;
686eb1d1641SHerbert Xu }
687eb1d1641SHerbert Xu 
688eb1d1641SHerbert Xu static inline struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
689fbca58a2SCong Wang 						      struct sk_buff *skb, u16 vid)
690eb1d1641SHerbert Xu {
691eb1d1641SHerbert Xu 	return NULL;
692eb1d1641SHerbert Xu }
693eb1d1641SHerbert Xu 
6941080ab95SNikolay Aleksandrov static inline int br_multicast_add_port(struct net_bridge_port *port)
695eb1d1641SHerbert Xu {
6961080ab95SNikolay Aleksandrov 	return 0;
697eb1d1641SHerbert Xu }
698eb1d1641SHerbert Xu 
699eb1d1641SHerbert Xu static inline void br_multicast_del_port(struct net_bridge_port *port)
700eb1d1641SHerbert Xu {
701eb1d1641SHerbert Xu }
702eb1d1641SHerbert Xu 
703eb1d1641SHerbert Xu static inline void br_multicast_enable_port(struct net_bridge_port *port)
704eb1d1641SHerbert Xu {
705eb1d1641SHerbert Xu }
706eb1d1641SHerbert Xu 
707eb1d1641SHerbert Xu static inline void br_multicast_disable_port(struct net_bridge_port *port)
708eb1d1641SHerbert Xu {
709eb1d1641SHerbert Xu }
710eb1d1641SHerbert Xu 
711eb1d1641SHerbert Xu static inline void br_multicast_init(struct net_bridge *br)
712eb1d1641SHerbert Xu {
713eb1d1641SHerbert Xu }
714eb1d1641SHerbert Xu 
715eb1d1641SHerbert Xu static inline void br_multicast_open(struct net_bridge *br)
716eb1d1641SHerbert Xu {
717eb1d1641SHerbert Xu }
718eb1d1641SHerbert Xu 
719eb1d1641SHerbert Xu static inline void br_multicast_stop(struct net_bridge *br)
720eb1d1641SHerbert Xu {
721eb1d1641SHerbert Xu }
7225cb5e947SHerbert Xu 
723a7ce45a7SNikolay Aleksandrov static inline void br_multicast_dev_del(struct net_bridge *br)
724a7ce45a7SNikolay Aleksandrov {
725a7ce45a7SNikolay Aleksandrov }
726a7ce45a7SNikolay Aleksandrov 
72737b090e6SNikolay Aleksandrov static inline void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
72837b090e6SNikolay Aleksandrov 				      struct sk_buff *skb,
72937b090e6SNikolay Aleksandrov 				      bool local_rcv, bool local_orig)
7305cb5e947SHerbert Xu {
7315cb5e947SHerbert Xu }
7325cb5e947SHerbert Xu 
733eb1d1641SHerbert Xu static inline bool br_multicast_is_router(struct net_bridge *br)
734eb1d1641SHerbert Xu {
73585b35269SSridhar Samudrala 	return 0;
736eb1d1641SHerbert Xu }
73737b090e6SNikolay Aleksandrov 
738cc0fdd80SLinus Lüssing static inline bool br_multicast_querier_exists(struct net_bridge *br,
739cc0fdd80SLinus Lüssing 					       struct ethhdr *eth)
740b00589afSLinus Lüssing {
741b00589afSLinus Lüssing 	return false;
742b00589afSLinus Lüssing }
74337b090e6SNikolay Aleksandrov 
744fdb184d1SRami Rosen static inline void br_mdb_init(void)
745fdb184d1SRami Rosen {
746fdb184d1SRami Rosen }
74737b090e6SNikolay Aleksandrov 
748fdb184d1SRami Rosen static inline void br_mdb_uninit(void)
749fdb184d1SRami Rosen {
750fdb184d1SRami Rosen }
7511080ab95SNikolay Aleksandrov 
7521080ab95SNikolay Aleksandrov static inline void br_multicast_count(struct net_bridge *br,
7531080ab95SNikolay Aleksandrov 				      const struct net_bridge_port *p,
754a65056ecSNikolay Aleksandrov 				      const struct sk_buff *skb,
755a65056ecSNikolay Aleksandrov 				      u8 type, u8 dir)
7561080ab95SNikolay Aleksandrov {
7571080ab95SNikolay Aleksandrov }
7581080ab95SNikolay Aleksandrov 
7591080ab95SNikolay Aleksandrov static inline int br_multicast_init_stats(struct net_bridge *br)
7601080ab95SNikolay Aleksandrov {
7611080ab95SNikolay Aleksandrov 	return 0;
7621080ab95SNikolay Aleksandrov }
7631080ab95SNikolay Aleksandrov 
764b6fe0440SIdo Schimmel static inline void br_multicast_uninit_stats(struct net_bridge *br)
765b6fe0440SIdo Schimmel {
766b6fe0440SIdo Schimmel }
767b6fe0440SIdo Schimmel 
7681080ab95SNikolay Aleksandrov static inline int br_multicast_igmp_type(const struct sk_buff *skb)
7691080ab95SNikolay Aleksandrov {
7701080ab95SNikolay Aleksandrov 	return 0;
7711080ab95SNikolay Aleksandrov }
77285b35269SSridhar Samudrala #endif
773eb1d1641SHerbert Xu 
774243a2e63SVlad Yasevich /* br_vlan.c */
775243a2e63SVlad Yasevich #ifdef CONFIG_BRIDGE_VLAN_FILTERING
77677751ee8SNikolay Aleksandrov bool br_allowed_ingress(const struct net_bridge *br,
77777751ee8SNikolay Aleksandrov 			struct net_bridge_vlan_group *vg, struct sk_buff *skb,
7782594e906SNikolay Aleksandrov 			u16 *vid);
77977751ee8SNikolay Aleksandrov bool br_allowed_egress(struct net_bridge_vlan_group *vg,
78085f46c6bSVlad Yasevich 		       const struct sk_buff *skb);
781e0d7968aSToshiaki Makita bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid);
782348662a1SJoe Perches struct sk_buff *br_handle_vlan(struct net_bridge *br,
78311538d03SRoopa Prabhu 			       const struct net_bridge_port *port,
7842594e906SNikolay Aleksandrov 			       struct net_bridge_vlan_group *vg,
78578851988SVlad Yasevich 			       struct sk_buff *skb);
786348662a1SJoe Perches int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags);
787348662a1SJoe Perches int br_vlan_delete(struct net_bridge *br, u16 vid);
788348662a1SJoe Perches void br_vlan_flush(struct net_bridge *br);
7892594e906SNikolay Aleksandrov struct net_bridge_vlan *br_vlan_find(struct net_bridge_vlan_group *vg, u16 vid);
790204177f3SToshiaki Makita void br_recalculate_fwd_mask(struct net_bridge *br);
791a7854037SNikolay Aleksandrov int __br_vlan_filter_toggle(struct net_bridge *br, unsigned long val);
792348662a1SJoe Perches int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val);
793d2d427b3SToshiaki Makita int __br_vlan_set_proto(struct net_bridge *br, __be16 proto);
794204177f3SToshiaki Makita int br_vlan_set_proto(struct net_bridge *br, unsigned long val);
7956dada9b1SNikolay Aleksandrov int br_vlan_set_stats(struct net_bridge *br, unsigned long val);
7965be5a2dfSVlad Yasevich int br_vlan_init(struct net_bridge *br);
79796a20d9dSVlad Yasevich int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val);
7980f963b75SNikolay Aleksandrov int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid);
799348662a1SJoe Perches int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags);
800348662a1SJoe Perches int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);
801348662a1SJoe Perches void nbp_vlan_flush(struct net_bridge_port *port);
8025be5a2dfSVlad Yasevich int nbp_vlan_init(struct net_bridge_port *port);
8032594e906SNikolay Aleksandrov int nbp_get_num_vlan_infos(struct net_bridge_port *p, u32 filter_mask);
804a60c0903SNikolay Aleksandrov void br_vlan_get_stats(const struct net_bridge_vlan *v,
805a60c0903SNikolay Aleksandrov 		       struct br_vlan_stats *stats);
806a37b85c9SVlad Yasevich 
8072594e906SNikolay Aleksandrov static inline struct net_bridge_vlan_group *br_vlan_group(
808a37b85c9SVlad Yasevich 					const struct net_bridge *br)
809a37b85c9SVlad Yasevich {
810907b1e6eSNikolay Aleksandrov 	return rtnl_dereference(br->vlgrp);
811a37b85c9SVlad Yasevich }
812a37b85c9SVlad Yasevich 
8132594e906SNikolay Aleksandrov static inline struct net_bridge_vlan_group *nbp_vlan_group(
814a37b85c9SVlad Yasevich 					const struct net_bridge_port *p)
815a37b85c9SVlad Yasevich {
816907b1e6eSNikolay Aleksandrov 	return rtnl_dereference(p->vlgrp);
817907b1e6eSNikolay Aleksandrov }
818907b1e6eSNikolay Aleksandrov 
819907b1e6eSNikolay Aleksandrov static inline struct net_bridge_vlan_group *br_vlan_group_rcu(
820907b1e6eSNikolay Aleksandrov 					const struct net_bridge *br)
821907b1e6eSNikolay Aleksandrov {
822907b1e6eSNikolay Aleksandrov 	return rcu_dereference(br->vlgrp);
823907b1e6eSNikolay Aleksandrov }
824907b1e6eSNikolay Aleksandrov 
825907b1e6eSNikolay Aleksandrov static inline struct net_bridge_vlan_group *nbp_vlan_group_rcu(
826907b1e6eSNikolay Aleksandrov 					const struct net_bridge_port *p)
827907b1e6eSNikolay Aleksandrov {
828907b1e6eSNikolay Aleksandrov 	return rcu_dereference(p->vlgrp);
829a37b85c9SVlad Yasevich }
830a37b85c9SVlad Yasevich 
831a37b85c9SVlad Yasevich /* Since bridge now depends on 8021Q module, but the time bridge sees the
832a37b85c9SVlad Yasevich  * skb, the vlan tag will always be present if the frame was tagged.
833a37b85c9SVlad Yasevich  */
834a37b85c9SVlad Yasevich static inline int br_vlan_get_tag(const struct sk_buff *skb, u16 *vid)
835a37b85c9SVlad Yasevich {
836a37b85c9SVlad Yasevich 	int err = 0;
837a37b85c9SVlad Yasevich 
8382594e906SNikolay Aleksandrov 	if (skb_vlan_tag_present(skb)) {
839df8a39deSJiri Pirko 		*vid = skb_vlan_tag_get(skb) & VLAN_VID_MASK;
8402594e906SNikolay Aleksandrov 	} else {
841a37b85c9SVlad Yasevich 		*vid = 0;
842a37b85c9SVlad Yasevich 		err = -EINVAL;
843a37b85c9SVlad Yasevich 	}
844a37b85c9SVlad Yasevich 
845a37b85c9SVlad Yasevich 	return err;
846a37b85c9SVlad Yasevich }
84778851988SVlad Yasevich 
84877751ee8SNikolay Aleksandrov static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
84978851988SVlad Yasevich {
85077751ee8SNikolay Aleksandrov 	if (!vg)
8515be5a2dfSVlad Yasevich 		return 0;
8525be5a2dfSVlad Yasevich 
85378851988SVlad Yasevich 	smp_rmb();
85477751ee8SNikolay Aleksandrov 	return vg->pvid;
85578851988SVlad Yasevich }
85678851988SVlad Yasevich 
857243a2e63SVlad Yasevich #else
85877751ee8SNikolay Aleksandrov static inline bool br_allowed_ingress(const struct net_bridge *br,
85977751ee8SNikolay Aleksandrov 				      struct net_bridge_vlan_group *vg,
8602594e906SNikolay Aleksandrov 				      struct sk_buff *skb,
8612594e906SNikolay Aleksandrov 				      u16 *vid)
8622594e906SNikolay Aleksandrov {
8632594e906SNikolay Aleksandrov 	return true;
8642594e906SNikolay Aleksandrov }
8652594e906SNikolay Aleksandrov 
8662594e906SNikolay Aleksandrov static inline bool br_allowed_egress(struct net_bridge_vlan_group *vg,
86785f46c6bSVlad Yasevich 				     const struct sk_buff *skb)
86885f46c6bSVlad Yasevich {
86985f46c6bSVlad Yasevich 	return true;
87085f46c6bSVlad Yasevich }
87185f46c6bSVlad Yasevich 
872e0d7968aSToshiaki Makita static inline bool br_should_learn(struct net_bridge_port *p,
873e0d7968aSToshiaki Makita 				   struct sk_buff *skb, u16 *vid)
874e0d7968aSToshiaki Makita {
875e0d7968aSToshiaki Makita 	return true;
876e0d7968aSToshiaki Makita }
877e0d7968aSToshiaki Makita 
87878851988SVlad Yasevich static inline struct sk_buff *br_handle_vlan(struct net_bridge *br,
87911538d03SRoopa Prabhu 					     const struct net_bridge_port *port,
8802594e906SNikolay Aleksandrov 					     struct net_bridge_vlan_group *vg,
88178851988SVlad Yasevich 					     struct sk_buff *skb)
88278851988SVlad Yasevich {
88378851988SVlad Yasevich 	return skb;
88478851988SVlad Yasevich }
88578851988SVlad Yasevich 
886552406c4SVlad Yasevich static inline int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags)
887243a2e63SVlad Yasevich {
888243a2e63SVlad Yasevich 	return -EOPNOTSUPP;
889243a2e63SVlad Yasevich }
890243a2e63SVlad Yasevich 
891243a2e63SVlad Yasevich static inline int br_vlan_delete(struct net_bridge *br, u16 vid)
892243a2e63SVlad Yasevich {
893243a2e63SVlad Yasevich 	return -EOPNOTSUPP;
894243a2e63SVlad Yasevich }
895243a2e63SVlad Yasevich 
896243a2e63SVlad Yasevich static inline void br_vlan_flush(struct net_bridge *br)
897243a2e63SVlad Yasevich {
898243a2e63SVlad Yasevich }
899243a2e63SVlad Yasevich 
900204177f3SToshiaki Makita static inline void br_recalculate_fwd_mask(struct net_bridge *br)
901204177f3SToshiaki Makita {
902204177f3SToshiaki Makita }
903204177f3SToshiaki Makita 
9045be5a2dfSVlad Yasevich static inline int br_vlan_init(struct net_bridge *br)
9058580e211SToshiaki Makita {
9065be5a2dfSVlad Yasevich 	return 0;
9078580e211SToshiaki Makita }
9088580e211SToshiaki Makita 
909552406c4SVlad Yasevich static inline int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags)
910243a2e63SVlad Yasevich {
911243a2e63SVlad Yasevich 	return -EOPNOTSUPP;
912243a2e63SVlad Yasevich }
913243a2e63SVlad Yasevich 
914243a2e63SVlad Yasevich static inline int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
915243a2e63SVlad Yasevich {
916243a2e63SVlad Yasevich 	return -EOPNOTSUPP;
917243a2e63SVlad Yasevich }
918243a2e63SVlad Yasevich 
919243a2e63SVlad Yasevich static inline void nbp_vlan_flush(struct net_bridge_port *port)
920243a2e63SVlad Yasevich {
921243a2e63SVlad Yasevich }
922243a2e63SVlad Yasevich 
9232594e906SNikolay Aleksandrov static inline struct net_bridge_vlan *br_vlan_find(struct net_bridge_vlan_group *vg,
9242594e906SNikolay Aleksandrov 						   u16 vid)
925a37b85c9SVlad Yasevich {
926a37b85c9SVlad Yasevich 	return NULL;
927a37b85c9SVlad Yasevich }
928bc9a25d2SVlad Yasevich 
9295be5a2dfSVlad Yasevich static inline int nbp_vlan_init(struct net_bridge_port *port)
9305be5a2dfSVlad Yasevich {
9315be5a2dfSVlad Yasevich 	return 0;
9325be5a2dfSVlad Yasevich }
9335be5a2dfSVlad Yasevich 
93478851988SVlad Yasevich static inline u16 br_vlan_get_tag(const struct sk_buff *skb, u16 *tag)
935a37b85c9SVlad Yasevich {
936a37b85c9SVlad Yasevich 	return 0;
937a37b85c9SVlad Yasevich }
9382594e906SNikolay Aleksandrov 
93977751ee8SNikolay Aleksandrov static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
94078851988SVlad Yasevich {
9413df6bf45SVlad Yasevich 	return 0;
94278851988SVlad Yasevich }
9432796d0c6SVlad Yasevich 
944a7854037SNikolay Aleksandrov static inline int __br_vlan_filter_toggle(struct net_bridge *br,
945a7854037SNikolay Aleksandrov 					  unsigned long val)
946a7854037SNikolay Aleksandrov {
947a7854037SNikolay Aleksandrov 	return -EOPNOTSUPP;
948a7854037SNikolay Aleksandrov }
9492594e906SNikolay Aleksandrov 
9502594e906SNikolay Aleksandrov static inline int nbp_get_num_vlan_infos(struct net_bridge_port *p,
9512594e906SNikolay Aleksandrov 					 u32 filter_mask)
9522594e906SNikolay Aleksandrov {
9532594e906SNikolay Aleksandrov 	return 0;
9542594e906SNikolay Aleksandrov }
9552594e906SNikolay Aleksandrov 
9562594e906SNikolay Aleksandrov static inline struct net_bridge_vlan_group *br_vlan_group(
9572594e906SNikolay Aleksandrov 					const struct net_bridge *br)
9582594e906SNikolay Aleksandrov {
9592594e906SNikolay Aleksandrov 	return NULL;
9602594e906SNikolay Aleksandrov }
9612594e906SNikolay Aleksandrov 
9622594e906SNikolay Aleksandrov static inline struct net_bridge_vlan_group *nbp_vlan_group(
9632594e906SNikolay Aleksandrov 					const struct net_bridge_port *p)
9642594e906SNikolay Aleksandrov {
9652594e906SNikolay Aleksandrov 	return NULL;
9662594e906SNikolay Aleksandrov }
967907b1e6eSNikolay Aleksandrov 
968907b1e6eSNikolay Aleksandrov static inline struct net_bridge_vlan_group *br_vlan_group_rcu(
969907b1e6eSNikolay Aleksandrov 					const struct net_bridge *br)
970907b1e6eSNikolay Aleksandrov {
971907b1e6eSNikolay Aleksandrov 	return NULL;
972907b1e6eSNikolay Aleksandrov }
973907b1e6eSNikolay Aleksandrov 
974907b1e6eSNikolay Aleksandrov static inline struct net_bridge_vlan_group *nbp_vlan_group_rcu(
975907b1e6eSNikolay Aleksandrov 					const struct net_bridge_port *p)
976907b1e6eSNikolay Aleksandrov {
977907b1e6eSNikolay Aleksandrov 	return NULL;
978907b1e6eSNikolay Aleksandrov }
979a60c0903SNikolay Aleksandrov 
980a60c0903SNikolay Aleksandrov static inline void br_vlan_get_stats(const struct net_bridge_vlan *v,
981a60c0903SNikolay Aleksandrov 				     struct br_vlan_stats *stats)
982a60c0903SNikolay Aleksandrov {
983a60c0903SNikolay Aleksandrov }
984243a2e63SVlad Yasevich #endif
985243a2e63SVlad Yasevich 
9861a4ba64dSPablo Neira Ayuso struct nf_br_ops {
9871a4ba64dSPablo Neira Ayuso 	int (*br_dev_xmit_hook)(struct sk_buff *skb);
9881a4ba64dSPablo Neira Ayuso };
9891a4ba64dSPablo Neira Ayuso extern const struct nf_br_ops __rcu *nf_br_ops;
9901a4ba64dSPablo Neira Ayuso 
9911da177e4SLinus Torvalds /* br_netfilter.c */
99234666d46SPablo Neira Ayuso #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
99334666d46SPablo Neira Ayuso int br_nf_core_init(void);
99434666d46SPablo Neira Ayuso void br_nf_core_fini(void);
995348662a1SJoe Perches void br_netfilter_rtable_init(struct net_bridge *);
996c0909713SStephen Hemminger #else
99734666d46SPablo Neira Ayuso static inline int br_nf_core_init(void) { return 0; }
99834666d46SPablo Neira Ayuso static inline void br_nf_core_fini(void) {}
9994adf0af6SSimon Wunderlich #define br_netfilter_rtable_init(x)
1000c0909713SStephen Hemminger #endif
10011da177e4SLinus Torvalds 
10021da177e4SLinus Torvalds /* br_stp.c */
1003775dd692SFlorian Fainelli void br_set_state(struct net_bridge_port *p, unsigned int state);
1004348662a1SJoe Perches struct net_bridge_port *br_get_port(struct net_bridge *br, u16 port_no);
1005348662a1SJoe Perches void br_init_port(struct net_bridge_port *p);
1006348662a1SJoe Perches void br_become_designated_port(struct net_bridge_port *p);
10071da177e4SLinus Torvalds 
1008348662a1SJoe Perches void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
1009348662a1SJoe Perches int br_set_forward_delay(struct net_bridge *br, unsigned long x);
1010348662a1SJoe Perches int br_set_hello_time(struct net_bridge *br, unsigned long x);
1011348662a1SJoe Perches int br_set_max_age(struct net_bridge *br, unsigned long x);
101282dd4332SVivien Didelot int __set_ageing_time(struct net_device *dev, unsigned long t);
10139e0b27feSVivien Didelot int br_set_ageing_time(struct net_bridge *br, clock_t ageing_time);
101414f98f25Sstephen hemminger 
101514f98f25Sstephen hemminger 
10161da177e4SLinus Torvalds /* br_stp_if.c */
1017348662a1SJoe Perches void br_stp_enable_bridge(struct net_bridge *br);
1018348662a1SJoe Perches void br_stp_disable_bridge(struct net_bridge *br);
1019348662a1SJoe Perches void br_stp_set_enabled(struct net_bridge *br, unsigned long val);
1020348662a1SJoe Perches void br_stp_enable_port(struct net_bridge_port *p);
1021348662a1SJoe Perches void br_stp_disable_port(struct net_bridge_port *p);
1022348662a1SJoe Perches bool br_stp_recalculate_bridge_id(struct net_bridge *br);
1023348662a1SJoe Perches void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *a);
1024348662a1SJoe Perches void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio);
1025348662a1SJoe Perches int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio);
1026348662a1SJoe Perches int br_stp_set_path_cost(struct net_bridge_port *p, unsigned long path_cost);
1027348662a1SJoe Perches ssize_t br_show_bridge_id(char *buf, const struct bridge_id *id);
10281da177e4SLinus Torvalds 
10291da177e4SLinus Torvalds /* br_stp_bpdu.c */
10307c85fbf0SPatrick McHardy struct stp_proto;
1031348662a1SJoe Perches void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
10327c85fbf0SPatrick McHardy 		struct net_device *dev);
10331da177e4SLinus Torvalds 
10341da177e4SLinus Torvalds /* br_stp_timer.c */
1035348662a1SJoe Perches void br_stp_timer_init(struct net_bridge *br);
1036348662a1SJoe Perches void br_stp_port_timer_init(struct net_bridge_port *p);
1037348662a1SJoe Perches unsigned long br_timer_value(const struct timer_list *timer);
10381da177e4SLinus Torvalds 
10391da177e4SLinus Torvalds /* br.c */
1040e6373c4cSIgor Maravić #if IS_ENABLED(CONFIG_ATM_LANE)
1041da678292SMichał Mirosław extern int (*br_fdb_test_addr_hook)(struct net_device *dev, unsigned char *addr);
1042da678292SMichał Mirosław #endif
10431da177e4SLinus Torvalds 
104411dc1f36SStephen Hemminger /* br_netlink.c */
1045149ddd83Sstephen hemminger extern struct rtnl_link_ops br_link_ops;
1046348662a1SJoe Perches int br_netlink_init(void);
1047348662a1SJoe Perches void br_netlink_fini(void);
1048348662a1SJoe Perches void br_ifinfo_notify(int event, struct net_bridge_port *port);
1049add511b3SRoopa Prabhu int br_setlink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags);
1050add511b3SRoopa Prabhu int br_dellink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags);
1051348662a1SJoe Perches int br_getlink(struct sk_buff *skb, u32 pid, u32 seq, struct net_device *dev,
105246c264daSNicolas Dichtel 	       u32 filter_mask, int nlflags);
105311dc1f36SStephen Hemminger 
10541da177e4SLinus Torvalds #ifdef CONFIG_SYSFS
10551da177e4SLinus Torvalds /* br_sysfs_if.c */
105652cf25d0SEmese Revfy extern const struct sysfs_ops brport_sysfs_ops;
1057348662a1SJoe Perches int br_sysfs_addif(struct net_bridge_port *p);
1058348662a1SJoe Perches int br_sysfs_renameif(struct net_bridge_port *p);
10591da177e4SLinus Torvalds 
10601da177e4SLinus Torvalds /* br_sysfs_br.c */
1061348662a1SJoe Perches int br_sysfs_addbr(struct net_device *dev);
1062348662a1SJoe Perches void br_sysfs_delbr(struct net_device *dev);
10631da177e4SLinus Torvalds 
10641da177e4SLinus Torvalds #else
10651da177e4SLinus Torvalds 
10660cb2bbbeSLee Jones static inline int br_sysfs_addif(struct net_bridge_port *p) { return 0; }
10670cb2bbbeSLee Jones static inline int br_sysfs_renameif(struct net_bridge_port *p) { return 0; }
10680cb2bbbeSLee Jones static inline int br_sysfs_addbr(struct net_device *dev) { return 0; }
10690cb2bbbeSLee Jones static inline void br_sysfs_delbr(struct net_device *dev) { return; }
10701da177e4SLinus Torvalds #endif /* CONFIG_SYSFS */
10711da177e4SLinus Torvalds 
10726bc506b4SIdo Schimmel /* br_switchdev.c */
10736bc506b4SIdo Schimmel #ifdef CONFIG_NET_SWITCHDEV
10746bc506b4SIdo Schimmel int nbp_switchdev_mark_set(struct net_bridge_port *p);
10756bc506b4SIdo Schimmel void nbp_switchdev_frame_mark(const struct net_bridge_port *p,
10766bc506b4SIdo Schimmel 			      struct sk_buff *skb);
10776bc506b4SIdo Schimmel bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
10786bc506b4SIdo Schimmel 				  const struct sk_buff *skb);
10793922285dSArkadi Sharshevsky int br_switchdev_set_port_flag(struct net_bridge_port *p,
10803922285dSArkadi Sharshevsky 			       unsigned long flags,
10813922285dSArkadi Sharshevsky 			       unsigned long mask);
10826bc506b4SIdo Schimmel #else
10836bc506b4SIdo Schimmel static inline int nbp_switchdev_mark_set(struct net_bridge_port *p)
10846bc506b4SIdo Schimmel {
10856bc506b4SIdo Schimmel 	return 0;
10866bc506b4SIdo Schimmel }
10876bc506b4SIdo Schimmel 
10886bc506b4SIdo Schimmel static inline void nbp_switchdev_frame_mark(const struct net_bridge_port *p,
10896bc506b4SIdo Schimmel 					    struct sk_buff *skb)
10906bc506b4SIdo Schimmel {
10916bc506b4SIdo Schimmel }
10926bc506b4SIdo Schimmel 
10936bc506b4SIdo Schimmel static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p,
10946bc506b4SIdo Schimmel 						const struct sk_buff *skb)
10956bc506b4SIdo Schimmel {
10966bc506b4SIdo Schimmel 	return true;
10976bc506b4SIdo Schimmel }
10983922285dSArkadi Sharshevsky 
10993922285dSArkadi Sharshevsky static inline int br_switchdev_set_port_flag(struct net_bridge_port *p,
11003922285dSArkadi Sharshevsky 					     unsigned long flags,
11013922285dSArkadi Sharshevsky 					     unsigned long mask)
11023922285dSArkadi Sharshevsky {
11033922285dSArkadi Sharshevsky 	return 0;
11043922285dSArkadi Sharshevsky }
11056bc506b4SIdo Schimmel #endif /* CONFIG_NET_SWITCHDEV */
11066bc506b4SIdo Schimmel 
11071da177e4SLinus Torvalds #endif
1108