1 --- a/net/netfilter/Kconfig
2 +++ b/net/netfilter/Kconfig
3 @@ -837,6 +837,13 @@ config NETFILTER_XT_MATCH_HL
4 in the IPv6 header, or the time-to-live field in the IPv4
7 +config NETFILTER_XT_MATCH_ID
8 + tristate '"id" match support'
9 + depends on NETFILTER_ADVANCED
11 + This option adds a `id' dummy-match, which allows you to put
12 + numeric IDs into your iptables ruleset.
14 config NETFILTER_XT_MATCH_IPRANGE
15 tristate '"iprange" address range match support'
16 depends on NETFILTER_ADVANCED
17 --- a/net/netfilter/Makefile
18 +++ b/net/netfilter/Makefile
19 @@ -86,6 +86,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) +=
20 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
21 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
22 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
23 +obj-$(CONFIG_NETFILTER_XT_MATCH_ID) += xt_id.o
24 obj-$(CONFIG_NETFILTER_XT_MATCH_IPRANGE) += xt_iprange.o
25 obj-$(CONFIG_NETFILTER_XT_MATCH_IPVS) += xt_ipvs.o
26 obj-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += xt_length.o
28 +++ b/net/netfilter/xt_id.c
31 + * Implements a dummy match to allow attaching IDs to rules
33 + * 2014-08-01 Jo-Philipp Wich <jow@openwrt.org>
36 +#include <linux/module.h>
37 +#include <linux/skbuff.h>
38 +#include <linux/netfilter/x_tables.h>
39 +#include <linux/netfilter/xt_id.h>
41 +MODULE_AUTHOR("Jo-Philipp Wich <jow@openwrt.org>");
42 +MODULE_DESCRIPTION("Xtables: No-op match which can be tagged with a 32bit ID");
43 +MODULE_LICENSE("GPL");
44 +MODULE_ALIAS("ipt_id");
45 +MODULE_ALIAS("ip6t_id");
48 +id_mt(const struct sk_buff *skb, struct xt_action_param *par)
50 + /* We always match */
54 +static struct xt_match id_mt_reg __read_mostly = {
57 + .family = NFPROTO_UNSPEC,
59 + .matchsize = sizeof(struct xt_id_info),
63 +static int __init id_mt_init(void)
65 + return xt_register_match(&id_mt_reg);
68 +static void __exit id_mt_exit(void)
70 + xt_unregister_match(&id_mt_reg);
73 +module_init(id_mt_init);
74 +module_exit(id_mt_exit);
75 --- a/include/linux/netfilter/Kbuild
76 +++ b/include/linux/netfilter/Kbuild
77 @@ -47,6 +47,7 @@ header-y += xt_ecn.h
79 header-y += xt_hashlimit.h
80 header-y += xt_helper.h
82 header-y += xt_iprange.h
84 header-y += xt_layer7.h
86 +++ b/include/linux/netfilter/xt_id.h