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