br.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. br_fdb_get_hook = br_fdb_get;
  55. br_fdb_put_hook = br_fdb_put;
  56. return 0;
  57. err_out4:
  58. unregister_netdevice_notifier(&br_device_notifier);
  59. err_out3:
  60. br_netfilter_fini();
  61. err_out2:
  62. unregister_pernet_subsys(&br_net_ops);
  63. err_out1:
  64. br_fdb_fini();
  65. err_out:
  66. stp_proto_unregister(&br_stp_proto);
  67. return err;
  68. }
  69. static void __exit br_deinit(void)
  70. {
  71. stp_proto_unregister(&br_stp_proto);
  72. br_netlink_fini();
  73. unregister_netdevice_notifier(&br_device_notifier);
  74. brioctl_set(NULL);
  75. unregister_pernet_subsys(&br_net_ops);
  76. synchronize_net();
  77. br_netfilter_fini();
  78. br_fdb_get_hook = NULL;
  79. br_fdb_put_hook = NULL;
  80. br_handle_frame_hook = NULL;
  81. br_fdb_fini();
  82. }
  83. EXPORT_SYMBOL(br_should_route_hook);
  84. module_init(br_init)
  85. module_exit(br_deinit)
  86. MODULE_LICENSE("GPL");
  87. MODULE_VERSION(BR_VERSION);