Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / net / bridge / br.c
blob19311aafcf5a06e6ae7abaaf82527711573dc6d6
1 /*
2 * Generic parts
3 * Linux ethernet bridge
5 * Authors:
6 * Lennert Buytenhek <buytenh@gnu.org>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/netdevice.h>
17 #include <linux/etherdevice.h>
18 #include <linux/init.h>
19 #include <linux/llc.h>
20 #include <net/llc.h>
21 #include <net/stp.h>
23 #include "br_private.h"
25 static void __net_exit br_net_exit(struct net *net)
27 struct net_device *dev;
28 LIST_HEAD(list);
30 rtnl_lock();
31 for_each_netdev(net, dev)
32 if (dev->priv_flags & IFF_EBRIDGE)
33 br_dev_delete(dev, &list);
35 unregister_netdevice_many(&list);
36 rtnl_unlock();
40 static struct pernet_operations br_net_ops = {
41 .exit = br_net_exit,
44 static const struct stp_proto br_stp_proto = {
45 .rcv = br_stp_rcv,
48 static int __init br_init(void)
50 int err;
52 err = stp_proto_register(&br_stp_proto);
53 if (err < 0) {
54 pr_err("bridge: can't register sap for STP\n");
55 return err;
58 err = br_fdb_init();
59 if (err)
60 goto err_out;
62 err = register_pernet_subsys(&br_net_ops);
63 if (err)
64 goto err_out1;
66 err = br_netfilter_init();
67 if (err)
68 goto err_out2;
70 err = register_netdevice_notifier(&br_device_notifier);
71 if (err)
72 goto err_out3;
74 err = br_netlink_init();
75 if (err)
76 goto err_out4;
78 brioctl_set(br_ioctl_deviceless_stub);
80 #if IS_ENABLED(CONFIG_ATM_LANE)
81 br_fdb_test_addr_hook = br_fdb_test_addr;
82 #endif
84 return 0;
85 err_out4:
86 unregister_netdevice_notifier(&br_device_notifier);
87 err_out3:
88 br_netfilter_fini();
89 err_out2:
90 unregister_pernet_subsys(&br_net_ops);
91 err_out1:
92 br_fdb_fini();
93 err_out:
94 stp_proto_unregister(&br_stp_proto);
95 return err;
98 static void __exit br_deinit(void)
100 stp_proto_unregister(&br_stp_proto);
102 br_netlink_fini();
103 unregister_netdevice_notifier(&br_device_notifier);
104 brioctl_set(NULL);
106 unregister_pernet_subsys(&br_net_ops);
108 rcu_barrier(); /* Wait for completion of call_rcu()'s */
110 br_netfilter_fini();
111 #if IS_ENABLED(CONFIG_ATM_LANE)
112 br_fdb_test_addr_hook = NULL;
113 #endif
115 br_fdb_fini();
118 module_init(br_init)
119 module_exit(br_deinit)
120 MODULE_LICENSE("GPL");
121 MODULE_VERSION(BR_VERSION);
122 MODULE_ALIAS_RTNL_LINK("bridge");