]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: Allow list stateful objects in a table
authorElise Lennion <elise.lennion@gmail.com>
Thu, 26 Jan 2017 17:15:44 +0000 (15:15 -0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 27 Jan 2017 12:33:20 +0000 (13:33 +0100)
Currently, stateful objects can be listed by: listing all objects in
all tables; listing a single object in a table. Now it's allowed to
list all objects in a table.

$ nft list counters table filter
table ip filter {
counter https-traffic {
packets 14825 bytes 950063
}
counter http-traffic {
packets 117 bytes 9340
}
}

$ nft list quotas table filter
table ip filter {
quota https-quota {
25 mbytes used 2 mbytes
}
quota http-quota {
25 mbytes used 10 kbytes
}
}

Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c
src/parser_bison.y

index ed41bd8a38b21eaedf5694a653b9cc3e02f8c0d2..379f9d7024755c0ebe05961a2a6a349c6a6e6830 100644 (file)
@@ -2950,10 +2950,16 @@ static int cmd_evaluate_list(struct eval_ctx *ctx, struct cmd *cmd)
                        return cmd_error(ctx, "Could not process rule: Object '%s' does not exist",
                                         cmd->handle.obj);
                return 0;
-       case CMD_OBJ_CHAINS:
-       case CMD_OBJ_SETS:
        case CMD_OBJ_COUNTERS:
        case CMD_OBJ_QUOTAS:
+               if (cmd->handle.table == NULL)
+                       return 0;
+               if (table_lookup(&cmd->handle) == NULL)
+                       return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
+                                        cmd->handle.table);
+               return 0;
+       case CMD_OBJ_CHAINS:
+       case CMD_OBJ_SETS:
        case CMD_OBJ_RULESET:
        case CMD_OBJ_FLOWTABLES:
        case CMD_OBJ_MAPS:
index a1b8b088cb40d25dd9b4c34cf90ff9101b48be42..d543e3ea2515c2074131e1a7d64e7ce4303d30eb 100644 (file)
@@ -932,6 +932,10 @@ list_cmd           :       TABLE           table_spec
                        {
                                $$ = cmd_alloc(CMD_LIST, CMD_OBJ_COUNTERS, &$2, &@$, NULL);
                        }
+                       |       COUNTERS        TABLE   table_spec
+                       {
+                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_COUNTERS, &$3, &@$, NULL);
+                       }
                        |       COUNTER         obj_spec
                        {
                                $$ = cmd_alloc(CMD_LIST, CMD_OBJ_COUNTER, &$2, &@$, NULL);
@@ -940,6 +944,10 @@ list_cmd           :       TABLE           table_spec
                        {
                                $$ = cmd_alloc(CMD_LIST, CMD_OBJ_QUOTAS, &$2, &@$, NULL);
                        }
+                       |       QUOTAS          TABLE   table_spec
+                       {
+                               $$ = cmd_alloc(CMD_LIST, CMD_OBJ_QUOTAS, &$3, &@$, NULL);
+                       }
                        |       QUOTA           obj_spec
                        {
                                $$ = cmd_alloc(CMD_LIST, CMD_OBJ_QUOTA, &$2, &@$, NULL);