xref: /openbmc/linux/net/bridge/br_private.h (revision cd5d5810)
1 /*
2  *	Linux ethernet bridge
3  *
4  *	Authors:
5  *	Lennert Buytenhek		<buytenh@gnu.org>
6  *
7  *	This program is free software; you can redistribute it and/or
8  *	modify it under the terms of the GNU General Public License
9  *	as published by the Free Software Foundation; either version
10  *	2 of the License, or (at your option) any later version.
11  */
12 
13 #ifndef _BR_PRIVATE_H
14 #define _BR_PRIVATE_H
15 
16 #include <linux/netdevice.h>
17 #include <linux/if_bridge.h>
18 #include <linux/netpoll.h>
19 #include <linux/u64_stats_sync.h>
20 #include <net/route.h>
21 #include <linux/if_vlan.h>
22 
23 #define BR_HASH_BITS 8
24 #define BR_HASH_SIZE (1 << BR_HASH_BITS)
25 
26 #define BR_HOLD_TIME (1*HZ)
27 
28 #define BR_PORT_BITS	10
29 #define BR_MAX_PORTS	(1<<BR_PORT_BITS)
30 #define BR_VLAN_BITMAP_LEN	BITS_TO_LONGS(VLAN_N_VID)
31 
32 #define BR_VERSION	"2.3"
33 
34 /* Control of forwarding link local multicast */
35 #define BR_GROUPFWD_DEFAULT	0
36 /* Don't allow forwarding control protocols like STP and LLDP */
37 #define BR_GROUPFWD_RESTRICTED	0x4007u
38 
39 /* Path to usermode spanning tree program */
40 #define BR_STP_PROG	"/sbin/bridge-stp"
41 
42 typedef struct bridge_id bridge_id;
43 typedef struct mac_addr mac_addr;
44 typedef __u16 port_id;
45 
46 struct bridge_id
47 {
48 	unsigned char	prio[2];
49 	unsigned char	addr[6];
50 };
51 
52 struct mac_addr
53 {
54 	unsigned char	addr[6];
55 };
56 
57 struct br_ip
58 {
59 	union {
60 		__be32	ip4;
61 #if IS_ENABLED(CONFIG_IPV6)
62 		struct in6_addr ip6;
63 #endif
64 	} u;
65 	__be16		proto;
66 	__u16		vid;
67 };
68 
69 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
70 /* our own querier */
71 struct bridge_mcast_query {
72 	struct timer_list	timer;
73 	u32			startup_sent;
74 };
75 
76 /* other querier */
77 struct bridge_mcast_querier {
78 	struct timer_list		timer;
79 	unsigned long			delay_time;
80 };
81 #endif
82 
83 struct net_port_vlans {
84 	u16				port_idx;
85 	u16				pvid;
86 	union {
87 		struct net_bridge_port		*port;
88 		struct net_bridge		*br;
89 	}				parent;
90 	struct rcu_head			rcu;
91 	unsigned long			vlan_bitmap[BR_VLAN_BITMAP_LEN];
92 	unsigned long			untagged_bitmap[BR_VLAN_BITMAP_LEN];
93 	u16				num_vlans;
94 };
95 
96 struct net_bridge_fdb_entry
97 {
98 	struct hlist_node		hlist;
99 	struct net_bridge_port		*dst;
100 
101 	struct rcu_head			rcu;
102 	unsigned long			updated;
103 	unsigned long			used;
104 	mac_addr			addr;
105 	unsigned char			is_local;
106 	unsigned char			is_static;
107 	__u16				vlan_id;
108 };
109 
110 struct net_bridge_port_group {
111 	struct net_bridge_port		*port;
112 	struct net_bridge_port_group __rcu *next;
113 	struct hlist_node		mglist;
114 	struct rcu_head			rcu;
115 	struct timer_list		timer;
116 	struct br_ip			addr;
117 	unsigned char			state;
118 };
119 
120 struct net_bridge_mdb_entry
121 {
122 	struct hlist_node		hlist[2];
123 	struct net_bridge		*br;
124 	struct net_bridge_port_group __rcu *ports;
125 	struct rcu_head			rcu;
126 	struct timer_list		timer;
127 	struct br_ip			addr;
128 	bool				mglist;
129 };
130 
131 struct net_bridge_mdb_htable
132 {
133 	struct hlist_head		*mhash;
134 	struct rcu_head			rcu;
135 	struct net_bridge_mdb_htable	*old;
136 	u32				size;
137 	u32				max;
138 	u32				secret;
139 	u32				ver;
140 };
141 
142 struct net_bridge_port
143 {
144 	struct net_bridge		*br;
145 	struct net_device		*dev;
146 	struct list_head		list;
147 
148 	/* STP */
149 	u8				priority;
150 	u8				state;
151 	u16				port_no;
152 	unsigned char			topology_change_ack;
153 	unsigned char			config_pending;
154 	port_id				port_id;
155 	port_id				designated_port;
156 	bridge_id			designated_root;
157 	bridge_id			designated_bridge;
158 	u32				path_cost;
159 	u32				designated_cost;
160 	unsigned long			designated_age;
161 
162 	struct timer_list		forward_delay_timer;
163 	struct timer_list		hold_timer;
164 	struct timer_list		message_age_timer;
165 	struct kobject			kobj;
166 	struct rcu_head			rcu;
167 
168 	unsigned long 			flags;
169 #define BR_HAIRPIN_MODE		0x00000001
170 #define BR_BPDU_GUARD           0x00000002
171 #define BR_ROOT_BLOCK		0x00000004
172 #define BR_MULTICAST_FAST_LEAVE	0x00000008
173 #define BR_ADMIN_COST		0x00000010
174 #define BR_LEARNING		0x00000020
175 #define BR_FLOOD		0x00000040
176 
177 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
178 	struct bridge_mcast_query	ip4_query;
179 #if IS_ENABLED(CONFIG_IPV6)
180 	struct bridge_mcast_query	ip6_query;
181 #endif /* IS_ENABLED(CONFIG_IPV6) */
182 	unsigned char			multicast_router;
183 	struct timer_list		multicast_router_timer;
184 	struct hlist_head		mglist;
185 	struct hlist_node		rlist;
186 #endif
187 
188 #ifdef CONFIG_SYSFS
189 	char				sysfs_name[IFNAMSIZ];
190 #endif
191 
192 #ifdef CONFIG_NET_POLL_CONTROLLER
193 	struct netpoll			*np;
194 #endif
195 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
196 	struct net_port_vlans __rcu	*vlan_info;
197 #endif
198 };
199 
200 #define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
201 
202 static inline struct net_bridge_port *br_port_get_rcu(const struct net_device *dev)
203 {
204 	return rcu_dereference(dev->rx_handler_data);
205 }
206 
207 static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *dev)
208 {
209 	return br_port_exists(dev) ?
210 		rtnl_dereference(dev->rx_handler_data) : NULL;
211 }
212 
213 struct br_cpu_netstats {
214 	u64			rx_packets;
215 	u64			rx_bytes;
216 	u64			tx_packets;
217 	u64			tx_bytes;
218 	struct u64_stats_sync	syncp;
219 };
220 
221 struct net_bridge
222 {
223 	spinlock_t			lock;
224 	struct list_head		port_list;
225 	struct net_device		*dev;
226 
227 	struct br_cpu_netstats __percpu *stats;
228 	spinlock_t			hash_lock;
229 	struct hlist_head		hash[BR_HASH_SIZE];
230 #ifdef CONFIG_BRIDGE_NETFILTER
231 	struct rtable 			fake_rtable;
232 	bool				nf_call_iptables;
233 	bool				nf_call_ip6tables;
234 	bool				nf_call_arptables;
235 #endif
236 	u16				group_fwd_mask;
237 
238 	/* STP */
239 	bridge_id			designated_root;
240 	bridge_id			bridge_id;
241 	u32				root_path_cost;
242 	unsigned long			max_age;
243 	unsigned long			hello_time;
244 	unsigned long			forward_delay;
245 	unsigned long			bridge_max_age;
246 	unsigned long			ageing_time;
247 	unsigned long			bridge_hello_time;
248 	unsigned long			bridge_forward_delay;
249 
250 	u8				group_addr[ETH_ALEN];
251 	u16				root_port;
252 
253 	enum {
254 		BR_NO_STP, 		/* no spanning tree */
255 		BR_KERNEL_STP,		/* old STP in kernel */
256 		BR_USER_STP,		/* new RSTP in userspace */
257 	} stp_enabled;
258 
259 	unsigned char			topology_change;
260 	unsigned char			topology_change_detected;
261 
262 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
263 	unsigned char			multicast_router;
264 
265 	u8				multicast_disabled:1;
266 	u8				multicast_querier:1;
267 	u8				multicast_query_use_ifaddr:1;
268 
269 	u32				hash_elasticity;
270 	u32				hash_max;
271 
272 	u32				multicast_last_member_count;
273 	u32				multicast_startup_query_count;
274 
275 	unsigned long			multicast_last_member_interval;
276 	unsigned long			multicast_membership_interval;
277 	unsigned long			multicast_querier_interval;
278 	unsigned long			multicast_query_interval;
279 	unsigned long			multicast_query_response_interval;
280 	unsigned long			multicast_startup_query_interval;
281 
282 	spinlock_t			multicast_lock;
283 	struct net_bridge_mdb_htable __rcu *mdb;
284 	struct hlist_head		router_list;
285 
286 	struct timer_list		multicast_router_timer;
287 	struct bridge_mcast_querier	ip4_querier;
288 	struct bridge_mcast_query	ip4_query;
289 #if IS_ENABLED(CONFIG_IPV6)
290 	struct bridge_mcast_querier	ip6_querier;
291 	struct bridge_mcast_query	ip6_query;
292 #endif /* IS_ENABLED(CONFIG_IPV6) */
293 #endif
294 
295 	struct timer_list		hello_timer;
296 	struct timer_list		tcn_timer;
297 	struct timer_list		topology_change_timer;
298 	struct timer_list		gc_timer;
299 	struct kobject			*ifobj;
300 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
301 	u8				vlan_enabled;
302 	struct net_port_vlans __rcu	*vlan_info;
303 #endif
304 };
305 
306 struct br_input_skb_cb {
307 	struct net_device *brdev;
308 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
309 	int igmp;
310 	int mrouters_only;
311 #endif
312 };
313 
314 #define BR_INPUT_SKB_CB(__skb)	((struct br_input_skb_cb *)(__skb)->cb)
315 
316 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
317 # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb)	(BR_INPUT_SKB_CB(__skb)->mrouters_only)
318 #else
319 # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb)	(0)
320 #endif
321 
322 #define br_printk(level, br, format, args...)	\
323 	printk(level "%s: " format, (br)->dev->name, ##args)
324 
325 #define br_err(__br, format, args...)			\
326 	br_printk(KERN_ERR, __br, format, ##args)
327 #define br_warn(__br, format, args...)			\
328 	br_printk(KERN_WARNING, __br, format, ##args)
329 #define br_notice(__br, format, args...)		\
330 	br_printk(KERN_NOTICE, __br, format, ##args)
331 #define br_info(__br, format, args...)			\
332 	br_printk(KERN_INFO, __br, format, ##args)
333 
334 #define br_debug(br, format, args...)			\
335 	pr_debug("%s: " format,  (br)->dev->name, ##args)
336 
337 extern struct notifier_block br_device_notifier;
338 
339 /* called under bridge lock */
340 static inline int br_is_root_bridge(const struct net_bridge *br)
341 {
342 	return !memcmp(&br->bridge_id, &br->designated_root, 8);
343 }
344 
345 /* br_device.c */
346 extern void br_dev_setup(struct net_device *dev);
347 extern void br_dev_delete(struct net_device *dev, struct list_head *list);
348 extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
349 			       struct net_device *dev);
350 #ifdef CONFIG_NET_POLL_CONTROLLER
351 static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
352 				       struct sk_buff *skb)
353 {
354 	struct netpoll *np = p->np;
355 
356 	if (np)
357 		netpoll_send_skb(np, skb);
358 }
359 
360 extern int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp);
361 extern void br_netpoll_disable(struct net_bridge_port *p);
362 #else
363 static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
364 				       struct sk_buff *skb)
365 {
366 }
367 
368 static inline int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp)
369 {
370 	return 0;
371 }
372 
373 static inline void br_netpoll_disable(struct net_bridge_port *p)
374 {
375 }
376 #endif
377 
378 /* br_fdb.c */
379 extern int br_fdb_init(void);
380 extern void br_fdb_fini(void);
381 extern void br_fdb_flush(struct net_bridge *br);
382 extern void br_fdb_changeaddr(struct net_bridge_port *p,
383 			      const unsigned char *newaddr);
384 extern void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);
385 extern void br_fdb_cleanup(unsigned long arg);
386 extern void br_fdb_delete_by_port(struct net_bridge *br,
387 				  const struct net_bridge_port *p, int do_all);
388 extern struct net_bridge_fdb_entry *__br_fdb_get(struct net_bridge *br,
389 						 const unsigned char *addr,
390 						 __u16 vid);
391 extern int br_fdb_test_addr(struct net_device *dev, unsigned char *addr);
392 extern int br_fdb_fillbuf(struct net_bridge *br, void *buf,
393 			  unsigned long count, unsigned long off);
394 extern int br_fdb_insert(struct net_bridge *br,
395 			 struct net_bridge_port *source,
396 			 const unsigned char *addr,
397 			 u16 vid);
398 extern void br_fdb_update(struct net_bridge *br,
399 			  struct net_bridge_port *source,
400 			  const unsigned char *addr,
401 			  u16 vid);
402 extern int fdb_delete_by_addr(struct net_bridge *br, const u8 *addr, u16 vid);
403 
404 extern int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
405 			 struct net_device *dev,
406 			 const unsigned char *addr);
407 extern int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[],
408 		      struct net_device *dev,
409 		      const unsigned char *addr,
410 		      u16 nlh_flags);
411 extern int br_fdb_dump(struct sk_buff *skb,
412 		       struct netlink_callback *cb,
413 		       struct net_device *dev,
414 		       int idx);
415 
416 /* br_forward.c */
417 extern void br_deliver(const struct net_bridge_port *to,
418 		struct sk_buff *skb);
419 extern int br_dev_queue_push_xmit(struct sk_buff *skb);
420 extern void br_forward(const struct net_bridge_port *to,
421 		struct sk_buff *skb, struct sk_buff *skb0);
422 extern int br_forward_finish(struct sk_buff *skb);
423 extern void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb,
424 			     bool unicast);
425 extern void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,
426 			     struct sk_buff *skb2, bool unicast);
427 
428 /* br_if.c */
429 extern void br_port_carrier_check(struct net_bridge_port *p);
430 extern int br_add_bridge(struct net *net, const char *name);
431 extern int br_del_bridge(struct net *net, const char *name);
432 extern void br_net_exit(struct net *net);
433 extern int br_add_if(struct net_bridge *br,
434 	      struct net_device *dev);
435 extern int br_del_if(struct net_bridge *br,
436 	      struct net_device *dev);
437 extern int br_min_mtu(const struct net_bridge *br);
438 extern netdev_features_t br_features_recompute(struct net_bridge *br,
439 	netdev_features_t features);
440 
441 /* br_input.c */
442 extern int br_handle_frame_finish(struct sk_buff *skb);
443 extern rx_handler_result_t br_handle_frame(struct sk_buff **pskb);
444 
445 /* br_ioctl.c */
446 extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
447 extern int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *arg);
448 
449 /* br_multicast.c */
450 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
451 extern unsigned int br_mdb_rehash_seq;
452 extern int br_multicast_rcv(struct net_bridge *br,
453 			    struct net_bridge_port *port,
454 			    struct sk_buff *skb);
455 extern struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
456 					       struct sk_buff *skb, u16 vid);
457 extern void br_multicast_add_port(struct net_bridge_port *port);
458 extern void br_multicast_del_port(struct net_bridge_port *port);
459 extern void br_multicast_enable_port(struct net_bridge_port *port);
460 extern void br_multicast_disable_port(struct net_bridge_port *port);
461 extern void br_multicast_init(struct net_bridge *br);
462 extern void br_multicast_open(struct net_bridge *br);
463 extern void br_multicast_stop(struct net_bridge *br);
464 extern void br_multicast_deliver(struct net_bridge_mdb_entry *mdst,
465 				 struct sk_buff *skb);
466 extern void br_multicast_forward(struct net_bridge_mdb_entry *mdst,
467 				 struct sk_buff *skb, struct sk_buff *skb2);
468 extern int br_multicast_set_router(struct net_bridge *br, unsigned long val);
469 extern int br_multicast_set_port_router(struct net_bridge_port *p,
470 					unsigned long val);
471 extern int br_multicast_toggle(struct net_bridge *br, unsigned long val);
472 extern int br_multicast_set_querier(struct net_bridge *br, unsigned long val);
473 extern int br_multicast_set_hash_max(struct net_bridge *br, unsigned long val);
474 extern struct net_bridge_mdb_entry *br_mdb_ip_get(
475 				struct net_bridge_mdb_htable *mdb,
476 				struct br_ip *dst);
477 extern struct net_bridge_mdb_entry *br_multicast_new_group(struct net_bridge *br,
478 				struct net_bridge_port *port, struct br_ip *group);
479 extern void br_multicast_free_pg(struct rcu_head *head);
480 extern struct net_bridge_port_group *br_multicast_new_port_group(
481 				struct net_bridge_port *port,
482 				struct br_ip *group,
483 				struct net_bridge_port_group __rcu *next,
484 				unsigned char state);
485 extern void br_mdb_init(void);
486 extern void br_mdb_uninit(void);
487 extern void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port,
488 			  struct br_ip *group, int type);
489 
490 #define mlock_dereference(X, br) \
491 	rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock))
492 
493 static inline bool br_multicast_is_router(struct net_bridge *br)
494 {
495 	return br->multicast_router == 2 ||
496 	       (br->multicast_router == 1 &&
497 		timer_pending(&br->multicast_router_timer));
498 }
499 
500 static inline bool
501 __br_multicast_querier_exists(struct net_bridge *br,
502 			      struct bridge_mcast_querier *querier)
503 {
504 	return time_is_before_jiffies(querier->delay_time) &&
505 	       (br->multicast_querier || timer_pending(&querier->timer));
506 }
507 
508 static inline bool br_multicast_querier_exists(struct net_bridge *br,
509 					       struct ethhdr *eth)
510 {
511 	switch (eth->h_proto) {
512 	case (htons(ETH_P_IP)):
513 		return __br_multicast_querier_exists(br, &br->ip4_querier);
514 #if IS_ENABLED(CONFIG_IPV6)
515 	case (htons(ETH_P_IPV6)):
516 		return __br_multicast_querier_exists(br, &br->ip6_querier);
517 #endif
518 	default:
519 		return false;
520 	}
521 }
522 #else
523 static inline int br_multicast_rcv(struct net_bridge *br,
524 				   struct net_bridge_port *port,
525 				   struct sk_buff *skb)
526 {
527 	return 0;
528 }
529 
530 static inline struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
531 						      struct sk_buff *skb, u16 vid)
532 {
533 	return NULL;
534 }
535 
536 static inline void br_multicast_add_port(struct net_bridge_port *port)
537 {
538 }
539 
540 static inline void br_multicast_del_port(struct net_bridge_port *port)
541 {
542 }
543 
544 static inline void br_multicast_enable_port(struct net_bridge_port *port)
545 {
546 }
547 
548 static inline void br_multicast_disable_port(struct net_bridge_port *port)
549 {
550 }
551 
552 static inline void br_multicast_init(struct net_bridge *br)
553 {
554 }
555 
556 static inline void br_multicast_open(struct net_bridge *br)
557 {
558 }
559 
560 static inline void br_multicast_stop(struct net_bridge *br)
561 {
562 }
563 
564 static inline void br_multicast_deliver(struct net_bridge_mdb_entry *mdst,
565 					struct sk_buff *skb)
566 {
567 }
568 
569 static inline void br_multicast_forward(struct net_bridge_mdb_entry *mdst,
570 					struct sk_buff *skb,
571 					struct sk_buff *skb2)
572 {
573 }
574 static inline bool br_multicast_is_router(struct net_bridge *br)
575 {
576 	return 0;
577 }
578 static inline bool br_multicast_querier_exists(struct net_bridge *br,
579 					       struct ethhdr *eth)
580 {
581 	return false;
582 }
583 static inline void br_mdb_init(void)
584 {
585 }
586 static inline void br_mdb_uninit(void)
587 {
588 }
589 #endif
590 
591 /* br_vlan.c */
592 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
593 extern bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v,
594 			       struct sk_buff *skb, u16 *vid);
595 extern bool br_allowed_egress(struct net_bridge *br,
596 			      const struct net_port_vlans *v,
597 			      const struct sk_buff *skb);
598 extern struct sk_buff *br_handle_vlan(struct net_bridge *br,
599 				      const struct net_port_vlans *v,
600 				      struct sk_buff *skb);
601 extern int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags);
602 extern int br_vlan_delete(struct net_bridge *br, u16 vid);
603 extern void br_vlan_flush(struct net_bridge *br);
604 extern int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val);
605 extern int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags);
606 extern int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);
607 extern void nbp_vlan_flush(struct net_bridge_port *port);
608 extern bool nbp_vlan_find(struct net_bridge_port *port, u16 vid);
609 
610 static inline struct net_port_vlans *br_get_vlan_info(
611 						const struct net_bridge *br)
612 {
613 	return rcu_dereference_rtnl(br->vlan_info);
614 }
615 
616 static inline struct net_port_vlans *nbp_get_vlan_info(
617 						const struct net_bridge_port *p)
618 {
619 	return rcu_dereference_rtnl(p->vlan_info);
620 }
621 
622 /* Since bridge now depends on 8021Q module, but the time bridge sees the
623  * skb, the vlan tag will always be present if the frame was tagged.
624  */
625 static inline int br_vlan_get_tag(const struct sk_buff *skb, u16 *vid)
626 {
627 	int err = 0;
628 
629 	if (vlan_tx_tag_present(skb))
630 		*vid = vlan_tx_tag_get(skb) & VLAN_VID_MASK;
631 	else {
632 		*vid = 0;
633 		err = -EINVAL;
634 	}
635 
636 	return err;
637 }
638 
639 static inline u16 br_get_pvid(const struct net_port_vlans *v)
640 {
641 	/* Return just the VID if it is set, or VLAN_N_VID (invalid vid) if
642 	 * vid wasn't set
643 	 */
644 	smp_rmb();
645 	return v->pvid ?: VLAN_N_VID;
646 }
647 
648 #else
649 static inline bool br_allowed_ingress(struct net_bridge *br,
650 				      struct net_port_vlans *v,
651 				      struct sk_buff *skb,
652 				      u16 *vid)
653 {
654 	return true;
655 }
656 
657 static inline bool br_allowed_egress(struct net_bridge *br,
658 				     const struct net_port_vlans *v,
659 				     const struct sk_buff *skb)
660 {
661 	return true;
662 }
663 
664 static inline struct sk_buff *br_handle_vlan(struct net_bridge *br,
665 					     const struct net_port_vlans *v,
666 					     struct sk_buff *skb)
667 {
668 	return skb;
669 }
670 
671 static inline int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags)
672 {
673 	return -EOPNOTSUPP;
674 }
675 
676 static inline int br_vlan_delete(struct net_bridge *br, u16 vid)
677 {
678 	return -EOPNOTSUPP;
679 }
680 
681 static inline void br_vlan_flush(struct net_bridge *br)
682 {
683 }
684 
685 static inline int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags)
686 {
687 	return -EOPNOTSUPP;
688 }
689 
690 static inline int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
691 {
692 	return -EOPNOTSUPP;
693 }
694 
695 static inline void nbp_vlan_flush(struct net_bridge_port *port)
696 {
697 }
698 
699 static inline struct net_port_vlans *br_get_vlan_info(
700 						const struct net_bridge *br)
701 {
702 	return NULL;
703 }
704 static inline struct net_port_vlans *nbp_get_vlan_info(
705 						const struct net_bridge_port *p)
706 {
707 	return NULL;
708 }
709 
710 static inline bool nbp_vlan_find(struct net_bridge_port *port, u16 vid)
711 {
712 	return false;
713 }
714 
715 static inline u16 br_vlan_get_tag(const struct sk_buff *skb, u16 *tag)
716 {
717 	return 0;
718 }
719 static inline u16 br_get_pvid(const struct net_port_vlans *v)
720 {
721 	return VLAN_N_VID;	/* Returns invalid vid */
722 }
723 #endif
724 
725 /* br_netfilter.c */
726 #ifdef CONFIG_BRIDGE_NETFILTER
727 extern int br_netfilter_init(void);
728 extern void br_netfilter_fini(void);
729 extern void br_netfilter_rtable_init(struct net_bridge *);
730 #else
731 #define br_netfilter_init()	(0)
732 #define br_netfilter_fini()	do { } while(0)
733 #define br_netfilter_rtable_init(x)
734 #endif
735 
736 /* br_stp.c */
737 extern void br_log_state(const struct net_bridge_port *p);
738 extern struct net_bridge_port *br_get_port(struct net_bridge *br,
739 					   u16 port_no);
740 extern void br_init_port(struct net_bridge_port *p);
741 extern void br_become_designated_port(struct net_bridge_port *p);
742 
743 extern void __br_set_forward_delay(struct net_bridge *br, unsigned long t);
744 extern int br_set_forward_delay(struct net_bridge *br, unsigned long x);
745 extern int br_set_hello_time(struct net_bridge *br, unsigned long x);
746 extern int br_set_max_age(struct net_bridge *br, unsigned long x);
747 
748 
749 /* br_stp_if.c */
750 extern void br_stp_enable_bridge(struct net_bridge *br);
751 extern void br_stp_disable_bridge(struct net_bridge *br);
752 extern void br_stp_set_enabled(struct net_bridge *br, unsigned long val);
753 extern void br_stp_enable_port(struct net_bridge_port *p);
754 extern void br_stp_disable_port(struct net_bridge_port *p);
755 extern bool br_stp_recalculate_bridge_id(struct net_bridge *br);
756 extern void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *a);
757 extern void br_stp_set_bridge_priority(struct net_bridge *br,
758 				       u16 newprio);
759 extern int br_stp_set_port_priority(struct net_bridge_port *p,
760 				    unsigned long newprio);
761 extern int br_stp_set_path_cost(struct net_bridge_port *p,
762 				unsigned long path_cost);
763 extern ssize_t br_show_bridge_id(char *buf, const struct bridge_id *id);
764 
765 /* br_stp_bpdu.c */
766 struct stp_proto;
767 extern void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
768 		       struct net_device *dev);
769 
770 /* br_stp_timer.c */
771 extern void br_stp_timer_init(struct net_bridge *br);
772 extern void br_stp_port_timer_init(struct net_bridge_port *p);
773 extern unsigned long br_timer_value(const struct timer_list *timer);
774 
775 /* br.c */
776 #if IS_ENABLED(CONFIG_ATM_LANE)
777 extern int (*br_fdb_test_addr_hook)(struct net_device *dev, unsigned char *addr);
778 #endif
779 
780 /* br_netlink.c */
781 extern struct rtnl_link_ops br_link_ops;
782 extern int br_netlink_init(void);
783 extern void br_netlink_fini(void);
784 extern void br_ifinfo_notify(int event, struct net_bridge_port *port);
785 extern int br_setlink(struct net_device *dev, struct nlmsghdr *nlmsg);
786 extern int br_dellink(struct net_device *dev, struct nlmsghdr *nlmsg);
787 extern int br_getlink(struct sk_buff *skb, u32 pid, u32 seq,
788 		      struct net_device *dev, u32 filter_mask);
789 
790 #ifdef CONFIG_SYSFS
791 /* br_sysfs_if.c */
792 extern const struct sysfs_ops brport_sysfs_ops;
793 extern int br_sysfs_addif(struct net_bridge_port *p);
794 extern int br_sysfs_renameif(struct net_bridge_port *p);
795 
796 /* br_sysfs_br.c */
797 extern int br_sysfs_addbr(struct net_device *dev);
798 extern void br_sysfs_delbr(struct net_device *dev);
799 
800 #else
801 
802 static inline int br_sysfs_addif(struct net_bridge_port *p) { return 0; }
803 static inline int br_sysfs_renameif(struct net_bridge_port *p) { return 0; }
804 static inline int br_sysfs_addbr(struct net_device *dev) { return 0; }
805 static inline void br_sysfs_delbr(struct net_device *dev) { return; }
806 #endif /* CONFIG_SYSFS */
807 
808 #endif
809