diff mbox

[libnftnl] trace: use get_u32 to parse NFPROTO and POLICY attribute

Message ID 1472820686-8157-1-git-send-email-zlpnobody@163.com
State Accepted
Delegated to: Florian Westphal
Headers show

Commit Message

Liping Zhang Sept. 2, 2016, 12:51 p.m. UTC
From: Liping Zhang <liping.zhang@spreadtrum.com>

NFTA_TRACE_NFPROTO and NFTA_TRACE_POLICY attribute is 32-bit
value, so we should use mnl_attr_get_u32 and htonl here.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
---
 src/trace.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Florian Westphal Sept. 2, 2016, 1:03 p.m. UTC | #1
Liping Zhang <zlpnobody@163.com> wrote:
> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> NFTA_TRACE_NFPROTO and NFTA_TRACE_POLICY attribute is 32-bit
> value, so we should use mnl_attr_get_u32 and htonl here.
 
Applied, thanks.
--
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
diff mbox

Patch

diff --git a/src/trace.c b/src/trace.c
index 2b3388d..bd05d3c 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -408,12 +408,12 @@  int nftnl_trace_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_trace *t)
 		t->flags |= (1 << NFTNL_TRACE_TRANSPORT_HEADER);
 
 	if (tb[NFTA_TRACE_NFPROTO]) {
-		t->nfproto = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_NFPROTO]));
+		t->nfproto = ntohl(mnl_attr_get_u32(tb[NFTA_TRACE_NFPROTO]));
 		t->flags |= (1 << NFTNL_TRACE_NFPROTO);
 	}
 
 	if (tb[NFTA_TRACE_POLICY]) {
-		t->policy = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_POLICY]));
+		t->policy = ntohl(mnl_attr_get_u32(tb[NFTA_TRACE_POLICY]));
 		t->flags |= (1 << NFTNL_TRACE_POLICY);
 	}