netfilter: nf_conntrack: add support for "conntrack zones"
[deliverable/linux.git] / net / ipv6 / netfilter / ip6table_raw.c
CommitLineData
1da177e4
LT
1/*
2 * IPv6 raw table, a port of the IPv4 raw table to IPv6
3 *
4 * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
5 */
6#include <linux/module.h>
7#include <linux/netfilter_ipv6/ip6_tables.h>
8
6e23ae2a 9#define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
1da177e4 10
35aad0ff 11static const struct xt_table packet_raw = {
1ab1457c
YH
12 .name = "raw",
13 .valid_hooks = RAW_VALID_HOOKS,
2e4e6a17 14 .me = THIS_MODULE,
f88e6a8a 15 .af = NFPROTO_IPV6,
2b95efe7 16 .priority = NF_IP6_PRI_FIRST,
1da177e4
LT
17};
18
19/* The work comes in here from netfilter.c. */
20static unsigned int
737535c5
JE
21ip6table_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 *))
1da177e4 24{
2b21e051 25 const struct net *net = dev_net((in != NULL) ? in : out);
1339dd91 26
2b21e051 27 return ip6t_do_table(skb, hook, in, out, net->ipv6.ip6table_raw);
1da177e4
LT
28}
29
2b95efe7 30static struct nf_hook_ops *rawtable_ops __read_mostly;
1da177e4 31
8280aa61
AD
32static int __net_init ip6table_raw_net_init(struct net *net)
33{
e3eaa991
JE
34 struct ip6t_replace *repl;
35
36 repl = ip6t_alloc_initial_table(&packet_raw);
37 if (repl == NULL)
38 return -ENOMEM;
8280aa61 39 net->ipv6.ip6table_raw =
e3eaa991
JE
40 ip6t_register_table(net, &packet_raw, repl);
41 kfree(repl);
8280aa61
AD
42 if (IS_ERR(net->ipv6.ip6table_raw))
43 return PTR_ERR(net->ipv6.ip6table_raw);
44 return 0;
45}
46
47static void __net_exit ip6table_raw_net_exit(struct net *net)
48{
f54e9367 49 ip6t_unregister_table(net, net->ipv6.ip6table_raw);
8280aa61
AD
50}
51
52static struct pernet_operations ip6table_raw_net_ops = {
53 .init = ip6table_raw_net_init,
54 .exit = ip6table_raw_net_exit,
55};
56
65b4b4e8 57static int __init ip6table_raw_init(void)
1da177e4
LT
58{
59 int ret;
60
8280aa61
AD
61 ret = register_pernet_subsys(&ip6table_raw_net_ops);
62 if (ret < 0)
63 return ret;
1da177e4
LT
64
65 /* Register hooks */
2b95efe7
JE
66 rawtable_ops = xt_hook_link(&packet_raw, ip6table_raw_hook);
67 if (IS_ERR(rawtable_ops)) {
68 ret = PTR_ERR(rawtable_ops);
1da177e4 69 goto cleanup_table;
2b95efe7 70 }
1da177e4 71
1da177e4
LT
72 return ret;
73
1da177e4 74 cleanup_table:
8280aa61 75 unregister_pernet_subsys(&ip6table_raw_net_ops);
1da177e4
LT
76 return ret;
77}
78
65b4b4e8 79static void __exit ip6table_raw_fini(void)
1da177e4 80{
2b95efe7 81 xt_hook_unlink(&packet_raw, rawtable_ops);
8280aa61 82 unregister_pernet_subsys(&ip6table_raw_net_ops);
1da177e4
LT
83}
84
65b4b4e8
AM
85module_init(ip6table_raw_init);
86module_exit(ip6table_raw_fini);
1da177e4 87MODULE_LICENSE("GPL");
This page took 0.513465 seconds and 5 git commands to generate.