]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
nftables: Fix list of sets by family
authorAna Rey <anarey@gmail.com>
Fri, 28 Mar 2014 12:30:27 +0000 (12:30 +0000)
committerPatrick McHardy <kaber@trash.net>
Fri, 28 Mar 2014 12:30:27 +0000 (12:30 +0000)
Fix the result of command line 'nft list sets FAMILY'. It shows the
following error message:

"Error: syntax error, unexpected end of file, expecting string"

Now, it is possible shows right this information:

$ sudo nft -nna list sets ip
        set set_test {
                type ipv4_address
                elements = { 192.168.3.45, 192.168.3.43, 192.168.3.42, 192.168.3.4}
        }
set set_test2 {
                type ipv4_address
                elements = { 192.168.3.43, 192.168.3.42, 192.168.3.4}
        }
set set0 {
                type ipv4_address
                flags constant
                elements = { 127.0.0.12, 12.11.11.11}
        }

Signed-off-by: Ana Rey <anarey@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
src/parser.y
src/rule.c

index db6f493313ca55a0effb43b72b4abf38d8453c92..af348578298ebc5c9f8ece6b0886dd60698b1320 100644 (file)
@@ -719,7 +719,7 @@ list_cmd            :       TABLE           table_spec
                        {
                                $$ = cmd_alloc(CMD_LIST, CMD_OBJ_CHAIN, &$2, &@$, NULL);
                        }
-                       |       SETS            table_spec
+                       |       SETS            tables_spec
                        {
                                $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SETS, &$2, &@$, NULL);
                        }
index b71904013d8ac4046a2e6421dc5cece3718d90f1..00dedf547108f73d4902efc2fa50bc84bb1d7d3c 100644 (file)
@@ -668,8 +668,12 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd)
        case CMD_OBJ_SETS:
                if (netlink_list_sets(ctx, &cmd->handle, &cmd->location) < 0)
                        return -1;
-               list_for_each_entry_safe(set, nset, &ctx->list, list)
-                       list_move_tail(&set->list, &table->sets);
+               list_for_each_entry(set, &ctx->list, list){
+                       if (netlink_get_setelems(ctx, &set->handle,
+                                                &cmd->location, set) < 0)
+                               return -1;
+                       set_print(set);
+               }
                break;
        case CMD_OBJ_SET:
                if (netlink_get_set(ctx, &cmd->handle, &cmd->location) < 0)