br.c 2.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 *	Generic parts
 *	Linux ethernet bridge
 *
 *	Authors:
 *	Lennert Buytenhek		<buytenh@gnu.org>
 *
 *	This program is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU General Public License
 *	as published by the Free Software Foundation; either version
 *	2 of the License, or (at your option) any later version.
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/init.h>
19 20
#include <linux/llc.h>
#include <net/llc.h>
P
Patrick McHardy 已提交
21
#include <net/stp.h>
L
Linus Torvalds 已提交
22 23 24

#include "br_private.h"

25
int (*br_should_route_hook)(struct sk_buff *skb);
L
Linus Torvalds 已提交
26

P
Patrick McHardy 已提交
27 28 29
static const struct stp_proto br_stp_proto = {
	.rcv	= br_stp_rcv,
};
30

31 32 33 34
static struct pernet_operations br_net_ops = {
	.exit	= br_net_exit,
};

L
Linus Torvalds 已提交
35 36
static int __init br_init(void)
{
37 38
	int err;

P
Patrick McHardy 已提交
39 40
	err = stp_proto_register(&br_stp_proto);
	if (err < 0) {
41
		printk(KERN_ERR "bridge: can't register sap for STP\n");
P
Patrick McHardy 已提交
42
		return err;
43 44
	}

45 46
	err = br_fdb_init();
	if (err)
47
		goto err_out;
L
Linus Torvalds 已提交
48

49
	err = register_pernet_subsys(&br_net_ops);
50 51 52
	if (err)
		goto err_out1;

53
	err = br_netfilter_init();
54 55 56
	if (err)
		goto err_out2;

57
	err = register_netdevice_notifier(&br_device_notifier);
58 59 60
	if (err)
		goto err_out3;

61 62 63 64
	err = br_netlink_init();
	if (err)
		goto err_out4;

L
Linus Torvalds 已提交
65 66 67
	brioctl_set(br_ioctl_deviceless_stub);
	br_handle_frame_hook = br_handle_frame;

68 69 70
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
	br_fdb_test_addr_hook = br_fdb_test_addr;
#endif
L
Linus Torvalds 已提交
71 72

	return 0;
73
err_out4:
74
	unregister_netdevice_notifier(&br_device_notifier);
75
err_out3:
76
	br_netfilter_fini();
77 78
err_out2:
	unregister_pernet_subsys(&br_net_ops);
79
err_out1:
80 81
	br_fdb_fini();
err_out:
P
Patrick McHardy 已提交
82
	stp_proto_unregister(&br_stp_proto);
83
	return err;
L
Linus Torvalds 已提交
84 85 86 87
}

static void __exit br_deinit(void)
{
P
Patrick McHardy 已提交
88
	stp_proto_unregister(&br_stp_proto);
89

90
	br_netlink_fini();
L
Linus Torvalds 已提交
91 92 93
	unregister_netdevice_notifier(&br_device_notifier);
	brioctl_set(NULL);

94
	unregister_pernet_subsys(&br_net_ops);
L
Linus Torvalds 已提交
95

96
	rcu_barrier(); /* Wait for completion of call_rcu()'s */
L
Linus Torvalds 已提交
97

98
	br_netfilter_fini();
99 100 101
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
	br_fdb_test_addr_hook = NULL;
#endif
L
Linus Torvalds 已提交
102 103 104 105 106 107 108 109 110 111

	br_handle_frame_hook = NULL;
	br_fdb_fini();
}

EXPORT_SYMBOL(br_should_route_hook);

module_init(br_init)
module_exit(br_deinit)
MODULE_LICENSE("GPL");
S
Stephen Hemminger 已提交
112
MODULE_VERSION(BR_VERSION);