• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/net/ipv6/netfilter/
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#include <linux/slab.h>
9
10#define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
11
12static const struct xt_table packet_raw = {
13	.name = "raw",
14	.valid_hooks = RAW_VALID_HOOKS,
15	.me = THIS_MODULE,
16	.af = NFPROTO_IPV6,
17	.priority = NF_IP6_PRI_RAW,
18};
19
20/* The work comes in here from netfilter.c. */
21static unsigned int
22ip6table_raw_hook(unsigned int hook, struct sk_buff *skb,
23		  const struct net_device *in, const struct net_device *out,
24		  int (*okfn)(struct sk_buff *))
25{
26	const struct net *net = dev_net((in != NULL) ? in : out);
27
28	return ip6t_do_table(skb, hook, in, out, net->ipv6.ip6table_raw);
29}
30
31static struct nf_hook_ops *rawtable_ops __read_mostly;
32
33static int __net_init ip6table_raw_net_init(struct net *net)
34{
35	struct ip6t_replace *repl;
36
37	repl = ip6t_alloc_initial_table(&packet_raw);
38	if (repl == NULL)
39		return -ENOMEM;
40	net->ipv6.ip6table_raw =
41		ip6t_register_table(net, &packet_raw, repl);
42	kfree(repl);
43	if (IS_ERR(net->ipv6.ip6table_raw))
44		return PTR_ERR(net->ipv6.ip6table_raw);
45	return 0;
46}
47
48static void __net_exit ip6table_raw_net_exit(struct net *net)
49{
50	ip6t_unregister_table(net, net->ipv6.ip6table_raw);
51}
52
53static struct pernet_operations ip6table_raw_net_ops = {
54	.init = ip6table_raw_net_init,
55	.exit = ip6table_raw_net_exit,
56};
57
58static int __init ip6table_raw_init(void)
59{
60	int ret;
61
62	ret = register_pernet_subsys(&ip6table_raw_net_ops);
63	if (ret < 0)
64		return ret;
65
66	/* Register hooks */
67	rawtable_ops = xt_hook_link(&packet_raw, ip6table_raw_hook);
68	if (IS_ERR(rawtable_ops)) {
69		ret = PTR_ERR(rawtable_ops);
70		goto cleanup_table;
71	}
72
73	return ret;
74
75 cleanup_table:
76	unregister_pernet_subsys(&ip6table_raw_net_ops);
77	return ret;
78}
79
80static void __exit ip6table_raw_fini(void)
81{
82	xt_hook_unlink(&packet_raw, rawtable_ops);
83	unregister_pernet_subsys(&ip6table_raw_net_ops);
84}
85
86module_init(ip6table_raw_init);
87module_exit(ip6table_raw_fini);
88MODULE_LICENSE("GPL");
89