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