Skip to contentSkip to conversation

expr: add forward expression

PATCH New Pablo Neira Ayuso 1 participant 1 message Jan 11, 2016 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 expr: add forward expression

Add forward expression for the netdev family.

---
 include/libnftnl/expr.h             |   4 +
 include/linux/netfilter/nf_tables.h |  12 +++
 src/Makefile.am                     |   1 +
 src/expr/fwd.c                      | 187 ++++++++++++++++++++++++++++++++++++
 src/expr_ops.c                      |   2 +
 tests/Makefile.am                   |   4 +
 tests/nft-expr_fwd-test.c           |  90 +++++++++++++++++
 7 files changed, 300 insertions(+)
 create mode 100644 src/expr/fwd.c
 create mode 100644 tests/nft-expr_fwd-test.c
include/libnftnl/expr.h +4 -0
index ab2c5ba..7093759 100644
@@ -183,6 +183,10 @@ enum {
 	NFTNL_EXPR_DUP_SREG_DEV,
 };
 
+enum {
+	NFTNL_EXPR_FWD_SREG_DEV = NFTNL_EXPR_BASE,
+};
+
 /*
  * Compat
  */
include/linux/netfilter/nf_tables.h +12 -0
index f77693b..27baeca 100644
@@ -978,6 +978,18 @@ enum nft_dup_attributes {
 #define NFTA_DUP_MAX		(__NFTA_DUP_MAX - 1)
 
 /**
+ * enum nft_fwd_attributes - nf_tables fwd expression netlink attributes
+ *
+ * @NFTA_FWD_SREG_DEV: output interface name (NLA_U32: nft_register)
+ */
+enum nft_fwd_attributes {
+	NFTA_FWD_UNSPEC,
+	NFTA_FWD_SREG_DEV,
+	__NFTA_FWD_MAX
+};
+#define NFTA_FWD_MAX	(__NFTA_FWD_MAX - 1)
+
+/**
  * enum nft_gen_attributes - nf_tables ruleset generation attributes
  *
  * @NFTA_GEN_ID: Ruleset generation ID (NLA_U32)
src/Makefile.am +1 -0
index 795307d..a27e292 100644
@@ -29,6 +29,7 @@ libnftnl_la_SOURCES = utils.c		\
 		      expr/data_reg.c	\
 		      expr/dup.c	\
 		      expr/exthdr.c	\
+		      expr/fwd.c	\
 		      expr/limit.c	\
 		      expr/log.c	\
 		      expr/lookup.c	\
src/expr/fwd.c new file +187 -0

187 lines not on this page · raw message

src/expr_ops.c +2 -0
index bfb3ba2..ae515af 100644
@@ -11,6 +11,7 @@ extern struct expr_ops expr_ops_counter;
 extern struct expr_ops expr_ops_ct;
 extern struct expr_ops expr_ops_dup;
 extern struct expr_ops expr_ops_exthdr;
+extern struct expr_ops expr_ops_fwd;
 extern struct expr_ops expr_ops_immediate;
 extern struct expr_ops expr_ops_limit;
 extern struct expr_ops expr_ops_log;
@@ -34,6 +35,7 @@ static struct expr_ops *expr_ops[] = {
 	&expr_ops_ct,
 	&expr_ops_dup,
 	&expr_ops_exthdr,
+	&expr_ops_fwd,
 	&expr_ops_immediate,
 	&expr_ops_limit,
 	&expr_ops_log,
tests/Makefile.am +4 -0
index 51403e5..c246034 100644
@@ -15,6 +15,7 @@ check_PROGRAMS = 	nft-parsing-test		\
 			nft-expr_cmp-test		\
 			nft-expr_ct-test		\
 			nft-expr_dup-test		\
+			nft-expr_fwd-test		\
 			nft-expr_exthdr-test		\
 			nft-expr_immediate-test		\
 			nft-expr_limit-test		\
@@ -66,6 +67,9 @@ nft_expr_ct_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
 nft_expr_dup_test_SOURCES = nft-expr_dup-test.c
 nft_expr_dup_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
 
+nft_expr_fwd_test_SOURCES = nft-expr_fwd-test.c
+nft_expr_fwd_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
+
 nft_expr_immediate_test_SOURCES = nft-expr_counter-test.c
 nft_expr_immediate_test_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
 
tests/nft-expr_fwd-test.c new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.1.4