src: add flowtable support
Pablo Neira Ayuso
maintainerPATCH 1/2 src: add flowtable support
This patch allows you to add, delete and list flowtable through the existing netlink interface.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- examples/Makefile.am | 12 + examples/nft-flowtable-add.c | 136 +++++++ examples/nft-flowtable-del.c | 122 ++++++ examples/nft-flowtable-get.c | 121 ++++++ include/libnftnl/Makefile.am | 1 + include/libnftnl/flowtable.h | 81 ++++ include/linux/netfilter/nf_tables.h | 53 +++ src/Makefile.am | 1 + src/flowtable.c | 793 ++++++++++++++++++++++++++++++++++++ src/libnftnl.map | 31 ++ 10 files changed, 1351 insertions(+) create mode 100644 examples/nft-flowtable-add.c create mode 100644 examples/nft-flowtable-del.c create mode 100644 examples/nft-flowtable-get.c create mode 100644 include/libnftnl/flowtable.h create mode 100644 src/flowtable.c
examples/Makefile.am +12 -0
@@ -25,6 +25,9 @@ check_PROGRAMS = nft-table-add \ nft-obj-add \ nft-obj-get \ nft-obj-del \ + nft-flowtable-add \ + nft-flowtable-del \ + nft-flowtable-get \ nft-ruleset-get \ nft-ruleset-parse-file \ nft-compat-get
@@ -104,6 +107,15 @@ nft_obj_del_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_obj_get_SOURCES = nft-obj-get.c nft_obj_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} +nft_flowtable_add_SOURCES = nft-flowtable-add.c +nft_flowtable_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_flowtable_del_SOURCES = nft-flowtable-del.c +nft_flowtable_del_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_flowtable_get_SOURCES = nft-flowtable-get.c +nft_flowtable_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + nft_ruleset_get_SOURCES = nft-ruleset-get.c nft_ruleset_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
examples/nft-flowtable-add.c new file +136 -0
136 lines not on this page · raw message
examples/nft-flowtable-del.c new file +122 -0
122 lines not on this page · raw message
examples/nft-flowtable-get.c new file +121 -0
121 lines not on this page · raw message
include/libnftnl/Makefile.am +1 -0
@@ -6,6 +6,7 @@ pkginclude_HEADERS = batch.h \ rule.h \ expr.h \ set.h \ + flowtable.h \ ruleset.h \ common.h \ udata.h \
include/libnftnl/flowtable.h new file +81 -0
81 lines not on this page · raw message
include/linux/netfilter/nf_tables.h +53 -0
71 lines not on this page · raw message
src/Makefile.am +1 -0
@@ -8,6 +8,7 @@ libnftnl_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libnftnl.map \ libnftnl_la_SOURCES = utils.c \ batch.c \ buffer.c \ + flowtable.c \ common.c \ gen.c \ table.c \
src/flowtable.c new file +793 -0
793 lines not on this page · raw message
src/libnftnl.map +31 -0
@@ -311,3 +311,34 @@ local: *; LIBNFTNL_6 { nftnl_expr_fprintf; } LIBNFTNL_5; + +LIBNFTNL_7 { + nftnl_flowtable_alloc; + nftnl_flowtable_free; + nftnl_flowtable_is_set; + nftnl_flowtable_unset; + nftnl_flowtable_set; + nftnl_flowtable_set_u32; + nftnl_flowtable_set_s32; + nftnl_flowtable_set_array; + nftnl_flowtable_set_str; + nftnl_flowtable_get; + nftnl_flowtable_get_u32; + nftnl_flowtable_get_s32; + nftnl_flowtable_get_array; + nftnl_flowtable_get_str; + nftnl_flowtable_parse; + nftnl_flowtable_parse_file; + nftnl_flowtable_snprintf; + nftnl_flowtable_fprintf; + nftnl_flowtable_nlmsg_build_payload; + nftnl_flowtable_nlmsg_parse; + nftnl_flowtable_list_alloc; + nftnl_flowtable_list_free; + nftnl_flowtable_list_is_empty; + nftnl_flowtable_list_add; + nftnl_flowtable_list_add_tail; + nftnl_flowtable_list_del; + nftnl_flowtable_list_foreach; + +} LIBNFTNL_6;
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/2 expr: add flow offload expression
This patch adds the new "flow_offload" expression to select what flows are offloaded to an existing flowtable.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- include/libnftnl/expr.h | 4 + include/linux/netfilter/nf_tables.h | 11 +++ src/Makefile.am | 1 + src/expr/flow_offload.c | 184 ++++++++++++++++++++++++++++++++++++ src/expr_ops.c | 2 + 5 files changed, 202 insertions(+) create mode 100644 src/expr/flow_offload.c
include/libnftnl/expr.h +4 -0
@@ -221,6 +221,10 @@ enum { };enum { +NFTNL_EXPR_FLOW_TABLE_NAME =NFTNL_EXPR_BASE , +}; + +enum {NFTNL_EXPR_FWD_SREG_DEV =NFTNL_EXPR_BASE , };
include/linux/netfilter/nf_tables.h +11 -0
@@ -952,6 +952,17 @@ enum nft_ct_attributes { };#define NFTA_CT_MAX (__NFTA_CT_MAX - 1) +/** +* enum nft_flow_attributes - ct offload expression attributes +* @NFTA_FLOW_TABLE_NAME: flow table name (NLA_STRING) +*/ +enum nft_offload_attributes { +NFTA_FLOW_UNSPEC , +NFTA_FLOW_TABLE_NAME , + __NFTA_FLOW_MAX, +}; +#define NFTA_FLOW_MAX (__NFTA_FLOW_MAX - 1) +enum nft_limit_type {NFT_LIMIT_PKTS ,NFT_LIMIT_PKT_BYTES
src/Makefile.am +1 -0
@@ -32,6 +32,7 @@ libnftnl_la_SOURCES = utils.c \ expr/data_reg.c \ expr/dup.c \ expr/exthdr.c \ + expr/flow_offload.c \ expr/fib.c \ expr/fwd.c \ expr/limit.c \
src/expr/flow_offload.c new file +184 -0
184 lines not on this page · raw message
src/expr_ops.c +2 -0
@@ -33,6 +33,7 @@ extern struct expr_ops expr_ops_target;extern struct expr_ops expr_ops_dynset;extern struct expr_ops expr_ops_hash;extern struct expr_ops expr_ops_fib; +extern struct expr_ops expr_ops_flow;static struct expr_ops expr_ops_notrack = { .name ="notrack" ,
@@ -69,6 +70,7 @@ static struct expr_ops *expr_ops[] = { &expr_ops_hash, &expr_ops_fib, &expr_ops_objref, + &expr_ops_flow, NULL, };
Signature · 1 line
2.11.0