netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libnftnl] trace: fix multiple copy and paste errors
@ 2016-03-07 11:01 Patrick McHardy
  2016-03-07 11:07 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick McHardy @ 2016-03-07 11:01 UTC (permalink / raw)
  To: pablo; +Cc: fw, netfilter-devel

Fix duplicated and incorrect assignments.

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 src/trace.c | 51 +++++++++++++--------------------------------------
 1 file changed, 13 insertions(+), 38 deletions(-)

diff --git a/src/trace.c b/src/trace.c
index b04abb5..9655f0a 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -333,11 +333,6 @@ int nftnl_trace_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_trace *t)
 	if (!tb[NFTA_TRACE_TYPE])
 		abi_breakage();
 
-	if (tb[NFTA_TRACE_TABLE])
-		t->table = strdup(mnl_attr_get_str(tb[NFTA_TRACE_TABLE]));
-	if (tb[NFTA_TRACE_CHAIN])
-		t->chain = strdup(mnl_attr_get_str(tb[NFTA_TRACE_CHAIN]));
-
 	t->family = nfg->nfgen_family;
 	t->flags |= (1 << NFTNL_TRACE_FAMILY);
 
@@ -347,6 +342,16 @@ int nftnl_trace_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_trace *t)
 	t->id = ntohl(mnl_attr_get_u32(tb[NFTA_TRACE_ID]));
 	t->flags |= (1 << NFTNL_TRACE_ID);
 
+	if (tb[NFTA_TRACE_TABLE]) {
+		t->table = strdup(mnl_attr_get_str(tb[NFTA_TRACE_TABLE]));
+		t->flags |= (1 << NFTNL_TRACE_TABLE);
+	}
+
+	if (tb[NFTA_TRACE_CHAIN]) {
+		t->chain = strdup(mnl_attr_get_str(tb[NFTA_TRACE_CHAIN]));
+		t->flags |= (1 << NFTNL_TRACE_CHAIN);
+	}
+
 	if (tb[NFTA_TRACE_IIFTYPE]) {
 		t->iiftype = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_IIFTYPE]));
 		t->flags |= (1 << NFTNL_TRACE_IIFTYPE);
@@ -358,7 +363,7 @@ int nftnl_trace_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_trace *t)
 	}
 
 	if (tb[NFTA_TRACE_OIFTYPE]) {
-		t->iiftype = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_OIFTYPE]));
+		t->oiftype = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_OIFTYPE]));
 		t->flags |= (1 << NFTNL_TRACE_OIFTYPE);
 	}
 
@@ -390,49 +395,19 @@ 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->iiftype = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_NFPROTO]));
+		t->nfproto = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_NFPROTO]));
 		t->flags |= (1 << NFTNL_TRACE_NFPROTO);
 	}
 
 	if (tb[NFTA_TRACE_POLICY]) {
-		t->iiftype = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_POLICY]));
+		t->policy = ntohs(mnl_attr_get_u16(tb[NFTA_TRACE_POLICY]));
 		t->flags |= (1 << NFTNL_TRACE_POLICY);
 	}
 
-	if (tb[NFTA_TRACE_OIF]) {
-		t->oif = ntohl(mnl_attr_get_u32(tb[NFTA_TRACE_OIF]));
-		t->flags |= (1 << NFTNL_TRACE_OIF);
-	}
-
 	if (tb[NFTA_TRACE_MARK]) {
 		t->mark = ntohl(mnl_attr_get_u32(tb[NFTA_TRACE_MARK]));
 		t->flags |= (1 << NFTNL_TRACE_MARK);
 	}
 
-	if (tb[NFTA_TRACE_RULE_HANDLE]) {
-		t->rule_handle = be64toh(mnl_attr_get_u64(tb[NFTA_TRACE_RULE_HANDLE]));
-		t->flags |= (1 << NFTNL_TRACE_RULE_HANDLE);
-	}
-
-	if (tb[NFTA_TRACE_VERDICT])
-		nftnl_trace_parse_verdict(tb[NFTA_TRACE_VERDICT], t);
-
-	if (nftnl_trace_nlmsg_parse_hdrdata(tb[NFTA_TRACE_LL_HEADER], &t->ll))
-		t->flags |= (1 << NFTNL_TRACE_LL_HEADER);
-
-	if (nftnl_trace_nlmsg_parse_hdrdata(tb[NFTA_TRACE_NETWORK_HEADER], &t->nh))
-		t->flags |= (1 << NFTNL_TRACE_NETWORK_HEADER);
-
-	if (nftnl_trace_nlmsg_parse_hdrdata(tb[NFTA_TRACE_TRANSPORT_HEADER], &t->th))
-		t->flags |= (1 << NFTNL_TRACE_TRANSPORT_HEADER);
-
-	if (t->chain)
-		t->flags |= (1 << NFTNL_TRACE_CHAIN);
-
-	if (t->chain)
-		t->flags |= (1 << NFTNL_TRACE_CHAIN);
-	if (t->table)
-		t->flags |= (1 << NFTNL_TRACE_TABLE);
-
 	return 0;
 }
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-07 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-07 11:01 [PATCH libnftnl] trace: fix multiple copy and paste errors Patrick McHardy
2016-03-07 11:07 ` Florian Westphal

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).