]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
mnl: Fix for missing info in rule dumps
authorPhil Sutter <phil@nwl.cc>
Thu, 17 Dec 2020 14:52:03 +0000 (15:52 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 30 Nov 2021 13:57:46 +0000 (14:57 +0100)
Commit 0e52cab1e64ab improved error reporting by adding rule's table and
chain names to netlink message directly, prefixed by their location
info. This in turn caused netlink dumps of the rule to not contain table
and chain name anymore. Fix this by inserting the missing info before
dumping and remove it afterwards to not cause duplicated entries in
netlink message.

Signed-off-by: Phil Sutter <phil@nwl.cc>
src/netlink_linearize.c

index 111102fd43346095f86ed3c890ed7a5b8662126c..34a6e1a941b56f412ebb77a52c920a960ef7f554 100644 (file)
@@ -1673,5 +1673,16 @@ void netlink_linearize_rule(struct netlink_ctx *ctx,
                nftnl_udata_buf_free(udata);
        }
 
-       netlink_dump_rule(lctx->nlr, ctx);
+       if (ctx->nft->debug_mask & NFT_DEBUG_NETLINK) {
+               nftnl_rule_set_str(lctx->nlr, NFTNL_RULE_TABLE,
+                                  rule->handle.table.name);
+               if (rule->handle.chain.name)
+                       nftnl_rule_set_str(lctx->nlr, NFTNL_RULE_CHAIN,
+                                          rule->handle.chain.name);
+
+               netlink_dump_rule(lctx->nlr, ctx);
+
+               nftnl_rule_unset(lctx->nlr, NFTNL_RULE_CHAIN);
+               nftnl_rule_unset(lctx->nlr, NFTNL_RULE_TABLE);
+       }
 }