From: Florian Westphal <fw@strlen.de>
To: netfilter-devel <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 2/3] netlink_linearize: fix timeout with map updates
Date: Mon, 12 Dec 2022 11:04:35 +0100 [thread overview]
Message-ID: <20221212100436.84116-3-fw@strlen.de> (raw)
In-Reply-To: <20221212100436.84116-1-fw@strlen.de>
Map updates can use timeouts, just like with sets, but the
linearization step did not pass this info to the kernel.
meta l4proto tcp update @pinned { ip saddr . ct original proto-src : ip daddr . ct original proto-dst timeout 90s
Listing this won't show the "timeout 90s" because kernel never saw it to
begin with.
NB: The above line attaches the timeout to the data element,
but there are no separate timeouts for the key and the value.
An alternative is to reject "key : value timeout X" from the parser
or evaluation step.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/netlink_linearize.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index c8bbcb7452b0..765b12263fa3 100644
--- a/src/netlink_linearize.c
+++ b/src/netlink_linearize.c
@@ -1520,6 +1520,13 @@ static void netlink_gen_map_stmt(struct netlink_linearize_ctx *ctx,
nftnl_expr_set_u32(nle, NFTNL_EXPR_DYNSET_SET_ID, set->handle.set_id);
nft_rule_add_expr(ctx, nle, &stmt->location);
+ if (stmt->map.key->timeout > 0)
+ nftnl_expr_set_u64(nle, NFTNL_EXPR_DYNSET_TIMEOUT,
+ stmt->map.key->timeout);
+ else if (stmt->map.data->timeout > 0)
+ nftnl_expr_set_u64(nle, NFTNL_EXPR_DYNSET_TIMEOUT,
+ stmt->map.data->timeout);
+
list_for_each_entry(this, &stmt->map.stmt_list, list)
num_stmts++;
--
2.38.1
next prev parent reply other threads:[~2022-12-12 10:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 10:04 [PATCH nft 0/3] fix map update with concatenation and timeouts Florian Westphal
2022-12-12 10:04 ` [PATCH nft 1/3] netlink_delinearize: fix decoding of concat data element Florian Westphal
2022-12-12 10:04 ` Florian Westphal [this message]
2022-12-12 13:35 ` [PATCH nft 2/3] netlink_linearize: fix timeout with map updates Pablo Neira Ayuso
2022-12-12 13:56 ` Florian Westphal
2022-12-12 10:04 ` [PATCH nft 3/3] tests: add a test case for map update from packet path with concat Florian Westphal
2022-12-12 13:38 ` [PATCH nft 0/3] fix map update with concatenation and timeouts Pablo Neira Ayuso
2022-12-12 16:42 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221212100436.84116-3-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).