br.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. int (*br_should_route_hook)(struct sk_buff *skb);
  23. static const struct stp_proto br_stp_proto = {
  24. .rcv = br_stp_rcv,
  25. };
  26. static struct pernet_operations br_net_ops = {
  27. .exit = br_net_exit,
  28. };
  29. static int __init br_init(void)
  30. {
  31. int err;
  32. err = stp_proto_register(&br_stp_proto);
  33. if (err < 0) {
  34. printk(KERN_ERR "bridge: can't register sap for STP\n");
  35. return err;
  36. }
  37. err = br_fdb_init();
  38. if (err)
  39. goto err_out;
  40. err = register_pernet_subsys(&br_net_ops);
  41. if (err)
  42. goto err_out1;
  43. err = br_netfilter_init();
  44. if (err)
  45. goto err_out2;
  46. err = register_netdevice_notifier(&br_device_notifier);
  47. if (err)
  48. goto err_out3;
  49. err = br_netlink_init();
  50. if (err)
  51. goto err_out4;
  52. brioctl_set(br_ioctl_deviceless_stub);
  53. br_handle_frame_hook = br_handle_frame;
  54. #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
  55. br_fdb_test_addr_hook = br_fdb_test_addr;
  56. #endif
  57. return 0;
  58. err_out4:
  59. unregister_netdevice_notifier(&br_device_notifier);
  60. err_out3:
  61. br_netfilter_fini();
  62. err_out2:
  63. unregister_pernet_subsys(&br_net_ops);
  64. err_out1:
  65. br_fdb_fini();
  66. err_out:
  67. stp_proto_unregister(&br_stp_proto);
  68. return err;
  69. }
  70. static void __exit br_deinit(void)
  71. {
  72. stp_proto_unregister(&br_stp_proto);
  73. br_netlink_fini();
  74. unregister_netdevice_notifier(&br_device_notifier);
  75. brioctl_set(NULL);
  76. unregister_pernet_subsys(&br_net_ops);
  77. rcu_barrier(); /* Wait for completion of call_rcu()'s */
  78. br_netfilter_fini();
  79. #if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
  80. br_fdb_test_addr_hook = NULL;
  81. #endif
  82. br_handle_frame_hook = NULL;
  83. br_fdb_fini();
  84. }
  85. EXPORT_SYMBOL(br_should_route_hook);
  86. module_init(br_init)
  87. module_exit(br_deinit)
  88. MODULE_LICENSE("GPL");
  89. MODULE_VERSION(BR_VERSION);