src: add ct expectation support
PATCH 1/2 src: add ct expectation support
Add support for ct expectation objects, used to define specific expectations.
Signed-off-by Stéphane Veyret <[email protected]>
--- include/libnftnl/object.h | 7 + include/linux/netfilter/nf_tables.h | 13 +- include/obj.h | 7 + src/Makefile.am | 1 + src/obj/ct_expect.c | 193 ++++++++++++++++++++++++++++ src/object.c | 1 + 6 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 src/obj/ct_expect.c
include/libnftnl/object.h +7 -0
@@ -70,6 +70,13 @@ enum { NFTNL_OBJ_CT_TIMEOUT_ARRAY, }; +enum { +NFTNL_OBJ_CT_EXPECT_L3PROTO =NFTNL_OBJ_BASE , +NFTNL_OBJ_CT_EXPECT_L4PROTO , +NFTNL_OBJ_CT_EXPECT_DPORT , +NFTNL_OBJ_CT_EXPECT_TIMEOUT , +}; +enum {NFTNL_OBJ_LIMIT_RATE =NFTNL_OBJ_BASE ,NFTNL_OBJ_LIMIT_UNIT ,
include/linux/netfilter/nf_tables.h +12 -1
@@ -1429,6 +1429,16 @@ enum nft_ct_timeout_attributes { };#define NFTA_CT_TIMEOUT_MAX (__NFTA_CT_TIMEOUT_MAX - 1) +enum nft_ct_expectation_attributes { +NFTA_CT_EXPECT_UNSPEC , +NFTA_CT_EXPECT_L3PROTO , +NFTA_CT_EXPECT_L4PROTO , +NFTA_CT_EXPECT_DPORT , +NFTA_CT_EXPECT_TIMEOUT , + __NFTA_CT_EXPECT_MAX, +}; +#define NFTA_CT_EXPECT_MAX (__NFTA_CT_EXPECT_MAX - 1) +#define NFT_OBJECT_UNSPEC 0#define NFT_OBJECT_COUNTER 1#define NFT_OBJECT_QUOTA 2
@@ -1438,7 +1448,8 @@ enum nft_ct_timeout_attributes {#define NFT_OBJECT_TUNNEL 6#define NFT_OBJECT_CT_TIMEOUT 7#define NFT_OBJECT_SECMARK 8 -#define __NFT_OBJECT_MAX 9 +#define NFT_OBJECT_CT_EXPECT 9 +#define __NFT_OBJECT_MAX 10#define NFT_OBJECT_MAX (__NFT_OBJECT_MAX - 1)/**
include/obj.h +7 -0
@@ -42,6 +42,12 @@ struct nftnl_obj {uint8_t l4proto;uint32_t timeout[NFTNL_CTTIMEOUT_ARRAY_MAX ]; } ct_timeout; +struct nftnl_obj_ct_expect { +uint16_t l3proto; +uint8_t l4proto; +uint16_t dport; +uint32_t timeout; + } ct_expect;struct nftnl_obj_limit {uint64_t rate;uint64_t unit;
@@ -99,6 +105,7 @@ extern struct obj_ops obj_ops_counter;extern struct obj_ops obj_ops_quota;extern struct obj_ops obj_ops_ct_helper;extern struct obj_ops obj_ops_ct_timeout; +extern struct obj_ops obj_ops_ct_expect;extern struct obj_ops obj_ops_limit;extern struct obj_ops obj_ops_tunnel;extern struct obj_ops obj_ops_secmark;
src/Makefile.am +1 -0
@@ -65,4 +65,5 @@ libnftnl_la_SOURCES = utils.c \ obj/limit.c \ obj/ct_timeout.c \ obj/secmark.c \ + obj/ct_expect.c \ libnftnl.map
src/obj/ct_expect.c new file +193 -0
193 lines not on this page · raw message
src/object.c +1 -0
@@ -33,6 +33,7 @@ static struct obj_ops *obj_ops[__NFT_OBJECT_MAX] = { [NFT_OBJECT_TUNNEL] = &obj_ops_tunnel, [NFT_OBJECT_CT_TIMEOUT] = &obj_ops_ct_timeout, [NFT_OBJECT_SECMARK] = &obj_ops_secmark, + [NFT_OBJECT_CT_EXPECT] = &obj_ops_ct_expect, };static struct obj_ops *nftnl_obj_ops_lookup (uint32_t type)
Signature · 1 line
2.21.0
PATCH 2/2 examples: add ct expectation examples
Add examples for ct expectations.
Add, list and delete ct expectation objects from specified table. Add expectation object to rule.
Signed-off-by Stéphane Veyret <[email protected]>
--- examples/Makefile.am | 16 +++ examples/nft-ct-expectation-add.c | 154 +++++++++++++++++++++++ examples/nft-ct-expectation-del.c | 128 +++++++++++++++++++ examples/nft-ct-expectation-get.c | 144 ++++++++++++++++++++++ examples/nft-rule-ct-expectation-add.c | 163 +++++++++++++++++++++++++ 5 files changed, 605 insertions(+) create mode 100644 examples/nft-ct-expectation-add.c create mode 100644 examples/nft-ct-expectation-del.c create mode 100644 examples/nft-ct-expectation-get.c create mode 100644 examples/nft-rule-ct-expectation-add.c
examples/Makefile.am +16 -0
@@ -29,10 +29,14 @@ check_PROGRAMS = nft-table-add \ nft-flowtable-get \ nft-ruleset-get \ nft-compat-get \ + nft-ct-expectation-add \ + nft-ct-expectation-del \ + nft-ct-expectation-get \ nft-ct-helper-add \ nft-ct-helper-get \ nft-ct-helper-del \ nft-rule-ct-helper-add \ + nft-rule-ct-expectation-add \ nft-rule-ct-timeout-add nft_table_add_SOURCES = nft-table-add.c
@@ -122,6 +126,15 @@ nft_ruleset_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_compat_get_SOURCES = nft-compat-get.c nft_compat_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} +nft_ct_expectation_add_SOURCES = nft-ct-expectation-add.c +nft_ct_expectation_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_ct_expectation_del_SOURCES = nft-ct-expectation-del.c +nft_ct_expectation_del_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + +nft_ct_expectation_get_SOURCES = nft-ct-expectation-get.c +nft_ct_expectation_get_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + nft_ct_helper_add_SOURCES = nft-ct-helper-add.c nft_ct_helper_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
@@ -134,5 +147,8 @@ nft_ct_helper_del_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} nft_rule_ct_helper_add_SOURCES = nft-rule-ct-helper-add.c nft_rule_ct_helper_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} +nft_rule_ct_expectation_add_SOURCES = nft-rule-ct-expectation-add.c +nft_rule_ct_expectation_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS} + nft_rule_ct_timeout_add_SOURCES = nft-rule-ct-timeout-add.c nft_rule_ct_timeout_add_LDADD = ../src/libnftnl.la ${LIBMNL_LIBS}
examples/nft-ct-expectation-add.c new file +154 -0
154 lines not on this page · raw message
examples/nft-ct-expectation-del.c new file +128 -0
128 lines not on this page · raw message
examples/nft-ct-expectation-get.c new file +144 -0
144 lines not on this page · raw message
examples/nft-rule-ct-expectation-add.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
2.21.0