Blame SOURCES/0023-netlink_linearize-fix-timeout-with-map-updates.patch

1d03cd
From 7cb1f51b1791434fa513b516e416a18d27ad1eb9 Mon Sep 17 00:00:00 2001
1d03cd
From: Phil Sutter <psutter@redhat.com>
1d03cd
Date: Fri, 17 Feb 2023 17:52:16 +0100
1d03cd
Subject: [PATCH] netlink_linearize: fix timeout with map updates
1d03cd
1d03cd
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094894
1d03cd
Upstream Status: nftables commit 284c038ef4c69
1d03cd
1d03cd
commit 284c038ef4c69d042ef91272d90c143019ecea1f
1d03cd
Author: Florian Westphal <fw@strlen.de>
1d03cd
Date:   Mon Dec 12 11:04:35 2022 +0100
1d03cd
1d03cd
    netlink_linearize: fix timeout with map updates
1d03cd
1d03cd
    Map updates can use timeouts, just like with sets, but the
1d03cd
    linearization step did not pass this info to the kernel.
1d03cd
1d03cd
    meta l4proto tcp update @pinned { ip saddr . ct original proto-src timeout 90s : ip daddr . tcp dport
1d03cd
1d03cd
    Listing this won't show the "timeout 90s" because kernel never saw it to
1d03cd
    begin with.
1d03cd
1d03cd
    Also update evaluation step to reject a timeout that was set on
1d03cd
    the data part: Timeouts are only allowed for the key-value pair
1d03cd
    as a whole.
1d03cd
1d03cd
    Signed-off-by: Florian Westphal <fw@strlen.de>
1d03cd
1d03cd
Signed-off-by: Phil Sutter <psutter@redhat.com>
1d03cd
---
1d03cd
 src/evaluate.c          | 3 +++
1d03cd
 src/netlink_linearize.c | 4 ++++
1d03cd
 2 files changed, 7 insertions(+)
1d03cd
1d03cd
diff --git a/src/evaluate.c b/src/evaluate.c
1d03cd
index 7f81411..6d0a0f5 100644
1d03cd
--- a/src/evaluate.c
1d03cd
+++ b/src/evaluate.c
1d03cd
@@ -3858,6 +3858,9 @@ static int stmt_evaluate_map(struct eval_ctx *ctx, struct stmt *stmt)
1d03cd
 	if (stmt->map.data->comment != NULL)
1d03cd
 		return expr_error(ctx->msgs, stmt->map.data,
1d03cd
 				  "Data expression comments are not supported");
1d03cd
+	if (stmt->map.data->timeout > 0)
1d03cd
+		return expr_error(ctx->msgs, stmt->map.data,
1d03cd
+				  "Data expression timeouts are not supported");
1d03cd
 
1d03cd
 	list_for_each_entry(this, &stmt->map.stmt_list, list) {
1d03cd
 		if (stmt_evaluate(ctx, this) < 0)
1d03cd
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
1d03cd
index c8bbcb7..6de0a96 100644
1d03cd
--- a/src/netlink_linearize.c
1d03cd
+++ b/src/netlink_linearize.c
1d03cd
@@ -1520,6 +1520,10 @@ static void netlink_gen_map_stmt(struct netlink_linearize_ctx *ctx,
1d03cd
 	nftnl_expr_set_u32(nle, NFTNL_EXPR_DYNSET_SET_ID, set->handle.set_id);
1d03cd
 	nft_rule_add_expr(ctx, nle, &stmt->location);
1d03cd
 
1d03cd
+	if (stmt->map.key->timeout > 0)
1d03cd
+		nftnl_expr_set_u64(nle, NFTNL_EXPR_DYNSET_TIMEOUT,
1d03cd
+				   stmt->map.key->timeout);
1d03cd
+
1d03cd
 	list_for_each_entry(this, &stmt->map.stmt_list, list)
1d03cd
 		num_stmts++;
1d03cd
 
1d03cd
-- 
1d03cd
2.39.2
1d03cd