xtables: initialize xtables defaults even on listing rules
Output of the tool should be the same as for iptables.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
diff --git a/iptables/nft.c b/iptables/nft.c
index e55c18c..7e1b47b 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -2483,6 +2483,10 @@
struct nft_chain_list_iter *iter;
struct nft_chain *c;
+ /* If built-in chains don't exist for this table, create them */
+ if (nft_xtables_config_load(h, XTABLES_CONFIG_DEFAULT, 0) < 0)
+ nft_chain_builtin_init(h, table, NULL, NF_ACCEPT);
+
list = nft_chain_dump(h);
iter = nft_chain_list_iter_create(list);