]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: fix "list set" unexpected behaviour
authorPablo M. Bermudo Garay <pablombg@gmail.com>
Wed, 1 Jun 2016 10:16:51 +0000 (12:16 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 1 Jun 2016 11:09:32 +0000 (13:09 +0200)
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
  ^^^^^^^^^^^^^^^^^^^^

Signed-off-by: Pablo M. Bermudo Garay <pablombg@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c

index 423523fe99dcf1671554c053a61e24dafc3b1f52..f24e5f3eabf5977d3d9cd22bfdfa22ba453c38ab 100644 (file)
@@ -2674,7 +2674,8 @@ 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_F_EVAL))
                        return cmd_error(ctx, "Could not process rule: Set '%s' does not exist",
                                         cmd->handle.set);
                return 0;