2 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Development of this code funded by Astaro AG (http://www.astaro.com/)
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/netfilter_bridge.h>
14 #include <net/netfilter/nf_tables.h>
16 static struct nft_af_info nft_af_bridge __read_mostly = {
17 .family = NFPROTO_BRIDGE,
18 .nhooks = NF_BR_NUMHOOKS,
22 static int nf_tables_bridge_init_net(struct net *net)
24 net->nft.bridge = kmalloc(sizeof(struct nft_af_info), GFP_KERNEL);
25 if (net->nft.bridge == NULL)
28 memcpy(net->nft.bridge, &nft_af_bridge, sizeof(nft_af_bridge));
30 if (nft_register_afinfo(net, net->nft.bridge) < 0)
35 kfree(net->nft.bridge);
39 static void nf_tables_bridge_exit_net(struct net *net)
41 nft_unregister_afinfo(net->nft.bridge);
42 kfree(net->nft.bridge);
45 static struct pernet_operations nf_tables_bridge_net_ops = {
46 .init = nf_tables_bridge_init_net,
47 .exit = nf_tables_bridge_exit_net,
50 static int __init nf_tables_bridge_init(void)
52 return register_pernet_subsys(&nf_tables_bridge_net_ops);
55 static void __exit nf_tables_bridge_exit(void)
57 return unregister_pernet_subsys(&nf_tables_bridge_net_ops);
60 module_init(nf_tables_bridge_init);
61 module_exit(nf_tables_bridge_exit);
63 MODULE_LICENSE("GPL");
64 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
65 MODULE_ALIAS_NFT_FAMILY(AF_BRIDGE);