|
|
9ff721 |
From 4c211953b1e6290653fa3bb151b85be29d02288f Mon Sep 17 00:00:00 2001
|
|
|
9ff721 |
From: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
9ff721 |
Date: Wed, 10 Oct 2018 19:19:18 +0200
|
|
|
9ff721 |
Subject: [PATCH] segtree: set proper error cause on existing elements
|
|
|
9ff721 |
|
|
|
9ff721 |
Adding new elements result in a confusing "Success" error message.
|
|
|
9ff721 |
|
|
|
9ff721 |
# nft add element x y { 0-3 }
|
|
|
9ff721 |
[...]
|
|
|
9ff721 |
Error: Could not process rule: Success
|
|
|
9ff721 |
add element x y { 0-3 }
|
|
|
9ff721 |
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
9ff721 |
|
|
|
9ff721 |
after this patch, this reports:
|
|
|
9ff721 |
|
|
|
9ff721 |
Error: Could not process rule: File exists
|
|
|
9ff721 |
add element x y { 0-3 }
|
|
|
9ff721 |
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
9ff721 |
|
|
|
9ff721 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
9ff721 |
(cherry picked from commit 8ef0efb97006081e7f6054a950cb3614dd57729f)
|
|
|
9ff721 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
9ff721 |
---
|
|
|
9ff721 |
src/segtree.c | 2 ++
|
|
|
9ff721 |
1 file changed, 2 insertions(+)
|
|
|
9ff721 |
|
|
|
9ff721 |
diff --git a/src/segtree.c b/src/segtree.c
|
|
|
9ff721 |
index 4ee09884cbde6..5685618b3724a 100644
|
|
|
9ff721 |
--- a/src/segtree.c
|
|
|
9ff721 |
+++ b/src/segtree.c
|
|
|
9ff721 |
@@ -270,6 +270,7 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree,
|
|
|
9ff721 |
|
|
|
9ff721 |
return 0;
|
|
|
9ff721 |
err:
|
|
|
9ff721 |
+ errno = EEXIST;
|
|
|
9ff721 |
return expr_binary_error(msgs, lei->expr, new->expr,
|
|
|
9ff721 |
"conflicting intervals specified");
|
|
|
9ff721 |
}
|
|
|
9ff721 |
@@ -371,6 +372,7 @@ static int set_overlap(struct list_head *msgs, const struct set *set,
|
|
|
9ff721 |
|
|
|
9ff721 |
expr_error(msgs, new_intervals[i]->expr,
|
|
|
9ff721 |
"interval overlaps with an existing one");
|
|
|
9ff721 |
+ errno = EEXIST;
|
|
|
9ff721 |
ret = -1;
|
|
|
9ff721 |
goto out;
|
|
|
9ff721 |
}
|
|
|
9ff721 |
--
|
|
|
bacbc8 |
2.21.0
|
|
|
9ff721 |
|