aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch/flow_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/openvswitch/flow_netlink.c')
-rw-r--r--net/openvswitch/flow_netlink.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index dc424798ba6f..624ea74353dd 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -2241,14 +2241,11 @@ int ovs_nla_put_mask(const struct sw_flow *flow, struct sk_buff *skb)
2241 2241
2242#define MAX_ACTIONS_BUFSIZE (32 * 1024) 2242#define MAX_ACTIONS_BUFSIZE (32 * 1024)
2243 2243
2244static struct sw_flow_actions *nla_alloc_flow_actions(int size, bool log) 2244static struct sw_flow_actions *nla_alloc_flow_actions(int size)
2245{ 2245{
2246 struct sw_flow_actions *sfa; 2246 struct sw_flow_actions *sfa;
2247 2247
2248 if (size > MAX_ACTIONS_BUFSIZE) { 2248 WARN_ON_ONCE(size > MAX_ACTIONS_BUFSIZE);
2249 OVS_NLERR(log, "Flow action size %u bytes exceeds max", size);
2250 return ERR_PTR(-EINVAL);
2251 }
2252 2249
2253 sfa = kmalloc(sizeof(*sfa) + size, GFP_KERNEL); 2250 sfa = kmalloc(sizeof(*sfa) + size, GFP_KERNEL);
2254 if (!sfa) 2251 if (!sfa)
@@ -2321,12 +2318,15 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa,
2321 new_acts_size = ksize(*sfa) * 2; 2318 new_acts_size = ksize(*sfa) * 2;
2322 2319
2323 if (new_acts_size > MAX_ACTIONS_BUFSIZE) { 2320 if (new_acts_size > MAX_ACTIONS_BUFSIZE) {
2324 if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size) 2321 if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size) {
2322 OVS_NLERR(log, "Flow action size exceeds max %u",
2323 MAX_ACTIONS_BUFSIZE);
2325 return ERR_PTR(-EMSGSIZE); 2324 return ERR_PTR(-EMSGSIZE);
2325 }
2326 new_acts_size = MAX_ACTIONS_BUFSIZE; 2326 new_acts_size = MAX_ACTIONS_BUFSIZE;
2327 } 2327 }
2328 2328
2329 acts = nla_alloc_flow_actions(new_acts_size, log); 2329 acts = nla_alloc_flow_actions(new_acts_size);
2330 if (IS_ERR(acts)) 2330 if (IS_ERR(acts))
2331 return (void *)acts; 2331 return (void *)acts;
2332 2332
@@ -3059,7 +3059,7 @@ int ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
3059{ 3059{
3060 int err; 3060 int err;
3061 3061
3062 *sfa = nla_alloc_flow_actions(nla_len(attr), log); 3062 *sfa = nla_alloc_flow_actions(min(nla_len(attr), MAX_ACTIONS_BUFSIZE));
3063 if (IS_ERR(*sfa)) 3063 if (IS_ERR(*sfa))
3064 return PTR_ERR(*sfa); 3064 return PTR_ERR(*sfa);
3065 3065