net: sched: add ipset ematch
Subsystems (3)
PATCH 1/1 net: sched: add ipset ematch
Can be used to match packets against netfilter ip sets created via ipset(8). skb->sk_iif is used as 'incoming interface', skb->dev is 'outgoing interface'.
Since ipset is usually called from netfilter, the ematch initializes a fake xt_action_param, pulls the ip header into the linear area and also sets skb->data to the IP header (otherwise matching Layer 4 set types doesn't work).
--- include/linux/pkt_cls.h | 3 +- net/sched/Kconfig | 10 ++++ net/sched/Makefile | 1 + net/sched/em_ipset.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 1 deletions(-) create mode 100644 net/sched/em_ipset.c
include/linux/pkt_cls.h +2 -1
@@ -453,7 +453,8 @@ enum {#define TCF_EM_TEXT 5#define TCF_EM_VLAN 6#define TCF_EM_CANID 7 -#define TCF_EM_MAX 7 +#define TCF_EM_IPSET 8 +#define TCF_EM_MAX 8enum {TCF_EM_PROG_TC
net/sched/Kconfig +10 -0
@@ -517,6 +517,16 @@ config NET_EMATCH_CANID To compile this code as a module, choose M here: the module will be called em_canid. +config NET_EMATCH_IPSET + tristate "IPset" + depends on NET_EMATCH && IP_SET + ---help--- + Say Y here if you want to be able to classify packets based on + ipset membership. + + To compile this code as a module, choose M here: the + module will be called em_ipset. + config NET_CLS_ACT bool "Actions" ---help---
net/sched/Makefile +1 -0
@@ -56,3 +56,4 @@ obj-$(CONFIG_NET_EMATCH_U32) += em_u32.o obj-$(CONFIG_NET_EMATCH_META) += em_meta.o obj-$(CONFIG_NET_EMATCH_TEXT) += em_text.o obj-$(CONFIG_NET_EMATCH_CANID) += em_canid.o +obj-$(CONFIG_NET_EMATCH_IPSET) += em_ipset.o
net/sched/em_ipset.c new file +135 -0
135 lines not on this page · raw message
Signature · 1 line
1.7.3.4
From: Florian Westphal <[email protected]>
Date: Wed, 11 Jul 2012 22:56:57 +0200
Quoted 10 lines
Can be used to match packets against netfilter ip sets created via ipset(8).
skb->sk_iifis used as 'incoming interface',skb->devis 'outgoing interface'.Since ipset is usually called from netfilter, the ematch initializes a fake
xt_action_param, pulls the ip header into the linear area and also setsskb->datato the IP header (otherwise matching Layer 4 set types doesn't work).Tested-by Mr Dash Four <[email protected]>Signed-off-by Florian Westphal <[email protected]>
Applied, thanks.