2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* IPv6 raw table, a port of the IPv4 raw table to IPv6
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/netfilter_ipv6/ip6_tables.h>
|
|
|
|
|
2007-11-20 02:53:30 +00:00
|
|
|
#define RAW_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_OUT))
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-08-24 12:56:30 +00:00
|
|
|
static const struct
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct ip6t_replace repl;
|
|
|
|
struct ip6t_standard entries[2];
|
|
|
|
struct ip6t_error term;
|
2008-01-31 12:04:13 +00:00
|
|
|
} initial_table __net_initdata = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.repl = {
|
|
|
|
.name = "raw",
|
|
|
|
.valid_hooks = RAW_VALID_HOOKS,
|
|
|
|
.num_entries = 3,
|
|
|
|
.size = sizeof(struct ip6t_standard) * 2 + sizeof(struct ip6t_error),
|
|
|
|
.hook_entry = {
|
2007-11-20 02:53:30 +00:00
|
|
|
[NF_INET_PRE_ROUTING] = 0,
|
|
|
|
[NF_INET_LOCAL_OUT] = sizeof(struct ip6t_standard)
|
2005-04-16 22:20:36 +00:00
|
|
|
},
|
|
|
|
.underflow = {
|
2007-11-20 02:53:30 +00:00
|
|
|
[NF_INET_PRE_ROUTING] = 0,
|
|
|
|
[NF_INET_LOCAL_OUT] = sizeof(struct ip6t_standard)
|
2005-04-16 22:20:36 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
.entries = {
|
2007-05-10 21:14:16 +00:00
|
|
|
IP6T_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
|
|
|
|
IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
|
2005-04-16 22:20:36 +00:00
|
|
|
},
|
2007-05-10 21:14:16 +00:00
|
|
|
.term = IP6T_ERROR_INIT, /* ERROR */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2009-08-24 12:56:30 +00:00
|
|
|
static const struct xt_table packet_raw = {
|
2007-02-09 14:24:49 +00:00
|
|
|
.name = "raw",
|
|
|
|
.valid_hooks = RAW_VALID_HOOKS,
|
[NETFILTER] x_tables: Abstraction layer for {ip,ip6,arp}_tables
This monster-patch tries to do the best job for unifying the data
structures and backend interfaces for the three evil clones ip_tables,
ip6_tables and arp_tables. In an ideal world we would never have
allowed this kind of copy+paste programming... but well, our world
isn't (yet?) ideal.
o introduce a new x_tables module
o {ip,arp,ip6}_tables depend on this x_tables module
o registration functions for tables, matches and targets are only
wrappers around x_tables provided functions
o all matches/targets that are used from ip_tables and ip6_tables
are now implemented as xt_FOOBAR.c files and provide module aliases
to ipt_FOOBAR and ip6t_FOOBAR
o header files for xt_matches are in include/linux/netfilter/,
include/linux/netfilter_{ipv4,ipv6} contains compatibility wrappers
around the xt_FOOBAR.h headers
Based on this patchset we're going to further unify the code,
gradually getting rid of all the layer 3 specific assumptions.
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-01-12 21:30:04 +00:00
|
|
|
.me = THIS_MODULE,
|
2009-06-13 04:25:44 +00:00
|
|
|
.af = NFPROTO_IPV6,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The work comes in here from netfilter.c. */
|
|
|
|
static unsigned int
|
2008-10-08 09:35:01 +00:00
|
|
|
ip6t_pre_routing_hook(unsigned int hook,
|
2007-10-15 07:53:15 +00:00
|
|
|
struct sk_buff *skb,
|
2005-04-16 22:20:36 +00:00
|
|
|
const struct net_device *in,
|
|
|
|
const struct net_device *out,
|
|
|
|
int (*okfn)(struct sk_buff *))
|
|
|
|
{
|
2008-10-08 09:35:01 +00:00
|
|
|
return ip6t_do_table(skb, hook, in, out,
|
|
|
|
dev_net(in)->ipv6.ip6table_raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
ip6t_local_out_hook(unsigned int hook,
|
|
|
|
struct sk_buff *skb,
|
|
|
|
const struct net_device *in,
|
|
|
|
const struct net_device *out,
|
|
|
|
int (*okfn)(struct sk_buff *))
|
|
|
|
{
|
|
|
|
return ip6t_do_table(skb, hook, in, out,
|
|
|
|
dev_net(out)->ipv6.ip6table_raw);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 09:23:00 +00:00
|
|
|
static struct nf_hook_ops ip6t_ops[] __read_mostly = {
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:01 +00:00
|
|
|
.hook = ip6t_pre_routing_hook,
|
2009-06-13 04:20:29 +00:00
|
|
|
.pf = NFPROTO_IPV6,
|
2007-11-20 02:53:30 +00:00
|
|
|
.hooknum = NF_INET_PRE_ROUTING,
|
2005-06-21 21:03:01 +00:00
|
|
|
.priority = NF_IP6_PRI_FIRST,
|
|
|
|
.owner = THIS_MODULE,
|
2005-04-16 22:20:36 +00:00
|
|
|
},
|
|
|
|
{
|
2008-10-08 09:35:01 +00:00
|
|
|
.hook = ip6t_local_out_hook,
|
2009-06-13 04:20:29 +00:00
|
|
|
.pf = NFPROTO_IPV6,
|
2007-11-20 02:53:30 +00:00
|
|
|
.hooknum = NF_INET_LOCAL_OUT,
|
2005-06-21 21:03:01 +00:00
|
|
|
.priority = NF_IP6_PRI_FIRST,
|
|
|
|
.owner = THIS_MODULE,
|
2005-04-16 22:20:36 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2008-01-31 12:04:13 +00:00
|
|
|
static int __net_init ip6table_raw_net_init(struct net *net)
|
|
|
|
{
|
|
|
|
/* Register table */
|
|
|
|
net->ipv6.ip6table_raw =
|
|
|
|
ip6t_register_table(net, &packet_raw, &initial_table.repl);
|
|
|
|
if (IS_ERR(net->ipv6.ip6table_raw))
|
|
|
|
return PTR_ERR(net->ipv6.ip6table_raw);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __net_exit ip6table_raw_net_exit(struct net *net)
|
|
|
|
{
|
2010-01-18 07:25:47 +00:00
|
|
|
ip6t_unregister_table(net, net->ipv6.ip6table_raw);
|
2008-01-31 12:04:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pernet_operations ip6table_raw_net_ops = {
|
|
|
|
.init = ip6table_raw_net_init,
|
|
|
|
.exit = ip6table_raw_net_exit,
|
|
|
|
};
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static int __init ip6table_raw_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2008-01-31 12:04:13 +00:00
|
|
|
ret = register_pernet_subsys(&ip6table_raw_net_ops);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Register hooks */
|
2006-04-06 21:09:49 +00:00
|
|
|
ret = nf_register_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto cleanup_table;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
cleanup_table:
|
2008-01-31 12:04:13 +00:00
|
|
|
unregister_pernet_subsys(&ip6table_raw_net_ops);
|
2005-04-16 22:20:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
static void __exit ip6table_raw_fini(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-04-06 21:09:49 +00:00
|
|
|
nf_unregister_hooks(ip6t_ops, ARRAY_SIZE(ip6t_ops));
|
2008-01-31 12:04:13 +00:00
|
|
|
unregister_pernet_subsys(&ip6table_raw_net_ops);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-29 00:37:06 +00:00
|
|
|
module_init(ip6table_raw_init);
|
|
|
|
module_exit(ip6table_raw_fini);
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_LICENSE("GPL");
|