Skip to contentSkip to conversation

ct: Add support for the 'id' key

PATCH Applied Brett Mastbergen 2 participants 2 messages May 1, 2020 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ct: Add support for the 'id' key

The 'id' key allows for matching on the id of the conntrack entry.

v2: Remove ct_id_type

---
 doc/payload-expression.txt | 5 ++++-
 src/ct.c                   | 2 ++
 src/parser_bison.y         | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)
doc/payload-expression.txt +4 -1
index 4bbf8d05..e6f108b1 100644
@@ -638,7 +638,7 @@ zone id is tied to the given direction. +
 
 [verse]
 *ct* {*state* | *direction* | *status* | *mark* | *expiration* | *helper* | *label*}
-*ct* [*original* | *reply*] {*l3proto* | *protocol* | *bytes* | *packets* | *avgpkt* | *zone*}
+*ct* [*original* | *reply*] {*l3proto* | *protocol* | *bytes* | *packets* | *avgpkt* | *zone* | *id*}
 *ct* {*original* | *reply*} {*proto-src* | *proto-dst*}
 *ct* {*original* | *reply*} {*ip* | *ip6*} {*saddr* | *daddr*}
 
@@ -700,6 +700,9 @@ integer (16 bit)
 |count|
 count number of connections
 integer (32 bit)
+|id|
+Connection id
+ct_id
 |==========================================
 A description of conntrack-specific types listed above can be found sub-section CONNTRACK TYPES above.
 
src/ct.c +2 -0
index db1dabd3..0842c838 100644
@@ -301,6 +301,8 @@ const struct ct_template ct_templates[__NFT_CT_MAX] = {
 					      BYTEORDER_BIG_ENDIAN, 128),
 	[NFT_CT_SECMARK]	= CT_TEMPLATE("secmark", &integer_type,
 					      BYTEORDER_HOST_ENDIAN, 32),
+	[NFT_CT_ID]		= CT_TEMPLATE("id", &integer_type,
+					      BYTEORDER_BIG_ENDIAN, 32),
 };
 
 static void ct_print(enum nft_ct_keys key, int8_t dir, uint8_t nfproto,
src/parser_bison.y +1 -0
index b1e869d5..3cd0559b 100644
@@ -4550,6 +4550,7 @@ ct_key			:	L3PROTOCOL	{ $$ = NFT_CT_L3PROTOCOL; }
 			|	LABEL		{ $$ = NFT_CT_LABELS; }
 			|	EVENT		{ $$ = NFT_CT_EVENTMASK; }
 			|	SECMARK		{ $$ = NFT_CT_SECMARK; }
+			|	ID	 	{ $$ = NFT_CT_ID; }
 			|	ct_key_dir_optional
 			;
 
Signature · 1 line
2.11.0
maintainer Applied
#1 lore raw
Quoted 1 line · Brett Mastbergen

The 'id' key allows for matching on the id of the conntrack entry.

Applied, thanks Brett.