]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: cover for large interval sets with create command
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 12 Jan 2026 10:51:50 +0000 (11:51 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 12 Jan 2026 11:57:57 +0000 (12:57 +0100)
commit 91dc281a82ea ("src: rework singleton interval transformation to
reduce memory consumption") duplicates singleton interval elements when
the netlink message gets full, this results in spurious EEXIST errors
when creating many elements in a set.

This patch extends the existing test to cover for this bug.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/maps/0004interval_map_create_once_0

index 7d3825596c4996e298a53d157d6c21e25c0c8260..30efc6f8a2e7fb97f25ac99d7115ac63c65de642 100755 (executable)
@@ -43,7 +43,7 @@ generate_test() {
 
 echo "add table x
 add map x y { type ipv4_addr : ipv4_addr; flags interval; }
-add element x y $(generate_add)" > $tmpfile
+create element x y $(generate_add)" > $tmpfile
 
 set -e
 $NFT -f $tmpfile
@@ -61,6 +61,24 @@ if [ "$EXPECTED" != "$GET" ] ; then
        exit 1
 fi
 
+$NFT flush ruleset
+
+# now try with add element command
+echo "add table x
+add map x y { type ipv4_addr : ipv4_addr; flags interval; }
+add element x y $(generate_add)" > $tmpfile
+
+set -e
+$NFT -f $tmpfile
+
+# same listing output is EXPECTED, no need to generate it again.
+
+GET=$($NFT list ruleset)
+if [ "$EXPECTED" != "$GET" ] ; then
+       $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+       exit 1
+fi
+
 if [ "$HOWMANY" != 63 ] ; then
        echo "Run a partial test due to NFT_TEST_SKIP_slow=y. Skip"
        exit 77