Blame SOURCES/0018-rule-list-only-the-table-containing-object.patch

9ff721
From 48169840569b45e7695b125935bf30967f30b10c Mon Sep 17 00:00:00 2001
9ff721
From: Harsha Sharma <harshasharmaiitr@gmail.com>
9ff721
Date: Sun, 8 Jul 2018 12:41:03 +0200
9ff721
Subject: [PATCH] rule: list only the table containing object
9ff721
9ff721
For e.g.
9ff721
9ff721
 % nft list ct helper ip raw cthelp1
9ff721
 table ip filter {
9ff721
 }
9ff721
 table ip raw {
9ff721
	ct helper cthelp1 {
9ff721
		type "ftp" protocol tcp
9ff721
		l3proto ip
9ff721
	}
9ff721
 }
9ff721
9ff721
With this patch, print only table raw.
9ff721
9ff721
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
9ff721
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9ff721
(cherry picked from commit 88456a7ef011728a98c950447630f0a128dcad13)
9ff721
Signed-off-by: Phil Sutter <psutter@redhat.com>
9ff721
---
9ff721
 src/rule.c | 12 +++++-------
9ff721
 1 file changed, 5 insertions(+), 7 deletions(-)
9ff721
9ff721
diff --git a/src/rule.c b/src/rule.c
9ff721
index a157ac91683cc..3b5468d00e79c 100644
9ff721
--- a/src/rule.c
9ff721
+++ b/src/rule.c
9ff721
@@ -1593,15 +1593,13 @@ static int do_list_obj(struct netlink_ctx *ctx, struct cmd *cmd, uint32_t type)
9ff721
 		    cmd->handle.family != table->handle.family)
9ff721
 			continue;
9ff721
 
9ff721
-		nft_print(ctx->octx, "table %s %s {\n",
9ff721
-			  family2str(table->handle.family),
9ff721
-			  table->handle.table.name);
9ff721
-
9ff721
 		if (cmd->handle.table.name != NULL &&
9ff721
-		    strcmp(cmd->handle.table.name, table->handle.table.name)) {
9ff721
-			nft_print(ctx->octx, "}\n");
9ff721
+		    !strcmp(cmd->handle.table.name, table->handle.table.name)) {
9ff721
+			nft_print(ctx->octx, "table %s %s {\n",
9ff721
+				  family2str(table->handle.family),
9ff721
+				  cmd->handle.table.name);
9ff721
+		} else
9ff721
 			continue;
9ff721
-		}
9ff721
 
9ff721
 		list_for_each_entry(obj, &table->objs, list) {
9ff721
 			if (obj->type != type ||
9ff721
-- 
bacbc8
2.21.0
9ff721