diff options
author | Pravin B Shelar <pshelar@nicira.com> | 2014-10-19 22:19:51 +0400 |
---|---|---|
committer | Pravin B Shelar <pshelar@nicira.com> | 2014-11-06 10:52:35 +0300 |
commit | 2fdb957d634a906ae8939bff23d45968307acbf7 (patch) | |
tree | 98eee0e868f2b6ff95d715d7a0cdac169d3357d4 /net/openvswitch/flow_netlink.c | |
parent | 41af73e9c17d5fb549fced2be97faeb4b8606fb8 (diff) | |
download | linux-2fdb957d634a906ae8939bff23d45968307acbf7.tar.xz |
openvswitch: Refactor action alloc and copy api.
There are two separate API to allocate and copy actions list. Anytime
OVS needs to copy action list, it needs to call both functions.
Following patch moves action allocation to copy function to avoid
code duplication.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
Diffstat (limited to 'net/openvswitch/flow_netlink.c')
-rw-r--r-- | net/openvswitch/flow_netlink.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c index 1050b2882b9e..482a0cbb22e8 100644 --- a/net/openvswitch/flow_netlink.c +++ b/net/openvswitch/flow_netlink.c @@ -1284,7 +1284,7 @@ nla_put_failure: #define MAX_ACTIONS_BUFSIZE (32 * 1024) -struct sw_flow_actions *ovs_nla_alloc_flow_actions(int size) +static struct sw_flow_actions *nla_alloc_flow_actions(int size) { struct sw_flow_actions *sfa; @@ -1329,7 +1329,7 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, new_acts_size = MAX_ACTIONS_BUFSIZE; } - acts = ovs_nla_alloc_flow_actions(new_acts_size); + acts = nla_alloc_flow_actions(new_acts_size); if (IS_ERR(acts)) return (void *)acts; @@ -1396,7 +1396,7 @@ static inline void add_nested_action_end(struct sw_flow_actions *sfa, a->nla_len = sfa->actions_len - st_offset; } -static int ovs_nla_copy_actions__(const struct nlattr *attr, +static int __ovs_nla_copy_actions(const struct nlattr *attr, const struct sw_flow_key *key, int depth, struct sw_flow_actions **sfa, __be16 eth_type, __be16 vlan_tci); @@ -1441,7 +1441,7 @@ static int validate_and_copy_sample(const struct nlattr *attr, if (st_acts < 0) return st_acts; - err = ovs_nla_copy_actions__(actions, key, depth + 1, sfa, + err = __ovs_nla_copy_actions(actions, key, depth + 1, sfa, eth_type, vlan_tci); if (err) return err; @@ -1684,7 +1684,7 @@ static int copy_action(const struct nlattr *from, return 0; } -static int ovs_nla_copy_actions__(const struct nlattr *attr, +static int __ovs_nla_copy_actions(const struct nlattr *attr, const struct sw_flow_key *key, int depth, struct sw_flow_actions **sfa, __be16 eth_type, __be16 vlan_tci) @@ -1846,8 +1846,18 @@ int ovs_nla_copy_actions(const struct nlattr *attr, const struct sw_flow_key *key, struct sw_flow_actions **sfa) { - return ovs_nla_copy_actions__(attr, key, 0, sfa, key->eth.type, - key->eth.tci); + int err; + + *sfa = nla_alloc_flow_actions(nla_len(attr)); + if (IS_ERR(*sfa)) + return PTR_ERR(*sfa); + + err = __ovs_nla_copy_actions(attr, key, 0, sfa, key->eth.type, + key->eth.tci); + if (err) + kfree(*sfa); + + return err; } static int sample_action_to_attr(const struct nlattr *attr, struct sk_buff *skb) |