diff mbox series

[nft] ct: Add support for the 'id' key

Message ID 20200501175535.4674-1-brett.mastbergen@gmail.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nft] ct: Add support for the 'id' key | expand

Commit Message

Brett Mastbergen May 1, 2020, 5:55 p.m. UTC
The 'id' key allows for matching on the id of the conntrack entry.

v2: Remove ct_id_type

Signed-off-by: Brett Mastbergen <brett.mastbergen@gmail.com>
---
 doc/payload-expression.txt | 5 ++++-
 src/ct.c                   | 2 ++
 src/parser_bison.y         | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

Comments

Pablo Neira Ayuso May 1, 2020, 6:59 p.m. UTC | #1
On Fri, May 01, 2020 at 01:55:35PM -0400, Brett Mastbergen wrote:
> The 'id' key allows for matching on the id of the conntrack entry.

Applied, thanks Brett.
diff mbox series

Patch

diff --git a/doc/payload-expression.txt b/doc/payload-expression.txt
index 4bbf8d05..e6f108b1 100644
--- a/doc/payload-expression.txt
+++ b/doc/payload-expression.txt
@@ -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.
 
diff --git a/src/ct.c b/src/ct.c
index db1dabd3..0842c838 100644
--- a/src/ct.c
+++ b/src/ct.c
@@ -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,
diff --git a/src/parser_bison.y b/src/parser_bison.y
index b1e869d5..3cd0559b 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -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
 			;