From 55a8685e18ed2f49142a8e2e9f9c79566cc29871 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 27 Jun 2023 14:12:53 +0200 Subject: tests: shell: cover refcount leak of mapping rhs Add a test to cover reference count leak in maps by adding twice same element, then flush. Reported-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- tests/shell/testcases/maps/0016map_leak_0 | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 tests/shell/testcases/maps/0016map_leak_0 diff --git a/tests/shell/testcases/maps/0016map_leak_0 b/tests/shell/testcases/maps/0016map_leak_0 new file mode 100755 index 00000000..e110ee4b --- /dev/null +++ b/tests/shell/testcases/maps/0016map_leak_0 @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e + +RULESET="table ip t { + map sourcemap { + type ipv4_addr : verdict + elements = { 100.123.10.2 : jump c } + } + + chain c { + } +}" + +$NFT -f - <<< "$RULESET" +# again, since it is addition, not creation, it is successful +$NFT -f - <<< "$RULESET" +# flush it to check for refcount leak +$NFT flush ruleset + +# +# again with stateful objects +# + +RULESET="table ip t { + counter c {} + + map sourcemap { + type ipv4_addr : counter + elements = { 100.123.10.2 : \"c\" } + } +}" + +$NFT -f - <<< "$RULESET" +# again, since it is addition, not creation, it is successful +$NFT -f - <<< "$RULESET" +# flush it to check for refcount leak +$NFT flush ruleset -- cgit v1.2.3