Skip to contentSkip to conversation

rule: filter out tables depending on family

PATCH New Pablo Neira Ayuso 1 participant 2 messages Sep 22, 2015 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/2 rule: filter out tables depending on family

 # nft list tables ip
 table ip filter
 # nft list tables ip6
 table ip6 filter
---
 src/rule.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/rule.c +6 -1
index 43cc4a8..92b83f0 100644
@@ -1013,10 +1013,15 @@ static int do_list_tables(struct netlink_ctx *ctx, struct cmd *cmd)
 {
 	struct table *table;
 
-	list_for_each_entry(table, &table_list, list)
+	list_for_each_entry(table, &table_list, list) {
+		if (cmd->handle.family != NFPROTO_UNSPEC &&
+		    cmd->handle.family != table->handle.family)
+			continue;
+
 		printf("table %s %s\n",
 		       family2str(table->handle.family),
 		       table->handle.table);
+	}
 
 	return 0;
 }
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH 2/2 parser: show all tables via list tables with no family

Default to the same behaviour that we get through `list ruleset', ie.

 # nft list tables
 table ip filter
 table ip6 filter
 # nft list tables ip
 table ip filter
 # nft list tables ip6
 table ip6 filter
---
 src/parser_bison.y |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/parser_bison.y +1 -1
index 385e214..36910a7 100644
@@ -767,7 +767,7 @@ list_cmd		:	TABLE		table_spec
 			{
 				$$ = cmd_alloc(CMD_LIST, CMD_OBJ_TABLE, &$2, &@$, NULL);
 			}
-			|	TABLES		tables_spec
+			|	TABLES		ruleset_spec
 			{
 				$$ = cmd_alloc(CMD_LIST, CMD_OBJ_TABLE, &$2, &@$, NULL);
 			}
Signature · 1 line
1.7.10.4