]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
intervals: do not report exact overlaps for new elements
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 13 Jun 2022 15:22:47 +0000 (17:22 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 18 Jun 2022 22:55:20 +0000 (00:55 +0200)
Two new elements that represent an exact overlap should not trigger an error.

   add table t
   add set t s { type ipv4_addr; flags interval; }
   add element t s { 1.0.1.0/24 }
   ...
   add element t s { 1.0.1.0/24 }

result in a bogus error.

 # nft -f set.nft
 set.nft:1002:19-28: Error: conflicting intervals specified
 add element t s { 1.0.1.0/24 }
                   ^^^^^^^^^^

Fixes: 3da9643fb9ff ("intervals: add support to automerge with kernel elements")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/intervals.c
tests/shell/testcases/sets/exact_overlap_0 [new file with mode: 0755]

index bc414d6c87976e6d9f82709c6adca8458746f389..89f5c33d7a6ec4c9b3c17993342b659e55b29773 100644 (file)
@@ -540,8 +540,7 @@ static int setelem_overlap(struct list_head *msgs, struct set *set,
                }
 
                if (mpz_cmp(prev_range.low, range.low) == 0 &&
-                   mpz_cmp(prev_range.high, range.high) == 0 &&
-                   (elem->flags & EXPR_F_KERNEL || prev->flags & EXPR_F_KERNEL))
+                   mpz_cmp(prev_range.high, range.high) == 0)
                        goto next;
 
                if (mpz_cmp(prev_range.low, range.low) <= 0 &&
diff --git a/tests/shell/testcases/sets/exact_overlap_0 b/tests/shell/testcases/sets/exact_overlap_0
new file mode 100755 (executable)
index 0000000..1ce9304
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+RULESET="add table t
+add set t s { type ipv4_addr; flags interval; }
+add element t s { 1.0.1.0/24 }
+add element t s { 1.0.2.0/23 }
+add element t s { 1.0.8.0/21 }
+add element t s { 1.0.32.0/19 }
+add element t s { 1.1.0.0/24 }
+add element t s { 1.1.2.0/23 }
+add element t s { 1.1.4.0/22 }
+add element t s { 1.1.8.0/24 }
+add element t s { 1.1.9.0/24 }
+add element t s { 1.1.10.0/23 }
+add element t s { 1.1.12.0/22 }
+add element t s { 1.1.16.0/20 }
+add element t s { 1.1.32.0/19 }
+add element t s { 1.0.1.0/24 }"
+
+$NFT -f - <<< $RULESET || exit 1
+
+$NFT add element t s { 1.0.1.0/24 }