summaryrefslogtreecommitdiffstats
path: root/iptables/nft.c
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2018-04-07 00:44:49 +0200
committerFlorian Westphal <fw@strlen.de>2018-04-09 22:53:09 +0200
commit9d9b724cab2276a1ffa43e8376f2ed10282d07da (patch)
tree331175080abfab6cdbdecd23f3484620e75577f0 /iptables/nft.c
parent59d15cfb8998074b2f6077fb5a4a5aea6a002bc7 (diff)
xtables-compat: skip unsupported tables
Instead of not listing anything at all if an unknown table name exists, just skip them. Output a small comment that the listing doesn't include the (unrecognized, nft-created) tables. Next patch will restrict 'is this table printable in xtables syntax' check to the "builtin" tables. Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/nft.c')
-rw-r--r--iptables/nft.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/iptables/nft.c b/iptables/nft.c
index a73c72bd..7c1e19d6 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -2842,49 +2842,16 @@ next:
return ret;
}
-static int nft_is_table_compatible(const char *name)
+bool nft_is_table_compatible(struct nft_handle *h, const char *name)
{
int i;
for (i = 0; i < TABLES_MAX; i++) {
- if (strcmp(xtables_ipv4[i].name, name) == 0)
- return 0;
- }
-
- return 1;
-}
-
-static int nft_are_tables_compatible(struct nft_handle *h)
-{
- struct nftnl_table_list *list;
- struct nftnl_table_list_iter *iter;
- struct nftnl_table *table;
- int ret = 0;
-
- list = nftnl_table_list_get(h);
- if (list == NULL)
- return -1;
-
- iter = nftnl_table_list_iter_create(list);
- if (iter == NULL)
- return -1;
-
- table = nftnl_table_list_iter_next(iter);
- while (table != NULL) {
- const char *name = nftnl_table_get(table, NFTNL_TABLE_NAME);
-
- if (nft_is_table_compatible(name) == 0) {
- table = nftnl_table_list_iter_next(iter);
- continue;
- }
-
- ret = 1;
- break;
+ if (strcmp(h->tables[i].name, name) == 0)
+ return true;
}
- nftnl_table_list_iter_destroy(iter);
- nftnl_table_list_free(list);
- return ret;
+ return false;
}
int nft_is_ruleset_compatible(struct nft_handle *h)
@@ -2895,10 +2862,6 @@ int nft_is_ruleset_compatible(struct nft_handle *h)
struct nftnl_rule *rule;
int ret = 0;
- ret = nft_are_tables_compatible(h);
- if (ret != 0)
- return ret;
-
ret = nft_are_chains_compatible(h);
if (ret != 0)
return ret;