2 * IPv6 raw table, a port of the IPv4 raw table to IPv6
6 #include <linux/module.h>
7 #include <linux/netfilter_ipv6/ip6_tables.h>
8 #include <linux/slab.h>
10 #define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
12 static int __net_init ip6table_raw_table_init(struct net *net);
14 static const struct xt_table packet_raw = {
16 .valid_hooks = RAW_VALID_HOOKS,
19 .priority = NF_IP6_PRI_RAW,
20 .table_init = ip6table_raw_table_init,
23 /* The work comes in here from netfilter.c. */
25 ip6table_raw_hook(void *priv, struct sk_buff *skb,
26 const struct nf_hook_state *state)
28 return ip6t_do_table(skb, state, state->net->ipv6.ip6table_raw);
31 static struct nf_hook_ops *rawtable_ops __read_mostly;
33 static int __net_init ip6table_raw_table_init(struct net *net)
35 struct ip6t_replace *repl;
38 if (net->ipv6.ip6table_raw)
41 repl = ip6t_alloc_initial_table(&packet_raw);
44 ret = ip6t_register_table(net, &packet_raw, repl, rawtable_ops,
45 &net->ipv6.ip6table_raw);
50 static void __net_exit ip6table_raw_net_exit(struct net *net)
52 if (!net->ipv6.ip6table_raw)
54 ip6t_unregister_table(net, net->ipv6.ip6table_raw, rawtable_ops);
55 net->ipv6.ip6table_raw = NULL;
58 static struct pernet_operations ip6table_raw_net_ops = {
59 .exit = ip6table_raw_net_exit,
62 static int __init ip6table_raw_init(void)
67 rawtable_ops = xt_hook_ops_alloc(&packet_raw, ip6table_raw_hook);
68 if (IS_ERR(rawtable_ops))
69 return PTR_ERR(rawtable_ops);
71 ret = register_pernet_subsys(&ip6table_raw_net_ops);
77 ret = ip6table_raw_table_init(&init_net);
79 unregister_pernet_subsys(&ip6table_raw_net_ops);
85 static void __exit ip6table_raw_fini(void)
87 unregister_pernet_subsys(&ip6table_raw_net_ops);
91 module_init(ip6table_raw_init);
92 module_exit(ip6table_raw_fini);
93 MODULE_LICENSE("GPL");