netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: flow: Allow actions and matches to be NULL in net_flow_put_flow()
@ 2014-12-29  2:20 Simon Horman
  2014-12-29 17:56 ` John Fastabend
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2014-12-29  2:20 UTC (permalink / raw)
  To: John Fastabend, netdev; +Cc: Simon Horman

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

Signed-off-by: Simon Horman <simon.horman@netronome.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

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

* Re: [PATCH] net: flow: Allow actions and matches to be NULL in net_flow_put_flow()
  2014-12-29  2:20 [PATCH] net: flow: Allow actions and matches to be NULL in net_flow_put_flow() Simon Horman
@ 2014-12-29 17:56 ` John Fastabend
  2015-01-05  2:06   ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: John Fastabend @ 2014-12-29 17:56 UTC (permalink / raw)
  To: Simon Horman; +Cc: John Fastabend, netdev

On 12/28/2014 06:20 PM, Simon Horman wrote:
> This makes the handing of the absence of actions or matches
> symmetric with net_flow_get_flow().
>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> ---

Again thanks I actually just hit this with my rocker implementation
so very timely fix. Same story here I'll roll it into the patch and
submit it later today.

.John

-- 
John Fastabend         Intel Corporation

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

* Re: [PATCH] net: flow: Allow actions and matches to be NULL in net_flow_put_flow()
  2014-12-29 17:56 ` John Fastabend
@ 2015-01-05  2:06   ` Simon Horman
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Horman @ 2015-01-05  2:06 UTC (permalink / raw)
  To: John Fastabend; +Cc: John Fastabend, netdev

On Mon, Dec 29, 2014 at 09:56:23AM -0800, John Fastabend wrote:
> On 12/28/2014 06:20 PM, Simon Horman wrote:
> >This makes the handing of the absence of actions or matches
> >symmetric with net_flow_get_flow().
> >
> >Signed-off-by: Simon Horman <simon.horman@netronome.com>
> >---
> 
> Again thanks I actually just hit this with my rocker implementation
> so very timely fix. Same story here I'll roll it into the patch and
> submit it later today.

Thanks. I have hit a few more minor problems which I have fixes for.
What is the best way to handle them? Rebase them on v1 of your patchset
and post them for review if they are still relevant?

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

end of thread, other threads:[~2015-01-05  2:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-29  2:20 [PATCH] net: flow: Allow actions and matches to be NULL in net_flow_put_flow() Simon Horman
2014-12-29 17:56 ` John Fastabend
2015-01-05  2:06   ` Simon Horman

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