aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/cls_flow.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-03-29 05:11:39 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-01 18:11:37 -0400
commit1b34ec43c9b3de44a5420841ab293d1b2035a94c (patch)
tree8d6cf966c813e0e61001655179b5ef8e5f1b54b3 /net/sched/cls_flow.c
parent9360ffd1859720f6520cf59241909b74dae369d0 (diff)
pkt_sched: Stop using NLA_PUT*().
These macros contain a hidden goto, and are thus extremely error prone and make code hard to audit. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_flow.c')
-rw-r--r--net/sched/cls_flow.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index 1d8bd0dbcd1f..ccd08c8dc6a7 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -572,25 +572,32 @@ static int flow_dump(struct tcf_proto *tp, unsigned long fh,
572 if (nest == NULL) 572 if (nest == NULL)
573 goto nla_put_failure; 573 goto nla_put_failure;
574 574
575 NLA_PUT_U32(skb, TCA_FLOW_KEYS, f->keymask); 575 if (nla_put_u32(skb, TCA_FLOW_KEYS, f->keymask) ||
576 NLA_PUT_U32(skb, TCA_FLOW_MODE, f->mode); 576 nla_put_u32(skb, TCA_FLOW_MODE, f->mode))
577 goto nla_put_failure;
577 578
578 if (f->mask != ~0 || f->xor != 0) { 579 if (f->mask != ~0 || f->xor != 0) {
579 NLA_PUT_U32(skb, TCA_FLOW_MASK, f->mask); 580 if (nla_put_u32(skb, TCA_FLOW_MASK, f->mask) ||
580 NLA_PUT_U32(skb, TCA_FLOW_XOR, f->xor); 581 nla_put_u32(skb, TCA_FLOW_XOR, f->xor))
582 goto nla_put_failure;
581 } 583 }
582 if (f->rshift) 584 if (f->rshift &&
583 NLA_PUT_U32(skb, TCA_FLOW_RSHIFT, f->rshift); 585 nla_put_u32(skb, TCA_FLOW_RSHIFT, f->rshift))
584 if (f->addend) 586 goto nla_put_failure;
585 NLA_PUT_U32(skb, TCA_FLOW_ADDEND, f->addend); 587 if (f->addend &&
588 nla_put_u32(skb, TCA_FLOW_ADDEND, f->addend))
589 goto nla_put_failure;
586 590
587 if (f->divisor) 591 if (f->divisor &&
588 NLA_PUT_U32(skb, TCA_FLOW_DIVISOR, f->divisor); 592 nla_put_u32(skb, TCA_FLOW_DIVISOR, f->divisor))
589 if (f->baseclass) 593 goto nla_put_failure;
590 NLA_PUT_U32(skb, TCA_FLOW_BASECLASS, f->baseclass); 594 if (f->baseclass &&
595 nla_put_u32(skb, TCA_FLOW_BASECLASS, f->baseclass))
596 goto nla_put_failure;
591 597
592 if (f->perturb_period) 598 if (f->perturb_period &&
593 NLA_PUT_U32(skb, TCA_FLOW_PERTURB, f->perturb_period / HZ); 599 nla_put_u32(skb, TCA_FLOW_PERTURB, f->perturb_period / HZ))
600 goto nla_put_failure;
594 601
595 if (tcf_exts_dump(skb, &f->exts, &flow_ext_map) < 0) 602 if (tcf_exts_dump(skb, &f->exts, &flow_ext_map) < 0)
596 goto nla_put_failure; 603 goto nla_put_failure;