~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/bridge/br_private.h

Version: ~ [ linux-5.5-rc7 ] ~ [ linux-5.4.13 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.97 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.166 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.210 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.210 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp