summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2017-09-07 19:41:27 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-09-08 14:57:49 +0200
commitb808caea50a9de10530591b2e83c243d9fbf4855 (patch)
tree575724a28222aa1289b6c1eb87094063e8eb5af3
parenta459be71c97c79438d9b46d7c47b3f2e9eb900cb (diff)
chain: Don't print unset policy value in netlink debug
The policy field was printed unconditionally, but if it wasn't set the default value 0 was printed as 'policy drop' which is not correct. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/chain.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/chain.c b/src/chain.c
index 29860c5..e5b9fe3 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -795,16 +795,24 @@ static int nftnl_chain_snprintf_default(char *buf, size_t size,
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
if (c->flags & (1 << NFTNL_CHAIN_HOOKNUM)) {
- ret = snprintf(buf+offset, len,
- " type %s hook %s prio %d policy %s "
- "packets %"PRIu64" bytes %"PRIu64"",
+ ret = snprintf(buf + offset, len, " type %s hook %s prio %d",
c->type, nftnl_hooknum2str(c->family, c->hooknum),
- c->prio, nftnl_verdict2str(c->policy),
+ c->prio);
+ SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+
+ if (c->flags & (1 << NFTNL_CHAIN_POLICY)) {
+ ret = snprintf(buf + offset, len, " policy %s",
+ nftnl_verdict2str(c->policy));
+ SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ }
+
+ ret = snprintf(buf + offset, len,
+ " packets %"PRIu64" bytes %"PRIu64"",
c->packets, c->bytes);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
if (c->flags & (1 << NFTNL_CHAIN_DEV)) {
- ret = snprintf(buf+offset, len, " dev %s ", c->dev);
+ ret = snprintf(buf + offset, len, " dev %s ", c->dev);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
}
}