]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: list only the table containing object
authorHarsha Sharma <harshasharmaiitr@gmail.com>
Sun, 8 Jul 2018 10:41:03 +0000 (12:41 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 10 Jul 2018 10:37:00 +0000 (12:37 +0200)
For e.g.

 % nft list ct helper ip raw cthelp1
 table ip filter {
 }
 table ip raw {
ct helper cthelp1 {
type "ftp" protocol tcp
l3proto ip
}
 }

With this patch, print only table raw.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index 0a1d6317a5147e4f412e80cb94ec49801fd4e379..7a7ac73b425bac1fac2357c6a984bec806dd1492 100644 (file)
@@ -1593,15 +1593,13 @@ static int do_list_obj(struct netlink_ctx *ctx, struct cmd *cmd, uint32_t type)
                    cmd->handle.family != table->handle.family)
                        continue;
 
-               nft_print(ctx->octx, "table %s %s {\n",
-                         family2str(table->handle.family),
-                         table->handle.table.name);
-
                if (cmd->handle.table.name != NULL &&
-                   strcmp(cmd->handle.table.name, table->handle.table.name)) {
-                       nft_print(ctx->octx, "}\n");
+                   !strcmp(cmd->handle.table.name, table->handle.table.name)) {
+                       nft_print(ctx->octx, "table %s %s {\n",
+                                 family2str(table->handle.family),
+                                 cmd->handle.table.name);
+               } else
                        continue;
-               }
 
                list_for_each_entry(obj, &table->objs, list) {
                        if (obj->type != type ||