Blame SOURCES/0003-monitor-Do-not-decompose-non-anonymous-sets.patch

911625
From 13bd961c3ba83e4189dcffdcf570c5a4391fd5f9 Mon Sep 17 00:00:00 2001
911625
From: Phil Sutter <psutter@redhat.com>
911625
Date: Fri, 10 Jan 2020 19:58:29 +0100
911625
Subject: [PATCH] monitor: Do not decompose non-anonymous sets
911625
911625
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1774742
911625
Upstream Status: nftables commit 5d57fa3e99bb9
911625
911625
commit 5d57fa3e99bb9f2044e236d4ddb7d874cfefe1dd
911625
Author: Phil Sutter <phil@nwl.cc>
911625
Date:   Thu Jan 9 13:34:20 2020 +0100
911625
911625
    monitor: Do not decompose non-anonymous sets
911625
911625
    They have been decomposed already, trying to do that again causes a
911625
    segfault. This is a similar fix as in commit 8ecb885589591 ("src:
911625
    restore --echo with anonymous sets").
911625
911625
    Signed-off-by: Phil Sutter <phil@nwl.cc>
911625
    Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
911625
---
911625
 src/monitor.c                          |  2 +-
911625
 tests/monitor/testcases/set-interval.t | 20 ++++++++++++++++++++
911625
 2 files changed, 21 insertions(+), 1 deletion(-)
911625
 create mode 100644 tests/monitor/testcases/set-interval.t
911625
911625
diff --git a/src/monitor.c b/src/monitor.c
911625
index ea0393c..0da9858 100644
911625
--- a/src/monitor.c
911625
+++ b/src/monitor.c
911625
@@ -500,7 +500,7 @@ static int netlink_events_obj_cb(const struct nlmsghdr *nlh, int type,
911625
 
911625
 static void rule_map_decompose_cb(struct set *s, void *data)
911625
 {
911625
-	if (s->flags & NFT_SET_INTERVAL)
911625
+	if (s->flags & (NFT_SET_INTERVAL & NFT_SET_ANONYMOUS))
911625
 		interval_map_decompose(s->init);
911625
 }
911625
 
911625
diff --git a/tests/monitor/testcases/set-interval.t b/tests/monitor/testcases/set-interval.t
911625
new file mode 100644
911625
index 0000000..59930c5
911625
--- /dev/null
911625
+++ b/tests/monitor/testcases/set-interval.t
911625
@@ -0,0 +1,20 @@
911625
+# setup first
911625
+I add table ip t
911625
+I add chain ip t c
911625
+O -
911625
+J {"add": {"table": {"family": "ip", "name": "t", "handle": 0}}}
911625
+J {"add": {"chain": {"family": "ip", "table": "t", "name": "c", "handle": 0}}}
911625
+
911625
+# add set with elements, monitor output expectedly differs
911625
+I add set ip t s { type inet_service; flags interval; elements = { 20, 30-40 }; }
911625
+O add set ip t s { type inet_service; flags interval; }
911625
+O add element ip t s { 20 }
911625
+O add element ip t s { 30-40 }
911625
+J {"add": {"set": {"family": "ip", "name": "s", "table": "t", "type": "inet_service", "handle": 0, "flags": ["interval"]}}}
911625
+J {"add": {"element": {"family": "ip", "table": "t", "name": "s", "elem": {"set": [20]}}}}
911625
+J {"add": {"element": {"family": "ip", "table": "t", "name": "s", "elem": {"set": [{"range": [30, 40]}]}}}}
911625
+
911625
+# this would crash nft
911625
+I add rule ip t c tcp dport @s
911625
+O -
911625
+J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"match": {"op": "==", "left": {"payload": {"protocol": "tcp", "field": "dport"}}, "right": "@s"}}]}}}
911625
-- 
8ff5ad
2.31.1
911625