2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-16 22:20:36 +00:00
|
|
|
/* IP tables module for matching the routing realm
|
|
|
|
*
|
|
|
|
* (C) 2003 by Sampsa Ranta <sampsa@netsonic.fi>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
|
[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
|
|
|
#include <linux/netfilter_ipv4.h>
|
|
|
|
#include <linux/netfilter/xt_realm.h>
|
|
|
|
#include <linux/netfilter/x_tables.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Sampsa Ranta <sampsa@netsonic.fi>");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-01-15 07:42:28 +00:00
|
|
|
MODULE_DESCRIPTION("Xtables: Routing realm match");
|
[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
|
|
|
MODULE_ALIAS("ipt_realm");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-07-08 05:15:35 +00:00
|
|
|
static bool
|
2009-07-07 18:42:08 +00:00
|
|
|
realm_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-10-08 09:35:18 +00:00
|
|
|
const struct xt_realm_info *info = par->matchinfo;
|
2009-06-02 05:19:30 +00:00
|
|
|
const struct dst_entry *dst = skb_dst(skb);
|
2007-02-12 19:15:49 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return (info->id == (dst->tclassid & info->mask)) ^ info->invert;
|
|
|
|
}
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
static struct xt_match realm_mt_reg __read_mostly = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.name = "realm",
|
2007-12-05 07:24:03 +00:00
|
|
|
.match = realm_mt,
|
2006-03-21 02:01:58 +00:00
|
|
|
.matchsize = sizeof(struct xt_realm_info),
|
2007-11-20 02:53:30 +00:00
|
|
|
.hooks = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_FORWARD) |
|
|
|
|
(1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_LOCAL_IN),
|
2008-10-08 09:35:20 +00:00
|
|
|
.family = NFPROTO_UNSPEC,
|
2005-04-16 22:20:36 +00:00
|
|
|
.me = THIS_MODULE
|
|
|
|
};
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
static int __init realm_mt_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-12-05 07:24:03 +00:00
|
|
|
return xt_register_match(&realm_mt_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
static void __exit realm_mt_exit(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-12-05 07:24:03 +00:00
|
|
|
xt_unregister_match(&realm_mt_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-12-05 07:24:03 +00:00
|
|
|
module_init(realm_mt_init);
|
|
|
|
module_exit(realm_mt_exit);
|