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))
11 static const struct xt_table packet_raw = {
13 .valid_hooks = RAW_VALID_HOOKS,
16 .priority = NF_IP6_PRI_FIRST,
19 /* The work comes in here from netfilter.c. */
21 ip6table_raw_hook(unsigned int hook, struct sk_buff *skb,
22 const struct net_device *in, const struct net_device *out,
23 int (*okfn)(struct sk_buff *))
25 const struct net *net = dev_net((in != NULL) ? in : out);
27 return ip6t_do_table(skb, hook, in, out, net->ipv6.ip6table_raw);
30 static struct nf_hook_ops *rawtable_ops __read_mostly;
32 static int __net_init ip6table_raw_net_init(struct net *net)
34 struct ip6t_replace *repl;
36 repl = ip6t_alloc_initial_table(&packet_raw);
39 net->ipv6.ip6table_raw =
40 ip6t_register_table(net, &packet_raw, repl);
42 if (IS_ERR(net->ipv6.ip6table_raw))
43 return PTR_ERR(net->ipv6.ip6table_raw);
47 static void __net_exit ip6table_raw_net_exit(struct net *net)
49 ip6t_unregister_table(net, net->ipv6.ip6table_raw);
52 static struct pernet_operations ip6table_raw_net_ops = {
53 .init = ip6table_raw_net_init,
54 .exit = ip6table_raw_net_exit,
57 static int __init ip6table_raw_init(void)
61 ret = register_pernet_subsys(&ip6table_raw_net_ops);
66 rawtable_ops = xt_hook_link(&packet_raw, ip6table_raw_hook);
67 if (IS_ERR(rawtable_ops)) {
68 ret = PTR_ERR(rawtable_ops);
75 unregister_pernet_subsys(&ip6table_raw_net_ops);
79 static void __exit ip6table_raw_fini(void)
81 xt_hook_unlink(&packet_raw, rawtable_ops);
82 unregister_pernet_subsys(&ip6table_raw_net_ops);
85 module_init(ip6table_raw_init);
86 module_exit(ip6table_raw_fini);
87 MODULE_LICENSE("GPL");