nftables/SOURCES/0018-rule-list-only-the-table-containing-object.patch
2021-10-08 14:03:04 +00:00

56 lines
1.5 KiB
Diff

From 48169840569b45e7695b125935bf30967f30b10c Mon Sep 17 00:00:00 2001
From: Harsha Sharma <harshasharmaiitr@gmail.com>
Date: Sun, 8 Jul 2018 12:41:03 +0200
Subject: [PATCH] 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>
(cherry picked from commit 88456a7ef011728a98c950447630f0a128dcad13)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
src/rule.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index a157ac91683cc..3b5468d00e79c 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 ||
--
2.19.0