From: Pravin B Shelar Date: Fri, 8 Aug 2014 03:34:20 +0000 (-0700) Subject: datapath: Avoid using stack larger than 1024. X-Git-Tag: v2.4.0~1679 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=cc561abf175b1211e82c58054c65f4785f479b23 datapath: Avoid using stack larger than 1024. commit (datapath: Refactor action alloc and copy api) effectively reverted 1d2a1b5f5252e4c6ce8bbf8d91ca27aba52496e6 (datapath: Factor out allocation and verification of actions.). This results in following warning: CC [M] /home/jesse/openvswitch/datapath/linux/datapath.o /home/jesse/openvswitch/datapath/linux/datapath.c: In function ‘ovs_flow_cmd_set’: /home/jesse/openvswitch/datapath/linux/datapath.c:1094:1: warning: the frame size of 1256 bytes is larger than 1024 bytes [-Wframe-larger-than=] } Following patch introduced the factoring back. CC: Jesse Gross Signed-off-by: Pravin B Shelar Acked-by: Jesse Gross --- diff --git a/datapath/datapath.c b/datapath/datapath.c index f795e94f2..ab63791c1 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -990,6 +990,25 @@ error: return error; } +/* Factor out action copy to avoid "Wframe-larger-than=1024" warning. */ +static struct sw_flow_actions *get_flow_actions(const struct nlattr *a, + const struct sw_flow_key *key, + const struct sw_flow_mask *mask) +{ + struct sw_flow_actions *acts; + struct sw_flow_key masked_key; + int error; + + ovs_flow_mask_key(&masked_key, key, mask); + error = ovs_nla_copy_actions(a, &masked_key, &acts); + if (error) { + OVS_NLERR("Actions may not be safe on all matching packets.\n"); + return ERR_PTR(error); + } + + return acts; +} + static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info) { struct nlattr **a = info->attrs; @@ -1018,13 +1037,9 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info) /* Validate actions. */ if (a[OVS_FLOW_ATTR_ACTIONS]) { - struct sw_flow_key masked_key; - - ovs_flow_mask_key(&masked_key, &key, &mask); - error = ovs_nla_copy_actions(a[OVS_FLOW_ATTR_ACTIONS], - &masked_key, &acts); - if (error) { - OVS_NLERR("Flow actions may not be safe on all matching packets.\n"); + acts = get_flow_actions(a[OVS_FLOW_ATTR_ACTIONS], &key, &mask); + if (IS_ERR(acts)) { + error = PTR_ERR(acts); goto error; }