2 * IPv6 raw table, a port of the IPv4 raw table to IPv6
4 * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
6 #include <linux/module.h>
7 #include <linux/netfilter_ipv6/ip6_tables.h>
9 #define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
13 struct ip6t_replace repl;
14 struct ip6t_standard entries[2];
15 struct ip6t_error term;
16 } initial_table __net_initdata = {
19 .valid_hooks = RAW_VALID_HOOKS,
21 .size = sizeof(struct ip6t_standard) * 2 + sizeof(struct ip6t_error),
23 [NF_INET_PRE_ROUTING] = 0,
24 [NF_INET_LOCAL_OUT] = sizeof(struct ip6t_standard)
27 [NF_INET_PRE_ROUTING] = 0,
28 [NF_INET_LOCAL_OUT] = sizeof(struct ip6t_standard)
32 IP6T_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
33 IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
35 .term = IP6T_ERROR_INIT, /* ERROR */
38 static const struct xt_table packet_raw = {
40 .valid_hooks = RAW_VALID_HOOKS,
45 /* The work comes in here from netfilter.c. */
47 ip6table_raw_hook(unsigned int hook, struct sk_buff *skb,
48 const struct net_device *in, const struct net_device *out,
49 int (*okfn)(struct sk_buff *))
51 if (hook == NF_INET_PRE_ROUTING)
52 return ip6t_do_table(skb, hook, in, out,
53 dev_net(in)->ipv6.ip6table_raw);
56 return ip6t_do_table(skb, hook, in, out,
57 dev_net(out)->ipv6.ip6table_raw);
60 static struct nf_hook_ops ip6t_ops[] __read_mostly = {
62 .hook = ip6table_raw_hook,
64 .hooknum = NF_INET_PRE_ROUTING,
65 .priority = NF_IP6_PRI_FIRST,
69 .hook = ip6table_raw_hook,
71 .hooknum = NF_INET_LOCAL_OUT,
72 .priority = NF_IP6_PRI_FIRST,
77 static int __net_init ip6table_raw_net_init(struct net *net)
80 net->ipv6.ip6table_raw =
81 ip6t_register_table(net, &packet_raw, &initial_table.repl);
82 if (IS_ERR(net->ipv6.ip6table_raw))
83 return PTR_ERR(net->ipv6.ip6table_raw);
87 static void __net_exit ip6table_raw_net_exit(struct net *net)
89 ip6t_unregister_table(net, net->ipv6.ip6table_raw);
92 static struct pernet_operations ip6table_raw_net_ops = {
93 .init = ip6table_raw_net_init,
94 .exit = ip6table_raw_net_exit,
97 static int __init ip6table_raw_init(void)
101 ret = register_pernet_subsys(&ip6table_raw_net_ops);
106 ret = nf_register_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
113 unregister_pernet_subsys(&ip6table_raw_net_ops);
117 static void __exit ip6table_raw_fini(void)
119 nf_unregister_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
120 unregister_pernet_subsys(&ip6table_raw_net_ops);
123 module_init(ip6table_raw_init);
124 module_exit(ip6table_raw_fini);
125 MODULE_LICENSE("GPL");