Commit 504f85c9 authored by Changli Gao's avatar Changli Gao Committed by David S. Miller

act_nat: use stack variable

act_nat: use stack variable

structure tc_nat isn't too big for stack, so we can put it in stack.
Signed-off-by: default avatarChangli Gao <xiaosuo@gmail.com>
----
 net/sched/act_nat.c |   31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5acbf7f1
...@@ -265,40 +265,29 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -265,40 +265,29 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
{ {
unsigned char *b = skb_tail_pointer(skb); unsigned char *b = skb_tail_pointer(skb);
struct tcf_nat *p = a->priv; struct tcf_nat *p = a->priv;
struct tc_nat *opt; struct tc_nat opt;
struct tcf_t t; struct tcf_t t;
int s;
s = sizeof(*opt); opt.old_addr = p->old_addr;
opt.new_addr = p->new_addr;
opt.mask = p->mask;
opt.flags = p->flags;
/* netlink spinlocks held above us - must use ATOMIC */ opt.index = p->tcf_index;
opt = kzalloc(s, GFP_ATOMIC); opt.action = p->tcf_action;
if (unlikely(!opt)) opt.refcnt = p->tcf_refcnt - ref;
return -ENOBUFS; opt.bindcnt = p->tcf_bindcnt - bind;
opt->old_addr = p->old_addr; NLA_PUT(skb, TCA_NAT_PARMS, sizeof(opt), &opt);
opt->new_addr = p->new_addr;
opt->mask = p->mask;
opt->flags = p->flags;
opt->index = p->tcf_index;
opt->action = p->tcf_action;
opt->refcnt = p->tcf_refcnt - ref;
opt->bindcnt = p->tcf_bindcnt - bind;
NLA_PUT(skb, TCA_NAT_PARMS, s, opt);
t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install); t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse); t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
t.expires = jiffies_to_clock_t(p->tcf_tm.expires); t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
NLA_PUT(skb, TCA_NAT_TM, sizeof(t), &t); NLA_PUT(skb, TCA_NAT_TM, sizeof(t), &t);
kfree(opt);
return skb->len; return skb->len;
nla_put_failure: nla_put_failure:
nlmsg_trim(skb, b); nlmsg_trim(skb, b);
kfree(opt);
return -1; return -1;
} }
......
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