summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2019-10-09 11:54:32 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-10-09 12:32:06 +0200
commita4ec053812610400b7a9e6c060d8b7589dedd5b1 (patch)
treebad46699b31fc8bdcbb52ba6d087863c6eabf7f5 /tests
parent998142c71d095d79488495ea545a704213fa0ba0 (diff)
segtree: always close interval in non-anonymous sets
Skip this optimization for non-anonymous sets, otherwise, element deletion breaks. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/shell/testcases/maps/0008interval_map_delete_032
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/shell/testcases/maps/0008interval_map_delete_0 b/tests/shell/testcases/maps/0008interval_map_delete_0
new file mode 100755
index 00000000..a43fd280
--- /dev/null
+++ b/tests/shell/testcases/maps/0008interval_map_delete_0
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -e
+
+EXPECTED="table ip filter {
+ map m {
+ type ipv4_addr : mark
+ flags interval
+ elements = { 127.0.0.2 : 0x00000002, 127.0.0.3 : 0x00000003 }
+ }
+
+ chain input {
+ type filter hook input priority filter; policy accept;
+ meta mark set ip daddr map @m
+ meta mark 0x00000002 counter accept
+ meta mark 0x00000003 counter accept
+ counter
+ }
+}"
+
+$NFT -f - <<< "$EXPECTED"
+$NFT delete element filter m { 127.0.0.2 }
+$NFT delete element filter m { 127.0.0.3 }
+$NFT add element filter m { 127.0.0.3 : 0x3 }
+$NFT add element filter m { 127.0.0.2 : 0x2 }
+
+GET=$($NFT list ruleset -s)
+if [ "$EXPECTED" != "$GET" ] ; then
+ DIFF="$(which diff)"
+ [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+ exit 1
+fi