Skip to content

Commit d956798

Browse files
Jozsef Kadlecsikkaber
authored andcommitted
netfilter: xtables: "set" match and "SET" target support
The patch adds the combined module of the "SET" target and "set" match to netfilter. Both the previous and the current revisions are supported. Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent f830837 commit d956798

4 files changed

Lines changed: 427 additions & 0 deletions

File tree

‎include/linux/netfilter/xt_set.h‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#ifndef _XT_SET_H
2+
#define _XT_SET_H
3+
4+
#include <linux/netfilter/ipset/ip_set.h>
5+
6+
/* Revision 0 interface: backward compatible with netfilter/iptables */
7+
8+
/*
9+
* Option flags for kernel operations (xt_set_info_v0)
10+
*/
11+
#define IPSET_SRC 0x01 /* Source match/add */
12+
#define IPSET_DST 0x02 /* Destination match/add */
13+
#define IPSET_MATCH_INV 0x04 /* Inverse matching */
14+
15+
struct xt_set_info_v0 {
16+
ip_set_id_t index;
17+
union {
18+
__u32 flags[IPSET_DIM_MAX + 1];
19+
struct {
20+
__u32 __flags[IPSET_DIM_MAX];
21+
__u8 dim;
22+
__u8 flags;
23+
} compat;
24+
} u;
25+
};
26+
27+
/* match and target infos */
28+
struct xt_set_info_match_v0 {
29+
struct xt_set_info_v0 match_set;
30+
};
31+
32+
struct xt_set_info_target_v0 {
33+
struct xt_set_info_v0 add_set;
34+
struct xt_set_info_v0 del_set;
35+
};
36+
37+
/* Revision 1: current interface to netfilter/iptables */
38+
39+
struct xt_set_info {
40+
ip_set_id_t index;
41+
__u8 dim;
42+
__u8 flags;
43+
};
44+
45+
/* match and target infos */
46+
struct xt_set_info_match {
47+
struct xt_set_info match_set;
48+
};
49+
50+
struct xt_set_info_target {
51+
struct xt_set_info add_set;
52+
struct xt_set_info del_set;
53+
};
54+
55+
#endif /*_XT_SET_H*/

‎net/netfilter/Kconfig‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,18 @@ config NETFILTER_XT_CONNMARK
352352
ctmark), similarly to the packet mark (nfmark). Using this
353353
target and match, you can set and match on this mark.
354354

355+
config NETFILTER_XT_SET
356+
tristate 'set target and match support'
357+
depends on IP_SET
358+
depends on NETFILTER_ADVANCED
359+
help
360+
This option adds the "SET" target and "set" match.
361+
362+
Using this target and match, you can add/delete and match
363+
elements in the sets created by ipset(8).
364+
365+
To compile it as a module, choose M here. If unsure, say N.
366+
355367
# alphabetically ordered list of targets
356368

357369
comment "Xtables targets"

‎net/netfilter/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
4646
# combos
4747
obj-$(CONFIG_NETFILTER_XT_MARK) += xt_mark.o
4848
obj-$(CONFIG_NETFILTER_XT_CONNMARK) += xt_connmark.o
49+
obj-$(CONFIG_NETFILTER_XT_SET) += xt_set.o
4950

5051
# targets
5152
obj-$(CONFIG_NETFILTER_XT_TARGET_AUDIT) += xt_AUDIT.o

0 commit comments

Comments
 (0)