aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_nat.c
diff options
context:
space:
mode:
authorChangli Gao <xiaosuo@gmail.com>2010-06-29 19:07:09 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-30 15:12:37 -0400
commit504f85c9d05f7c605306e808f0d835fe11bfd18d (patch)
tree98c3aa1f09c3c84598abfe6555010bfc54a2493d /net/sched/act_nat.c
parent5acbf7f10b9e336510a1de79b4af06f6da9a8c5a (diff)
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: Changli Gao <xiaosuo@gmail.com> ---- net/sched/act_nat.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_nat.c')
-rw-r--r--net/sched/act_nat.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index 570949417f3..0be49a4b4d8 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -265,40 +265,29 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
265{ 265{
266 unsigned char *b = skb_tail_pointer(skb); 266 unsigned char *b = skb_tail_pointer(skb);
267 struct tcf_nat *p = a->priv; 267 struct tcf_nat *p = a->priv;
268 struct tc_nat *opt; 268 struct tc_nat opt;
269 struct tcf_t t; 269 struct tcf_t t;
270 int s;
271 270
272 s = sizeof(*opt); 271 opt.old_addr = p->old_addr;
272 opt.new_addr = p->new_addr;
273 opt.mask = p->mask;
274 opt.flags = p->flags;
273 275
274 /* netlink spinlocks held above us - must use ATOMIC */ 276 opt.index = p->tcf_index;
275 opt = kzalloc(s, GFP_ATOMIC); 277 opt.action = p->tcf_action;
276 if (unlikely(!opt)) 278 opt.refcnt = p->tcf_refcnt - ref;
277 return -ENOBUFS; 279 opt.bindcnt = p->tcf_bindcnt - bind;
278 280
279 opt->old_addr = p->old_addr; 281 NLA_PUT(skb, TCA_NAT_PARMS, sizeof(opt), &opt);
280 opt->new_addr = p->new_addr;
281 opt->mask = p->mask;
282 opt->flags = p->flags;
283
284 opt->index = p->tcf_index;
285 opt->action = p->tcf_action;
286 opt->refcnt = p->tcf_refcnt - ref;
287 opt->bindcnt = p->tcf_bindcnt - bind;
288
289 NLA_PUT(skb, TCA_NAT_PARMS, s, opt);
290 t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install); 282 t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
291 t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse); 283 t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
292 t.expires = jiffies_to_clock_t(p->tcf_tm.expires); 284 t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
293 NLA_PUT(skb, TCA_NAT_TM, sizeof(t), &t); 285 NLA_PUT(skb, TCA_NAT_TM, sizeof(t), &t);
294 286
295 kfree(opt);
296
297 return skb->len; 287 return skb->len;
298 288
299nla_put_failure: 289nla_put_failure:
300 nlmsg_trim(skb, b); 290 nlmsg_trim(skb, b);
301 kfree(opt);
302 return -1; 291 return -1;
303} 292}
304 293