Patchwork [libnftables,04/13] src: fix display of compat_flag and compat_proto

login
register
mail settings
Submitter Alvaro Neira
Date Aug. 9, 2013, 11:12 a.m.
Message ID <20130809111232.29819.34259.stgit@Ph0enix>
Download mbox | patch
Permalink /patch/265994/
State Accepted
Headers show

Comments

Alvaro Neira - Aug. 9, 2013, 11:12 a.m.
From: Álvaro Neira Ayuso <alvaroneay@gmail.com>

Fixed display compat_proto value and compat_flag if available

Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
 src/rule.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/src/rule.c b/src/rule.c
index 9d6a996..41534bd 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -633,9 +633,10 @@  static int nft_rule_snprintf_json(char *buf, size_t size, struct nft_rule *r,
 					r->rule_flags);
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
-	if(NFT_RULE_ATTR_COMPAT_PROTO != 0 || NFT_RULE_ATTR_COMPAT_FLAGS != 0){
+	if (r->flags & (1 << NFT_RULE_ATTR_COMPAT_PROTO) ||
+	    r->flags & (1 << NFT_RULE_ATTR_COMPAT_FLAGS)) {
 		ret = snprintf(buf+offset,len,"\"compat_flags\" : %u, "
-									  "\"compat_proto\" : %u, ",
+					      "\"compat_proto\" : %u, ",
 					r->compat.flags, r->compat.proto);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}