From 684b5f5dd127f304155c4619cf0874111da9dcdb Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Sat, 8 Nov 2014 13:53:52 -0800 Subject: [PATCH] datapath: Rename last_action() as nla_is_last() and move to netlink.h 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 Cc: Pravin Shelar Cc: Andy Zhou Signed-off-by: Simon Horman Acked-by: Thomas Graf Signed-off-by: David S. Miller Acked-by: Pravin B Shelar --- datapath/actions.c | 11 +++-------- datapath/linux/compat/include/net/netlink.h | 7 +++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/datapath/actions.c b/datapath/actions.c index a42ad1e10..3868e105f 100644 --- a/datapath/actions.c +++ b/datapath/actions.c @@ -672,11 +672,6 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb, return ovs_dp_upcall(dp, skb, key, &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) { @@ -711,7 +706,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); @@ -811,7 +806,7 @@ static int execute_recirc(struct datapath *dp, struct sk_buff *skb, } BUG_ON(!is_flow_key_valid(key)); - 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. */ @@ -898,7 +893,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. diff --git a/datapath/linux/compat/include/net/netlink.h b/datapath/linux/compat/include/net/netlink.h index a6dc5845b..9b83e171b 100644 --- a/datapath/linux/compat/include/net/netlink.h +++ b/datapath/linux/compat/include/net/netlink.h @@ -63,4 +63,11 @@ static inline struct nlattr *nla_find_nested(struct nlattr *nla, int attrtype) } #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0) +static inline bool nla_is_last(const struct nlattr *nla, int rem) +{ + return nla->nla_len == rem; +} +#endif + #endif /* net/netlink.h */ -- 2.39.5