[PATCH nft 2/2] intervals: check for EXPR_F_REMOVE in case of element mismatch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If auto-merge is disable and element to be deleted finds no exact
matching, then bail out.

Fixes: 3e8d934e4f72 ("intervals: support to partial deletion with automerge")
Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/intervals.c                     |  4 ++++
 tests/shell/testcases/sets/errors_0 | 20 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/intervals.c b/src/intervals.c
index c21b3ee0ad60..13009ca1b888 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -421,6 +421,10 @@ static int setelem_delete(struct list_head *msgs, struct set *set,
 			expr_error(msgs, i, "element does not exist");
 			err = -1;
 			goto err;
+		} else if (i->flags & EXPR_F_REMOVE) {
+			expr_error(msgs, i, "element does not exist");
+			err = -1;
+			goto err;
 		}
 		prev = NULL;
 	}
diff --git a/tests/shell/testcases/sets/errors_0 b/tests/shell/testcases/sets/errors_0
index 2960b694c67c..a676ac7331c8 100755
--- a/tests/shell/testcases/sets/errors_0
+++ b/tests/shell/testcases/sets/errors_0
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-set -e
-
 RULESET="table ip x {
 	set y {
 		type ipv4_addr
@@ -11,4 +9,22 @@ RULESET="table ip x {
 
 delete element ip x y { 2.3.4.5 }"
 
+$NFT -f - <<< $RULESET
+if [ $? -eq 0 ]
+then
+	exit 1
+fi
+
+RULESET="table ip x {
+        set y {
+                type ipv4_addr
+                flags interval
+        }
+}
+
+add element x y { 1.1.1.1/24 }
+delete element x y { 1.1.1.1/24 }
+add element x y { 1.1.1.1/24 }
+delete element x y { 2.2.2.2/24 }"
+
 $NFT -f - <<< $RULESET || exit 0
-- 
2.30.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux