Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdim...
[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>
5a0e3ad6 8#include <linux/slab.h>
1da177e4 9
6e23ae2a 10#define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
1da177e4 11
35aad0ff 12static const struct xt_table packet_raw = {
1ab1457c
YH
13 .name = "raw",
14 .valid_hooks = RAW_VALID_HOOKS,
2e4e6a17 15 .me = THIS_MODULE,
f88e6a8a 16 .af = NFPROTO_IPV6,
9c138866 17 .priority = NF_IP6_PRI_RAW,
1da177e4
LT
18};
19
20/* The work comes in here from netfilter.c. */
21static unsigned int
06198b34 22ip6table_raw_hook(void *priv, struct sk_buff *skb,
238e54c9 23 const struct nf_hook_state *state)
1da177e4 24{
6cb8ff3f 25 return ip6t_do_table(skb, state, state->net->ipv6.ip6table_raw);
1da177e4
LT
26}
27
2b95efe7 28static struct nf_hook_ops *rawtable_ops __read_mostly;
1da177e4 29
8280aa61
AD
30static int __net_init ip6table_raw_net_init(struct net *net)
31{
e3eaa991
JE
32 struct ip6t_replace *repl;
33
34 repl = ip6t_alloc_initial_table(&packet_raw);
35 if (repl == NULL)
36 return -ENOMEM;
8280aa61 37 net->ipv6.ip6table_raw =
e3eaa991
JE
38 ip6t_register_table(net, &packet_raw, repl);
39 kfree(repl);
8c6ffba0 40 return PTR_ERR_OR_ZERO(net->ipv6.ip6table_raw);
8280aa61
AD
41}
42
43static void __net_exit ip6table_raw_net_exit(struct net *net)
44{
f54e9367 45 ip6t_unregister_table(net, net->ipv6.ip6table_raw);
8280aa61
AD
46}
47
48static struct pernet_operations ip6table_raw_net_ops = {
49 .init = ip6table_raw_net_init,
50 .exit = ip6table_raw_net_exit,
51};
52
65b4b4e8 53static int __init ip6table_raw_init(void)
1da177e4
LT
54{
55 int ret;
56
8280aa61
AD
57 ret = register_pernet_subsys(&ip6table_raw_net_ops);
58 if (ret < 0)
59 return ret;
1da177e4
LT
60
61 /* Register hooks */
2b95efe7
JE
62 rawtable_ops = xt_hook_link(&packet_raw, ip6table_raw_hook);
63 if (IS_ERR(rawtable_ops)) {
64 ret = PTR_ERR(rawtable_ops);
1da177e4 65 goto cleanup_table;
2b95efe7 66 }
1da177e4 67
1da177e4
LT
68 return ret;
69
1da177e4 70 cleanup_table:
8280aa61 71 unregister_pernet_subsys(&ip6table_raw_net_ops);
1da177e4
LT
72 return ret;
73}
74
65b4b4e8 75static void __exit ip6table_raw_fini(void)
1da177e4 76{
2b95efe7 77 xt_hook_unlink(&packet_raw, rawtable_ops);
8280aa61 78 unregister_pernet_subsys(&ip6table_raw_net_ops);
1da177e4
LT
79}
80
65b4b4e8
AM
81module_init(ip6table_raw_init);
82module_exit(ip6table_raw_fini);
1da177e4 83MODULE_LICENSE("GPL");
This page took 0.832101 seconds and 5 git commands to generate.