br.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Generic parts
  3. * Linux ethernet bridge
  4. *
  5. * Authors:
  6. * Lennert Buytenhek <buytenh@gnu.org>
  7. *
  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.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/kernel.h>
  15. #include <linux/netdevice.h>
  16. #include <linux/etherdevice.h>
  17. #include <linux/init.h>
  18. #include <linux/llc.h>
  19. #include <net/llc.h>
  20. #include <net/stp.h>
  21. #include "br_private.h"
  22. static const struct stp_proto br_stp_proto = {
  23. .rcv = br_stp_rcv,
  24. };
  25. static struct pernet_operations br_net_ops = {
  26. .exit = br_net_exit,
  27. };
  28. static int __init br_init(void)
  29. {
  30. int err;
  31. err = stp_proto_register(&br_stp_proto);
  32. if (err < 0) {
  33. pr_err("bridge: can't register sap for STP\n");
  34. return err;
  35. }
  36. err = br_fdb_init();
  37. if (err)
  38. goto err_out;
  39. err = register_pernet_subsys(&br_net_ops);
  40. if (err)
  41. goto err_out1;
  42. err = br_netfilter_init();
  43. if (err)
  44. goto err_out2;
  45. err = register_netdevice_notifier(&br_device_notifier);
  46. if (err)
  47. goto err_out3;
  48. err = br_netlink_init();
  49. if (err)
  50. goto err_out4;
  51. brioctl_set(br_ioctl_deviceless_stub);
  52. #if IS_ENABLED(CONFIG_ATM_LANE)
  53. br_fdb_test_addr_hook = br_fdb_test_addr;
  54. #endif
  55. return 0;
  56. err_out4:
  57. unregister_netdevice_notifier(&br_device_notifier);
  58. err_out3:
  59. br_netfilter_fini();
  60. err_out2:
  61. unregister_pernet_subsys(&br_net_ops);
  62. err_out1:
  63. br_fdb_fini();
  64. err_out:
  65. stp_proto_unregister(&br_stp_proto);
  66. return err;
  67. }
  68. static void __exit br_deinit(void)
  69. {
  70. stp_proto_unregister(&br_stp_proto);
  71. br_netlink_fini();
  72. unregister_netdevice_notifier(&br_device_notifier);
  73. brioctl_set(NULL);
  74. unregister_pernet_subsys(&br_net_ops);
  75. rcu_barrier(); /* Wait for completion of call_rcu()'s */
  76. br_netfilter_fini();
  77. #if IS_ENABLED(CONFIG_ATM_LANE)
  78. br_fdb_test_addr_hook = NULL;
  79. #endif
  80. br_fdb_fini();
  81. }
  82. module_init(br_init)
  83. module_exit(br_deinit)
  84. MODULE_LICENSE("GPL");
  85. MODULE_VERSION(BR_VERSION);
  86. MODULE_ALIAS_RTNL_LINK("bridge");