lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 29 Dec 2014 11:20:02 +0900
From:	Simon Horman <simon.horman@...ronome.com>
To:	John Fastabend <john.r.fastabend@...el.com>, netdev@...r.kernel.org
Cc:	Simon Horman <simon.horman@...ronome.com>
Subject: [PATCH] net: flow: Allow actions and matches to be NULL in net_flow_put_flow()

This makes the handing of the absence of actions or matches
symmetric with net_flow_get_flow().

Signed-off-by: Simon Horman <simon.horman@...ronome.com>
---
 net/core/flow_table.c | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/net/core/flow_table.c b/net/core/flow_table.c
index df2adf6..0992806 100644
--- a/net/core/flow_table.c
+++ b/net/core/flow_table.c
@@ -196,32 +196,36 @@ int net_flow_put_flow(struct sk_buff *skb, struct net_flow_flow *flow)
 	    nla_put_u32(skb, NET_FLOW_ATTR_PRIORITY, flow->priority))
 		goto flows_put_failure;
 
-	matches = nla_nest_start(skb, NET_FLOW_ATTR_MATCHES);
-	if (!matches)
-		goto flows_put_failure;
-	for (j = 0; flow->matches[j].header; j++) {
-		struct net_flow_field_ref *f = &flow->matches[j];
+	if (flow->matches) {
+		matches = nla_nest_start(skb, NET_FLOW_ATTR_MATCHES);
+		if (!matches)
+			goto flows_put_failure;
+		for (j = 0; flow->matches[j].header; j++) {
+			struct net_flow_field_ref *f = &flow->matches[j];
 
-		if (!f->header)
-			continue;
+			if (!f->header)
+				continue;
 
-		nla_put(skb, NET_FLOW_FIELD_REF, sizeof(*f), f);
+			nla_put(skb, NET_FLOW_FIELD_REF, sizeof(*f), f);
+		}
+		nla_nest_end(skb, matches);
 	}
-	nla_nest_end(skb, matches);
-
-	actions = nla_nest_start(skb, NET_FLOW_ATTR_ACTIONS);
-	if (!actions)
-		goto flows_put_failure;
 
-	for (i = 0; flow->actions[i].uid; i++) {
-		err = net_flow_put_flow_action(skb, &flow->actions[i]);
-		if (err) {
-			nla_nest_cancel(skb, actions);
+	if (flow->actions) {
+		actions = nla_nest_start(skb, NET_FLOW_ATTR_ACTIONS);
+		if (!actions)
 			goto flows_put_failure;
+
+		for (i = 0; flow->actions[i].uid; i++) {
+			err = net_flow_put_flow_action(skb, &flow->actions[i]);
+			if (err) {
+				nla_nest_cancel(skb, actions);
+				goto flows_put_failure;
+			}
 		}
+		nla_nest_end(skb, actions);
 	}
 
-	nla_nest_end(skb, actions);
 	nla_nest_end(skb, flows);
 	return 0;
 
-- 
2.1.3

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ