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

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