net: sched: add em_ipt ematch for calling xtables matches
Subsystems (3)
PATCH v3 1/1 net: sched: add em_ipt ematch for calling xtables matches
The commit a new tc ematch for using netfilter xtable matches.
This allows early classification as well as mirroning/redirecting traffic based on logic implemented in netfilter extensions.
Current supported use case is classification based on the incoming IPSec state used during decpsulation using the 'policy' iptables extension (xt_policy).
The module dynamically fetches the netfilter match module and calls it using a fake xt_action_param structure based on validated userspace provided parameters.
As the xt_policy match does not access skb->data, no skb modifications are needed on match.
---
v3:
- limit supported match to xt_policy and validate parameters
- receive match protocol from userspace
v2:
- Remove skb push/pull and limit functionality to ingress
--- include/uapi/linux/pkt_cls.h | 3 +- include/uapi/linux/tc_ematch/tc_em_ipt.h | 20 +++ net/sched/Kconfig | 12 ++ net/sched/Makefile | 1 + net/sched/em_ipt.c | 257 +++++++++++++++++++++++++++++++ 5 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 include/uapi/linux/tc_ematch/tc_em_ipt.h create mode 100644 net/sched/em_ipt.c
include/uapi/linux/pkt_cls.h +2 -1
@@ -555,7 +555,8 @@ enum {#define TCF_EM_VLAN 6#define TCF_EM_CANID 7#define TCF_EM_IPSET 8 -#define TCF_EM_MAX 8 +#define TCF_EM_IPT 9 +#define TCF_EM_MAX 9enum {TCF_EM_PROG_TC
include/uapi/linux/tc_ematch/tc_em_ipt.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_TC_EM_IPT_H +#define __LINUX_TC_EM_IPT_H + +#include <linux/types.h> +#include <linux/pkt_cls.h> + +enum { +TCA_EM_IPT_UNSPEC , +TCA_EM_IPT_HOOK , +TCA_EM_IPT_MATCH_NAME , +TCA_EM_IPT_MATCH_REVISION , +TCA_EM_IPT_NFPROTO , +TCA_EM_IPT_MATCH_DATA , + __TCA_EM_IPT_MAX +}; + +#define TCA_EM_IPT_MAX (__TCA_EM_IPT_MAX - 1) + +#endif
net/sched/Kconfig +12 -0
@@ -658,6 +658,18 @@ config NET_EMATCH_IPSET To compile this code as a module, choose M here: the module will be called em_ipset. +config NET_EMATCH_IPT + tristate "IPtables Matches" + depends on NET_EMATCH && NETFILTER && NETFILTER_XTABLES + ---help--- + Say Y here to be able to classify packets based on iptables + matches. + Current supported match is "policy" which allows packet classification + based on IPsec policy that was used during decapsulation + + To compile this code as a module, choose M here: the + module will be called em_ipt. + config NET_CLS_ACT bool "Actions" select NET_CLS
net/sched/Makefile +1 -0
@@ -75,3 +75,4 @@ 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 +obj-$(CONFIG_NET_EMATCH_IPT) += em_ipt.o
net/sched/em_ipt.c new file +257 -0
257 lines not on this page · raw message
Signature · 1 line
2.7.4
From: Eyal Birger <[email protected]>
Date: Thu, 15 Feb 2018 19:42:43 +0200
Quoted 9 lines
The commit a new tc ematch for using netfilter xtable matches.
This allows early classification as well as mirroning/redirecting traffic based on logic implemented in netfilter extensions.
Current supported use case is classification based on the incoming IPSec state used during decpsulation using the 'policy' iptables extension (
xt_policy).
Quoted 8 lines
The module dynamically fetches the netfilter match module and calls it using a fake
xt_action_paramstructure based on validated userspace provided parameters.As the
xt_policymatch does not accessskb->data, no skb modifications are needed on match.Signed-off-by Eyal Birger <[email protected]>
Applied, thank you.