summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorHarsha Sharma <harshasharmaiitr@gmail.com>2018-07-08 12:41:03 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-07-10 12:37:00 +0200
commit88456a7ef011728a98c950447630f0a128dcad13 (patch)
tree173871e07788a14245e5d10e8760847c1b812301 /src/rule.c
parent0e9cb91294f8015d91413a0dd00bd5c2b78842b2 (diff)
rule: list only the table containing object
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>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/rule.c b/src/rule.c
index 0a1d6317..7a7ac73b 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -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 ||