* [PATCH] datapath: Avoid using stack larger than 1024.
@ 2017-06-27 9:20 Tonghao Zhang
2017-06-27 21:19 ` Pravin Shelar
0 siblings, 1 reply; 4+ messages in thread
From: Tonghao Zhang @ 2017-06-27 9:20 UTC (permalink / raw)
To: netdev; +Cc: Tonghao Zhang
When compiling OvS-master on 4.4.0-81 kernel,
there is a warning:
CC [M] /root/ovs/datapath/linux/datapath.o
/root/ovs/datapath/linux/datapath.c: In function
‘ovs_flow_cmd_set’:
/root/ovs/datapath/linux/datapath.c:1221:1: warning:
the frame size of 1040 bytes is larger than 1024 bytes
[-Wframe-larger-than=]
This patch use kmalloc to malloc mem for sw_flow_mask and
avoid using stack.
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
net/openvswitch/datapath.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index c85029c..da8cd68 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1107,7 +1107,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
struct ovs_header *ovs_header = info->userhdr;
struct sw_flow_key key;
struct sw_flow *flow;
- struct sw_flow_mask mask;
+ struct sw_flow_mask *mask;
struct sk_buff *reply = NULL;
struct datapath *dp;
struct sw_flow_actions *old_acts = NULL, *acts = NULL;
@@ -1120,7 +1120,11 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log);
if (a[OVS_FLOW_ATTR_KEY]) {
- ovs_match_init(&match, &key, true, &mask);
+ mask = kmalloc(sizeof(struct sw_flow_mask), GFP_KERNEL);
+ if (!mask)
+ return -ENOMEM;
+
+ ovs_match_init(&match, &key, true, mask);
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
a[OVS_FLOW_ATTR_MASK], log);
} else if (!ufid_present) {
@@ -1141,7 +1145,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
}
acts = get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], &key,
- &mask, log);
+ mask, log);
if (IS_ERR(acts)) {
error = PTR_ERR(acts);
goto error;
@@ -1216,6 +1220,7 @@ err_unlock_ovs:
err_kfree_acts:
ovs_nla_free_flow_actions(acts);
error:
+ kfree(mask);
return error;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] datapath: Avoid using stack larger than 1024.
2017-06-27 9:20 [PATCH] datapath: Avoid using stack larger than 1024 Tonghao Zhang
@ 2017-06-27 21:19 ` Pravin Shelar
0 siblings, 0 replies; 4+ messages in thread
From: Pravin Shelar @ 2017-06-27 21:19 UTC (permalink / raw)
To: Tonghao Zhang; +Cc: Linux Kernel Network Developers
On Tue, Jun 27, 2017 at 2:20 AM, Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
> When compiling OvS-master on 4.4.0-81 kernel,
> there is a warning:
>
> CC [M] /root/ovs/datapath/linux/datapath.o
> /root/ovs/datapath/linux/datapath.c: In function
> ‘ovs_flow_cmd_set’:
> /root/ovs/datapath/linux/datapath.c:1221:1: warning:
> the frame size of 1040 bytes is larger than 1024 bytes
> [-Wframe-larger-than=]
>
> This patch use kmalloc to malloc mem for sw_flow_mask and
> avoid using stack.
>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
> net/openvswitch/datapath.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index c85029c..da8cd68 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -1107,7 +1107,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
> struct ovs_header *ovs_header = info->userhdr;
> struct sw_flow_key key;
> struct sw_flow *flow;
> - struct sw_flow_mask mask;
> + struct sw_flow_mask *mask;
> struct sk_buff *reply = NULL;
> struct datapath *dp;
> struct sw_flow_actions *old_acts = NULL, *acts = NULL;
> @@ -1120,7 +1120,11 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
>
> ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log);
> if (a[OVS_FLOW_ATTR_KEY]) {
> - ovs_match_init(&match, &key, true, &mask);
> + mask = kmalloc(sizeof(struct sw_flow_mask), GFP_KERNEL);
> + if (!mask)
> + return -ENOMEM;
> +
> + ovs_match_init(&match, &key, true, mask);
Rather than allocating mask object and freeing it at the end, can you
factor out code which needs mask into new function to save some stack
space in this function?
> error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
> a[OVS_FLOW_ATTR_MASK], log);
> } else if (!ufid_present) {
> @@ -1141,7 +1145,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
> }
>
> acts = get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], &key,
> - &mask, log);
> + mask, log);
> if (IS_ERR(acts)) {
> error = PTR_ERR(acts);
> goto error;
> @@ -1216,6 +1220,7 @@ err_unlock_ovs:
> err_kfree_acts:
> ovs_nla_free_flow_actions(acts);
> error:
> + kfree(mask);
mask free is missing in usual, no error case.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] datapath: Avoid using stack larger than 1024.
2017-06-27 7:03 Tonghao Zhang
@ 2017-06-27 16:38 ` Greg Rose
0 siblings, 0 replies; 4+ messages in thread
From: Greg Rose @ 2017-06-27 16:38 UTC (permalink / raw)
To: Tonghao Zhang; +Cc: netdev, pravin shelar
On 06/27/2017 12:03 AM, Tonghao Zhang wrote:
> When compiling OvS-master on 4.4.0-81 kernel,
> there is a warning:
>
> CC [M] /root/ovs/datapath/linux/datapath.o
> /root/ovs/datapath/linux/datapath.c: In function
> ‘ovs_flow_cmd_set’:
> /root/ovs/datapath/linux/datapath.c:1221:1: warning:
> the frame size of 1040 bytes is larger than 1024 bytes
> [-Wframe-larger-than=]
>
> This patch use kmalloc to malloc mem for sw_flow_mask and
> avoid using stack.
>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
> datapath/datapath.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/datapath/datapath.c b/datapath/datapath.c
> index c85029c..da8cd68 100644
> --- a/datapath/datapath.c
> +++ b/datapath/datapath.c
> @@ -1107,7 +1107,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
> struct ovs_header *ovs_header = info->userhdr;
> struct sw_flow_key key;
> struct sw_flow *flow;
> - struct sw_flow_mask mask;
> + struct sw_flow_mask *mask;
> struct sk_buff *reply = NULL;
> struct datapath *dp;
> struct sw_flow_actions *old_acts = NULL, *acts = NULL;
> @@ -1120,7 +1120,11 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
>
> ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log);
> if (a[OVS_FLOW_ATTR_KEY]) {
> - ovs_match_init(&match, &key, true, &mask);
> + mask = kmalloc(sizeof(struct sw_flow_mask), GFP_KERNEL);
> + if (!mask)
> + return -ENOMEM;
> +
> + ovs_match_init(&match, &key, true, mask);
> error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
> a[OVS_FLOW_ATTR_MASK], log);
> } else if (!ufid_present) {
> @@ -1141,7 +1145,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
> }
>
> acts = get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], &key,
> - &mask, log);
> + mask, log);
> if (IS_ERR(acts)) {
> error = PTR_ERR(acts);
> goto error;
> @@ -1216,6 +1220,7 @@ err_unlock_ovs:
> err_kfree_acts:
> ovs_nla_free_flow_actions(acts);
> error:
> + kfree(mask);
> return error;
> }
>
>
It looks fine to me but let's copy the maintainer Pravin
- Greg
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] datapath: Avoid using stack larger than 1024.
@ 2017-06-27 7:03 Tonghao Zhang
2017-06-27 16:38 ` Greg Rose
0 siblings, 1 reply; 4+ messages in thread
From: Tonghao Zhang @ 2017-06-27 7:03 UTC (permalink / raw)
To: netdev; +Cc: Tonghao Zhang
When compiling OvS-master on 4.4.0-81 kernel,
there is a warning:
CC [M] /root/ovs/datapath/linux/datapath.o
/root/ovs/datapath/linux/datapath.c: In function
‘ovs_flow_cmd_set’:
/root/ovs/datapath/linux/datapath.c:1221:1: warning:
the frame size of 1040 bytes is larger than 1024 bytes
[-Wframe-larger-than=]
This patch use kmalloc to malloc mem for sw_flow_mask and
avoid using stack.
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
datapath/datapath.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/datapath/datapath.c b/datapath/datapath.c
index c85029c..da8cd68 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -1107,7 +1107,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
struct ovs_header *ovs_header = info->userhdr;
struct sw_flow_key key;
struct sw_flow *flow;
- struct sw_flow_mask mask;
+ struct sw_flow_mask *mask;
struct sk_buff *reply = NULL;
struct datapath *dp;
struct sw_flow_actions *old_acts = NULL, *acts = NULL;
@@ -1120,7 +1120,11 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
ufid_present = ovs_nla_get_ufid(&sfid, a[OVS_FLOW_ATTR_UFID], log);
if (a[OVS_FLOW_ATTR_KEY]) {
- ovs_match_init(&match, &key, true, &mask);
+ mask = kmalloc(sizeof(struct sw_flow_mask), GFP_KERNEL);
+ if (!mask)
+ return -ENOMEM;
+
+ ovs_match_init(&match, &key, true, mask);
error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY],
a[OVS_FLOW_ATTR_MASK], log);
} else if (!ufid_present) {
@@ -1141,7 +1145,7 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
}
acts = get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], &key,
- &mask, log);
+ mask, log);
if (IS_ERR(acts)) {
error = PTR_ERR(acts);
goto error;
@@ -1216,6 +1220,7 @@ err_unlock_ovs:
err_kfree_acts:
ovs_nla_free_flow_actions(acts);
error:
+ kfree(mask);
return error;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-27 21:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 9:20 [PATCH] datapath: Avoid using stack larger than 1024 Tonghao Zhang
2017-06-27 21:19 ` Pravin Shelar
-- strict thread matches above, loose matches on Subject: below --
2017-06-27 7:03 Tonghao Zhang
2017-06-27 16:38 ` Greg Rose
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.