Skip to content

Commit

Permalink
netfilter: xtables: "set" match and "SET" target support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jozsef Kadlecsik authored and Patrick McHardy committed Feb 1, 2011
1 parent f830837 commit d956798
Show file tree
Hide file tree
Showing 4 changed files with 427 additions and 0 deletions.
55 changes: 55 additions & 0 deletions include/linux/netfilter/xt_set.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef _XT_SET_H
#define _XT_SET_H

#include <linux/netfilter/ipset/ip_set.h>

/* Revision 0 interface: backward compatible with netfilter/iptables */

/*
* Option flags for kernel operations (xt_set_info_v0)
*/
#define IPSET_SRC 0x01 /* Source match/add */
#define IPSET_DST 0x02 /* Destination match/add */
#define IPSET_MATCH_INV 0x04 /* Inverse matching */

struct xt_set_info_v0 {
ip_set_id_t index;
union {
__u32 flags[IPSET_DIM_MAX + 1];
struct {
__u32 __flags[IPSET_DIM_MAX];
__u8 dim;
__u8 flags;
} compat;
} u;
};

/* match and target infos */
struct xt_set_info_match_v0 {
struct xt_set_info_v0 match_set;
};

struct xt_set_info_target_v0 {
struct xt_set_info_v0 add_set;
struct xt_set_info_v0 del_set;
};

/* Revision 1: current interface to netfilter/iptables */

struct xt_set_info {
ip_set_id_t index;
__u8 dim;
__u8 flags;
};

/* match and target infos */
struct xt_set_info_match {
struct xt_set_info match_set;
};

struct xt_set_info_target {
struct xt_set_info add_set;
struct xt_set_info del_set;
};

#endif /*_XT_SET_H*/
12 changes: 12 additions & 0 deletions net/netfilter/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@ config NETFILTER_XT_CONNMARK
ctmark), similarly to the packet mark (nfmark). Using this
target and match, you can set and match on this mark.

config NETFILTER_XT_SET
tristate 'set target and match support'
depends on IP_SET
depends on NETFILTER_ADVANCED
help
This option adds the "SET" target and "set" match.

Using this target and match, you can add/delete and match
elements in the sets created by ipset(8).

To compile it as a module, choose M here. If unsure, say N.

# alphabetically ordered list of targets

comment "Xtables targets"
Expand Down
1 change: 1 addition & 0 deletions net/netfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
# combos
obj-$(CONFIG_NETFILTER_XT_MARK) += xt_mark.o
obj-$(CONFIG_NETFILTER_XT_CONNMARK) += xt_connmark.o
obj-$(CONFIG_NETFILTER_XT_SET) += xt_set.o

# targets
obj-$(CONFIG_NETFILTER_XT_TARGET_AUDIT) += xt_AUDIT.o
Expand Down
Loading

0 comments on commit d956798

Please sign in to comment.