Skip to contentSkip to conversation

evaluate: fix "list set" unexpected behaviour

PATCH Superseded Pablo M. Bermudo Garay 2 participants 3 messages Jun 1, 2016 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 evaluate: fix "list set" unexpected behaviour

Special sets like maps and flow tables have their own commands to be listed and inspected.

Before this patch, "nft list set" was able to display these special sets content:

  # nft list set filter test
  table ip filter {
          map test {
                  type ipv4_addr : inet_service
                  elements = { 192.168.1.101 : http-alt}
          }
  }

Now an error is shown:

  # nft list set filter test
  <cmdline>:1:1-20: Error: Could not process rule: Set 'test' does not exist
  list set filter test
  ^^^^^^^^^^^^^^^^^^^^
---
 src/evaluate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/evaluate.c +3 -1
index 423523f..86884a2 100644
@@ -2674,7 +2674,9 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)
 		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)
+		set = set_lookup(table, cmd->handle.set);
+		if (set == NULL || set->flags & SET_F_MAP ||
+		    set->flags & SET_F_EVAL)
 			return cmd_error(ctx, "Could not process rule: Set '%s' does not exist",
 					 cmd->handle.set);
 		return 0;
Signature · 1 line
2.8.3
#1 lore raw
Quoted 31 lines · Pablo M. Bermudo Garay

Special sets like maps and flow tables have their own commands to be listed and inspected.

Before this patch, "nft list set" was able to display these special sets content:

  # nft list set filter test
  table ip filter {
          map test {
                  type ipv4_addr : inet_service
                  elements = { 192.168.1.101 : http-alt}
          }
  }

Now an error is shown:

  # nft list set filter test
  <cmdline>:1:1-20: Error: Could not process rule: Set 'test' does not exist
  list set filter test
  ^^^^^^^^^^^^^^^^^^^^
---
 src/evaluate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/evaluate.c +0 -0
index 423523f..86884a2 100644

src/evaluate.c static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd) · line 2679

Quoted 7 lines
src/evaluate.c +3 -1
@@ -2674,7 +2674,9 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)
 		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)
+		set = set_lookup(table, cmd->handle.set);
+		if (set == NULL || set->flags & SET_F_MAP ||
+		    set->flags & SET_F_EVAL)

I'd suggest:

                    set == NULL && set->flags & (SET_F_EVAL | SET_F_MAP)
Quoted 6 lines
src/evaluate.c +0 -0
 			return cmd_error(ctx, "Could not process rule: Set '%s' does not exist",
 					 cmd->handle.set);
 		return 0;
Signature · 1 line
2.8.3
#2 lore raw

2016-06-01 11:20 GMT+02:00 Pablo Neira Ayuso <[email protected]>:

Quoted 3 lines

I'd suggest:

                    set == NULL && set->flags & (SET_F_EVAL | SET_F_MAP)

Oh, sure. Thank you for pointing that out.