[PATCH nft 4/7] evaluate: check if set exists before listing it

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

 



After this patch, we obtain:

 # nft list set ip6 test pepe
 <cmdline>:1:1-22: Error: Could not process rule: Set 'foo' does not exist
 list set ip6 test foo
 ^^^^^^^^^^^^^^^^^^^^^

So we get things aligned with table and chain listing commands.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/evaluate.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index 9762586..4f9299e 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -2091,10 +2091,20 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)
 	case CMD_OBJ_TABLE:
 		if (cmd->handle.table == NULL)
 			return 0;
+
+		table = table_lookup(&cmd->handle);
+		if (table == NULL)
+			return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
+					 cmd->handle.table);
+		return 0;
 	case CMD_OBJ_SET:
-		if (table_lookup(&cmd->handle) == NULL)
+		table = table_lookup(&cmd->handle);
+		if (table == NULL)
 			return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
 					 cmd->handle.table);
+		if (set_lookup(table, cmd->handle.set) == NULL)
+			return cmd_error(ctx, "Could not process rule: Set '%s' does not exist",
+					 cmd->handle.set);
 		return 0;
 	case CMD_OBJ_CHAIN:
 		table = table_lookup(&cmd->handle);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux