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>
8 #include <linux/slab.h>
10 #define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
12 static const struct xt_table packet_raw
= {
14 .valid_hooks
= RAW_VALID_HOOKS
,
17 .priority
= NF_IP6_PRI_RAW
,
20 /* The work comes in here from netfilter.c. */
22 ip6table_raw_hook(const struct nf_hook_ops
*ops
, struct sk_buff
*skb
,
23 const struct nf_hook_state
*state
)
25 return ip6t_do_table(skb
, ops
->hooknum
, state
,
26 state
->net
->ipv6
.ip6table_raw
);
29 static struct nf_hook_ops
*rawtable_ops __read_mostly
;
31 static int __net_init
ip6table_raw_net_init(struct net
*net
)
33 struct ip6t_replace
*repl
;
35 repl
= ip6t_alloc_initial_table(&packet_raw
);
38 net
->ipv6
.ip6table_raw
=
39 ip6t_register_table(net
, &packet_raw
, repl
);
41 return PTR_ERR_OR_ZERO(net
->ipv6
.ip6table_raw
);
44 static void __net_exit
ip6table_raw_net_exit(struct net
*net
)
46 ip6t_unregister_table(net
, net
->ipv6
.ip6table_raw
);
49 static struct pernet_operations ip6table_raw_net_ops
= {
50 .init
= ip6table_raw_net_init
,
51 .exit
= ip6table_raw_net_exit
,
54 static int __init
ip6table_raw_init(void)
58 ret
= register_pernet_subsys(&ip6table_raw_net_ops
);
63 rawtable_ops
= xt_hook_link(&packet_raw
, ip6table_raw_hook
);
64 if (IS_ERR(rawtable_ops
)) {
65 ret
= PTR_ERR(rawtable_ops
);
72 unregister_pernet_subsys(&ip6table_raw_net_ops
);
76 static void __exit
ip6table_raw_fini(void)
78 xt_hook_unlink(&packet_raw
, rawtable_ops
);
79 unregister_pernet_subsys(&ip6table_raw_net_ops
);
82 module_init(ip6table_raw_init
);
83 module_exit(ip6table_raw_fini
);
84 MODULE_LICENSE("GPL");