* [libnftnl PATCH] chain: Don't print unset policy value in netlink debug
@ 2017-09-07 17:41 Phil Sutter
2017-09-08 12:58 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2017-09-07 17:41 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
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>
---
src/chain.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/chain.c b/src/chain.c
index 29860c509a180..3190a775a0005 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -795,11 +795,19 @@ 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);
--
2.13.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [libnftnl PATCH] chain: Don't print unset policy value in netlink debug
2017-09-07 17:41 [libnftnl PATCH] chain: Don't print unset policy value in netlink debug Phil Sutter
@ 2017-09-08 12:58 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-09-08 12:58 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
On Thu, Sep 07, 2017 at 07:41:27PM +0200, Phil Sutter wrote:
> 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.
Applied, thanks Phil.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-08 12:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-07 17:41 [libnftnl PATCH] chain: Don't print unset policy value in netlink debug Phil Sutter
2017-09-08 12:58 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).