]>
Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
1da177e4 | 2 | /* IP tables module for matching the routing realm |
1da177e4 LT |
3 | * |
4 | * (C) 2003 by Sampsa Ranta <sampsa@netsonic.fi> | |
1da177e4 LT |
5 | */ |
6 | ||
7 | #include <linux/module.h> | |
8 | #include <linux/skbuff.h> | |
9 | #include <linux/netdevice.h> | |
10 | #include <net/route.h> | |
11 | ||
2e4e6a17 HW |
12 | #include <linux/netfilter_ipv4.h> |
13 | #include <linux/netfilter/xt_realm.h> | |
14 | #include <linux/netfilter/x_tables.h> | |
1da177e4 LT |
15 | |
16 | MODULE_AUTHOR("Sampsa Ranta <sampsa@netsonic.fi>"); | |
17 | MODULE_LICENSE("GPL"); | |
2ae15b64 | 18 | MODULE_DESCRIPTION("Xtables: Routing realm match"); |
2e4e6a17 | 19 | MODULE_ALIAS("ipt_realm"); |
1da177e4 | 20 | |
1d93a9cb | 21 | static bool |
62fc8051 | 22 | realm_mt(const struct sk_buff *skb, struct xt_action_param *par) |
1da177e4 | 23 | { |
f7108a20 | 24 | const struct xt_realm_info *info = par->matchinfo; |
adf30907 | 25 | const struct dst_entry *dst = skb_dst(skb); |
601e68e1 | 26 | |
1da177e4 LT |
27 | return (info->id == (dst->tclassid & info->mask)) ^ info->invert; |
28 | } | |
29 | ||
d3c5ee6d | 30 | static struct xt_match realm_mt_reg __read_mostly = { |
1da177e4 | 31 | .name = "realm", |
d3c5ee6d | 32 | .match = realm_mt, |
5d04bff0 | 33 | .matchsize = sizeof(struct xt_realm_info), |
6e23ae2a PM |
34 | .hooks = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_FORWARD) | |
35 | (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_LOCAL_IN), | |
ab4f21e6 | 36 | .family = NFPROTO_UNSPEC, |
1da177e4 LT |
37 | .me = THIS_MODULE |
38 | }; | |
39 | ||
d3c5ee6d | 40 | static int __init realm_mt_init(void) |
1da177e4 | 41 | { |
d3c5ee6d | 42 | return xt_register_match(&realm_mt_reg); |
1da177e4 LT |
43 | } |
44 | ||
d3c5ee6d | 45 | static void __exit realm_mt_exit(void) |
1da177e4 | 46 | { |
d3c5ee6d | 47 | xt_unregister_match(&realm_mt_reg); |
1da177e4 LT |
48 | } |
49 | ||
d3c5ee6d JE |
50 | module_init(realm_mt_init); |
51 | module_exit(realm_mt_exit); |