netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] datapath: Rename last_action() as nla_is_last() and move to netlink.h
@ 2014-10-27  7:12 Simon Horman
  2014-10-27 10:08 ` [ovs-dev] " Thomas Graf
  2014-10-28 21:08 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Horman @ 2014-10-27  7:12 UTC (permalink / raw)
  To: netdev, David S. Miller, Pravin Shelar
  Cc: dev, Simon Horman, Thomas Graf, Andy Zhou

The original motivation for this change was to allow the helper to be used
in files other than actions.c as part of work on an odp select group
action.

It was as pointed out by Thomas Graf that this helper would be best off
living in netlink.h. Furthermore, I think that the generic nature of this
helper means it is best off in netlink.h regardless of if it is used more
than one .c file or not. Thus, I would like it considered independent of
the work on an odp select group action.

Cc: Thomas Graf <tgraf@suug.ch>
Cc: Pravin Shelar <pshelar@nicira.com>
Cc: Andy Zhou <azhou@nicira.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
 include/net/netlink.h     | 10 ++++++++++
 net/openvswitch/actions.c | 11 +++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/include/net/netlink.h b/include/net/netlink.h
index 7b903e1..6415835 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -1185,4 +1185,14 @@ static inline int nla_validate_nested(const struct nlattr *start, int maxtype,
 #define nla_for_each_nested(pos, nla, rem) \
 	nla_for_each_attr(pos, nla_data(nla), nla_len(nla), rem)
 
+/**
+ * nla_is_last - Test if attribute is last in stream
+ * @nla: attribute to test
+ * @rem: bytes remaining in stream
+ */
+static inline bool nla_is_last(const struct nlattr *nla, int rem)
+{
+	return nla->nla_len == rem;
+}
+
 #endif
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 006886d..922c133 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -504,11 +504,6 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
 	return ovs_dp_upcall(dp, skb, &upcall);
 }
 
-static bool last_action(const struct nlattr *a, int rem)
-{
-	return a->nla_len == rem;
-}
-
 static int sample(struct datapath *dp, struct sk_buff *skb,
 		  struct sw_flow_key *key, const struct nlattr *attr)
 {
@@ -543,7 +538,7 @@ static int sample(struct datapath *dp, struct sk_buff *skb,
 	 * user space. This skb will be consumed by its caller.
 	 */
 	if (likely(nla_type(a) == OVS_ACTION_ATTR_USERSPACE &&
-		   last_action(a, rem)))
+		   nla_is_last(a, rem)))
 		return output_userspace(dp, skb, key, a);
 
 	skb = skb_clone(skb, GFP_ATOMIC);
@@ -633,7 +628,7 @@ static int execute_recirc(struct datapath *dp, struct sk_buff *skb,
 	if (err)
 		return err;
 
-	if (!last_action(a, rem)) {
+	if (!nla_is_last(a, rem)) {
 		/* Recirc action is the not the last action
 		 * of the action list, need to clone the skb.
 		 */
@@ -707,7 +702,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
 
 		case OVS_ACTION_ATTR_RECIRC:
 			err = execute_recirc(dp, skb, key, a, rem);
-			if (last_action(a, rem)) {
+			if (nla_is_last(a, rem)) {
 				/* If this is the last action, the skb has
 				 * been consumed or freed.
 				 * Return immediately.
-- 
2.1.1

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

* Re: [ovs-dev] [PATCH net-next] datapath: Rename last_action() as nla_is_last() and move to netlink.h
  2014-10-27  7:12 [PATCH net-next] datapath: Rename last_action() as nla_is_last() and move to netlink.h Simon Horman
@ 2014-10-27 10:08 ` Thomas Graf
  2014-10-28 21:08 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Graf @ 2014-10-27 10:08 UTC (permalink / raw)
  To: Simon Horman; +Cc: netdev, David S. Miller, Pravin Shelar, dev

On 10/27/14 at 04:12pm, Simon Horman wrote:
> The original motivation for this change was to allow the helper to be used
> in files other than actions.c as part of work on an odp select group
> action.
> 
> It was as pointed out by Thomas Graf that this helper would be best off
> living in netlink.h. Furthermore, I think that the generic nature of this
> helper means it is best off in netlink.h regardless of if it is used more
> than one .c file or not. Thus, I would like it considered independent of
> the work on an odp select group action.
> 
> Cc: Thomas Graf <tgraf@suug.ch>
> Cc: Pravin Shelar <pshelar@nicira.com>
> Cc: Andy Zhou <azhou@nicira.com>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>

Acked-by: Thomas Graf <tgraf@noironetworks.com>

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

* Re: [PATCH net-next] datapath: Rename last_action() as nla_is_last() and move to netlink.h
  2014-10-27  7:12 [PATCH net-next] datapath: Rename last_action() as nla_is_last() and move to netlink.h Simon Horman
  2014-10-27 10:08 ` [ovs-dev] " Thomas Graf
@ 2014-10-28 21:08 ` David Miller
  2014-10-29  2:10   ` Simon Horman
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2014-10-28 21:08 UTC (permalink / raw)
  To: simon.horman; +Cc: netdev, pshelar, dev, tgraf, azhou

From: Simon Horman <simon.horman@netronome.com>
Date: Mon, 27 Oct 2014 16:12:16 +0900

> The original motivation for this change was to allow the helper to be used
> in files other than actions.c as part of work on an odp select group
> action.
> 
> It was as pointed out by Thomas Graf that this helper would be best off
> living in netlink.h. Furthermore, I think that the generic nature of this
> helper means it is best off in netlink.h regardless of if it is used more
> than one .c file or not. Thus, I would like it considered independent of
> the work on an odp select group action.
> 
> Cc: Thomas Graf <tgraf@suug.ch>
> Cc: Pravin Shelar <pshelar@nicira.com>
> Cc: Andy Zhou <azhou@nicira.com>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>

Applied, thanks Simon.

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

* Re: [PATCH net-next] datapath: Rename last_action() as nla_is_last() and move to netlink.h
  2014-10-28 21:08 ` David Miller
@ 2014-10-29  2:10   ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2014-10-29  2:10 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, pshelar, dev, tgraf, azhou

On Tue, Oct 28, 2014 at 05:08:08PM -0400, David Miller wrote:
> From: Simon Horman <simon.horman@netronome.com>
> Date: Mon, 27 Oct 2014 16:12:16 +0900
> 
> > The original motivation for this change was to allow the helper to be used
> > in files other than actions.c as part of work on an odp select group
> > action.
> > 
> > It was as pointed out by Thomas Graf that this helper would be best off
> > living in netlink.h. Furthermore, I think that the generic nature of this
> > helper means it is best off in netlink.h regardless of if it is used more
> > than one .c file or not. Thus, I would like it considered independent of
> > the work on an odp select group action.
> > 
> > Cc: Thomas Graf <tgraf@suug.ch>
> > Cc: Pravin Shelar <pshelar@nicira.com>
> > Cc: Andy Zhou <azhou@nicira.com>
> > Signed-off-by: Simon Horman <simon.horman@netronome.com>
> 
> Applied, thanks Simon.

Thanks

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

end of thread, other threads:[~2014-10-29  2:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-27  7:12 [PATCH net-next] datapath: Rename last_action() as nla_is_last() and move to netlink.h Simon Horman
2014-10-27 10:08 ` [ovs-dev] " Thomas Graf
2014-10-28 21:08 ` David Miller
2014-10-29  2:10   ` 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).