Commit 0af413bd authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

flow_dissector: work around stack frame size warning

The fl_flow_key structure is around 500 bytes, so having two of them
on the stack in one function now exceeds the warning limit after an
otherwise correct change:

net/sched/cls_flower.c:298:12: error: stack frame size of 1056 bytes in function 'fl_classify' [-Werror,-Wframe-larger-than=]

I suspect the fl_classify function could be reworked to only have one
of them on the stack and modify it in place, but I could not work out
how to do that.

As a somewhat hacky workaround, move one of them into an out-of-line
function to reduce its scope. This does not necessarily reduce the stack
usage of the outer function, but at least the second copy is removed
from the stack during most of it and does not add up to whatever is
called from there.

I now see 552 bytes of stack usage for fl_classify(), plus 528 bytes
for fl_mask_lookup().

Fixes: 58cff782 ("flow_dissector: Parse multiple MPLS Label Stack Entries")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Acked-by: default avatarGuillaume Nault <gnault@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6f197fb6
...@@ -272,14 +272,16 @@ static struct cls_fl_filter *fl_lookup_range(struct fl_flow_mask *mask, ...@@ -272,14 +272,16 @@ static struct cls_fl_filter *fl_lookup_range(struct fl_flow_mask *mask,
return NULL; return NULL;
} }
static struct cls_fl_filter *fl_lookup(struct fl_flow_mask *mask, static noinline_for_stack
struct fl_flow_key *mkey, struct cls_fl_filter *fl_mask_lookup(struct fl_flow_mask *mask, struct fl_flow_key *key)
struct fl_flow_key *key)
{ {
struct fl_flow_key mkey;
fl_set_masked_key(&mkey, key, mask);
if ((mask->flags & TCA_FLOWER_MASK_FLAGS_RANGE)) if ((mask->flags & TCA_FLOWER_MASK_FLAGS_RANGE))
return fl_lookup_range(mask, mkey, key); return fl_lookup_range(mask, &mkey, key);
return __fl_lookup(mask, mkey); return __fl_lookup(mask, &mkey);
} }
static u16 fl_ct_info_to_flower_map[] = { static u16 fl_ct_info_to_flower_map[] = {
...@@ -299,7 +301,6 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, ...@@ -299,7 +301,6 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
struct tcf_result *res) struct tcf_result *res)
{ {
struct cls_fl_head *head = rcu_dereference_bh(tp->root); struct cls_fl_head *head = rcu_dereference_bh(tp->root);
struct fl_flow_key skb_mkey;
struct fl_flow_key skb_key; struct fl_flow_key skb_key;
struct fl_flow_mask *mask; struct fl_flow_mask *mask;
struct cls_fl_filter *f; struct cls_fl_filter *f;
...@@ -319,9 +320,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, ...@@ -319,9 +320,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
ARRAY_SIZE(fl_ct_info_to_flower_map)); ARRAY_SIZE(fl_ct_info_to_flower_map));
skb_flow_dissect(skb, &mask->dissector, &skb_key, 0); skb_flow_dissect(skb, &mask->dissector, &skb_key, 0);
fl_set_masked_key(&skb_mkey, &skb_key, mask); f = fl_mask_lookup(mask, &skb_key);
f = fl_lookup(mask, &skb_mkey, &skb_key);
if (f && !tc_skip_sw(f->flags)) { if (f && !tc_skip_sw(f->flags)) {
*res = f->res; *res = f->res;
return tcf_exts_exec(skb, &f->exts, res); return tcf_exts_exec(skb, &f->exts, res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment