pkt_sched: Stop using NLA_PUT*().
authorDavid S. Miller <davem@davemloft.net>
Thu, 29 Mar 2012 09:11:39 +0000 (05:11 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Apr 2012 22:11:37 +0000 (18:11 -0400)
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>
40 files changed:
net/sched/act_api.c
net/sched/act_csum.c
net/sched/act_gact.c
net/sched/act_ipt.c
net/sched/act_mirred.c
net/sched/act_nat.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_simple.c
net/sched/act_skbedit.c
net/sched/cls_api.c
net/sched/cls_basic.c
net/sched/cls_flow.c
net/sched/cls_fw.c
net/sched/cls_route.c
net/sched/cls_rsvp.h
net/sched/cls_tcindex.c
net/sched/cls_u32.c
net/sched/em_meta.c
net/sched/ematch.c
net/sched/sch_api.c
net/sched/sch_atm.c
net/sched/sch_cbq.c
net/sched/sch_choke.c
net/sched/sch_drr.c
net/sched/sch_dsmark.c
net/sched/sch_fifo.c
net/sched/sch_generic.c
net/sched/sch_gred.c
net/sched/sch_hfsc.c
net/sched/sch_htb.c
net/sched/sch_mqprio.c
net/sched/sch_multiq.c
net/sched/sch_netem.c
net/sched/sch_prio.c
net/sched/sch_qfq.c
net/sched/sch_red.c
net/sched/sch_sfb.c
net/sched/sch_sfq.c
net/sched/sch_tbf.c

index 93fdf131bd75e3e8e1969f1889c9d2a2cff90c67..5cfb160df0632f4ae206248a5e34cecdda0d707b 100644 (file)
@@ -127,7 +127,8 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
        nest = nla_nest_start(skb, a->order);
        if (nest == NULL)
                goto nla_put_failure;
-       NLA_PUT_STRING(skb, TCA_KIND, a->ops->kind);
+       if (nla_put_string(skb, TCA_KIND, a->ops->kind))
+               goto nla_put_failure;
        for (i = 0; i < (hinfo->hmask + 1); i++) {
                p = hinfo->htab[tcf_hash(i, hinfo->hmask)];
 
@@ -139,7 +140,8 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
                        p = s_p;
                }
        }
-       NLA_PUT_U32(skb, TCA_FCNT, n_i);
+       if (nla_put_u32(skb, TCA_FCNT, n_i))
+               goto nla_put_failure;
        nla_nest_end(skb, nest);
 
        return n_i;
@@ -437,7 +439,8 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
        if (a->ops == NULL || a->ops->dump == NULL)
                return err;
 
-       NLA_PUT_STRING(skb, TCA_KIND, a->ops->kind);
+       if (nla_put_string(skb, TCA_KIND, a->ops->kind))
+               goto nla_put_failure;
        if (tcf_action_copy_stats(skb, a, 0))
                goto nla_put_failure;
        nest = nla_nest_start(skb, TCA_OPTIONS);
index 453a73431ac47b8688a207b22d90f647dfc3eef4..882124ceb70c1be6ef1c87105d276a5e84e506ba 100644 (file)
@@ -550,11 +550,13 @@ static int tcf_csum_dump(struct sk_buff *skb,
        };
        struct tcf_t t;
 
-       NLA_PUT(skb, TCA_CSUM_PARMS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
-       NLA_PUT(skb, TCA_CSUM_TM, sizeof(t), &t);
+       if (nla_put(skb, TCA_CSUM_TM, sizeof(t), &t))
+               goto nla_put_failure;
 
        return skb->len;
 
index b77f5a06a658f56bf3733ab72918aa63aedd1c16..f10fb8256442014afbba6b85a23a3544ee0ec9e4 100644 (file)
@@ -162,7 +162,8 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
        };
        struct tcf_t t;
 
-       NLA_PUT(skb, TCA_GACT_PARMS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_GACT_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
 #ifdef CONFIG_GACT_PROB
        if (gact->tcfg_ptype) {
                struct tc_gact_p p_opt = {
@@ -171,13 +172,15 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
                        .ptype   = gact->tcfg_ptype,
                };
 
-               NLA_PUT(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt);
+               if (nla_put(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt))
+                       goto nla_put_failure;
        }
 #endif
        t.install = jiffies_to_clock_t(jiffies - gact->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(gact->tcf_tm.expires);
-       NLA_PUT(skb, TCA_GACT_TM, sizeof(t), &t);
+       if (nla_put(skb, TCA_GACT_TM, sizeof(t), &t))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
index 60f8f616e8fa2c7b73df63dff52119622f036168..0beba0e5312e02bbb250657ba32f8b1c7a2570c6 100644 (file)
@@ -267,15 +267,17 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
        c.refcnt = ipt->tcf_refcnt - ref;
        strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name);
 
-       NLA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t);
-       NLA_PUT_U32(skb, TCA_IPT_INDEX, ipt->tcf_index);
-       NLA_PUT_U32(skb, TCA_IPT_HOOK, ipt->tcfi_hook);
-       NLA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c);
-       NLA_PUT_STRING(skb, TCA_IPT_TABLE, ipt->tcfi_tname);
+       if (nla_put(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t) ||
+           nla_put_u32(skb, TCA_IPT_INDEX, ipt->tcf_index) ||
+           nla_put_u32(skb, TCA_IPT_HOOK, ipt->tcfi_hook) ||
+           nla_put(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c) ||
+           nla_put_string(skb, TCA_IPT_TABLE, ipt->tcfi_tname))
+               goto nla_put_failure;
        tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install);
        tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse);
        tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires);
-       NLA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm);
+       if (nla_put(skb, TCA_IPT_TM, sizeof (tm), &tm))
+               goto nla_put_failure;
        kfree(t);
        return skb->len;
 
index e051398fdf6baf4834bbe21bf13deac081594148..d583aea3b3dfac850b1e953b502e5ef05f13dc80 100644 (file)
@@ -227,11 +227,13 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, i
        };
        struct tcf_t t;
 
-       NLA_PUT(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - m->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - m->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(m->tcf_tm.expires);
-       NLA_PUT(skb, TCA_MIRRED_TM, sizeof(t), &t);
+       if (nla_put(skb, TCA_MIRRED_TM, sizeof(t), &t))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
index 001d1b354869a18f06df2b7fd0fee14870bdb343..b5d029eb44f23216cce377506b39e9bbf7997dc3 100644 (file)
@@ -284,11 +284,13 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
        };
        struct tcf_t t;
 
-       NLA_PUT(skb, TCA_NAT_PARMS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_NAT_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
-       NLA_PUT(skb, TCA_NAT_TM, sizeof(t), &t);
+       if (nla_put(skb, TCA_NAT_TM, sizeof(t), &t))
+               goto nla_put_failure;
 
        return skb->len;
 
index 10d3aed86560973f0b91daabcd3ddfb62777c3a9..26aa2f6ce257c5b39541df44db40c950fcd67045 100644 (file)
@@ -215,11 +215,13 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
        opt->refcnt = p->tcf_refcnt - ref;
        opt->bindcnt = p->tcf_bindcnt - bind;
 
-       NLA_PUT(skb, TCA_PEDIT_PARMS, s, opt);
+       if (nla_put(skb, TCA_PEDIT_PARMS, s, opt))
+               goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
-       NLA_PUT(skb, TCA_PEDIT_TM, sizeof(t), &t);
+       if (nla_put(skb, TCA_PEDIT_TM, sizeof(t), &t))
+               goto nla_put_failure;
        kfree(opt);
        return skb->len;
 
index 6fb3f5af0f85c69e6be7c90f71242fa073f87691..a9de23297d47759f3fa50113b1bf190f51bf4063 100644 (file)
@@ -356,11 +356,14 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
                opt.rate = police->tcfp_R_tab->rate;
        if (police->tcfp_P_tab)
                opt.peakrate = police->tcfp_P_tab->rate;
-       NLA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt);
-       if (police->tcfp_result)
-               NLA_PUT_U32(skb, TCA_POLICE_RESULT, police->tcfp_result);
-       if (police->tcfp_ewma_rate)
-               NLA_PUT_U32(skb, TCA_POLICE_AVRATE, police->tcfp_ewma_rate);
+       if (nla_put(skb, TCA_POLICE_TBF, sizeof(opt), &opt))
+               goto nla_put_failure;
+       if (police->tcfp_result &&
+           nla_put_u32(skb, TCA_POLICE_RESULT, police->tcfp_result))
+               goto nla_put_failure;
+       if (police->tcfp_ewma_rate &&
+           nla_put_u32(skb, TCA_POLICE_AVRATE, police->tcfp_ewma_rate))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
index 73e0a3ab4d55a0150045512771036330e4ca737b..3922f2a2821b83cf3f9db318980a7cad06111e1f 100644 (file)
@@ -172,12 +172,14 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
        };
        struct tcf_t t;
 
-       NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt);
-       NLA_PUT_STRING(skb, TCA_DEF_DATA, d->tcfd_defdata);
+       if (nla_put(skb, TCA_DEF_PARMS, sizeof(opt), &opt) ||
+           nla_put_string(skb, TCA_DEF_DATA, d->tcfd_defdata))
+               goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
-       NLA_PUT(skb, TCA_DEF_TM, sizeof(t), &t);
+       if (nla_put(skb, TCA_DEF_TM, sizeof(t), &t))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
index 35dbbe91027e3734e1b9ccd52b5b9ce2edbcbf5a..476e0fac6712292a133d5645f98ca889af52a8c4 100644 (file)
@@ -166,20 +166,25 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
        };
        struct tcf_t t;
 
-       NLA_PUT(skb, TCA_SKBEDIT_PARMS, sizeof(opt), &opt);
-       if (d->flags & SKBEDIT_F_PRIORITY)
-               NLA_PUT(skb, TCA_SKBEDIT_PRIORITY, sizeof(d->priority),
-                       &d->priority);
-       if (d->flags & SKBEDIT_F_QUEUE_MAPPING)
-               NLA_PUT(skb, TCA_SKBEDIT_QUEUE_MAPPING,
-                       sizeof(d->queue_mapping), &d->queue_mapping);
-       if (d->flags & SKBEDIT_F_MARK)
-               NLA_PUT(skb, TCA_SKBEDIT_MARK, sizeof(d->mark),
-                       &d->mark);
+       if (nla_put(skb, TCA_SKBEDIT_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
+       if ((d->flags & SKBEDIT_F_PRIORITY) &&
+           nla_put(skb, TCA_SKBEDIT_PRIORITY, sizeof(d->priority),
+                   &d->priority))
+               goto nla_put_failure;
+       if ((d->flags & SKBEDIT_F_QUEUE_MAPPING) &&
+           nla_put(skb, TCA_SKBEDIT_QUEUE_MAPPING,
+                   sizeof(d->queue_mapping), &d->queue_mapping))
+               goto nla_put_failure;
+       if ((d->flags & SKBEDIT_F_MARK) &&
+           nla_put(skb, TCA_SKBEDIT_MARK, sizeof(d->mark),
+                   &d->mark))
+               goto nla_put_failure;
        t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
        t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
        t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
-       NLA_PUT(skb, TCA_SKBEDIT_TM, sizeof(t), &t);
+       if (nla_put(skb, TCA_SKBEDIT_TM, sizeof(t), &t))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
index a69d44f1dac51786bed33220446629761df6de85..f452f696b4b358e1789f60349993616c049c0396 100644 (file)
@@ -357,7 +357,8 @@ static int tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp,
        tcm->tcm_ifindex = qdisc_dev(tp->q)->ifindex;
        tcm->tcm_parent = tp->classid;
        tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol);
-       NLA_PUT_STRING(skb, TCA_KIND, tp->ops->kind);
+       if (nla_put_string(skb, TCA_KIND, tp->ops->kind))
+               goto nla_put_failure;
        tcm->tcm_handle = fh;
        if (RTM_DELTFILTER != event) {
                tcm->tcm_handle = 0;
index ea1f70b5a5f4747f2988c0b354a0abac7f2443da..590960a22a77fb0747c2fc42c78caff686cd8ac8 100644 (file)
@@ -257,8 +257,9 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh,
        if (nest == NULL)
                goto nla_put_failure;
 
-       if (f->res.classid)
-               NLA_PUT_U32(skb, TCA_BASIC_CLASSID, f->res.classid);
+       if (f->res.classid &&
+           nla_put_u32(skb, TCA_BASIC_CLASSID, f->res.classid))
+               goto nla_put_failure;
 
        if (tcf_exts_dump(skb, &f->exts, &basic_ext_map) < 0 ||
            tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0)
index 1d8bd0dbcd1fff38ed191b89decb3f0afb0456af..ccd08c8dc6a72b18f0c7c45f743fa4912f954413 100644 (file)
@@ -572,25 +572,32 @@ static int flow_dump(struct tcf_proto *tp, unsigned long fh,
        if (nest == NULL)
                goto nla_put_failure;
 
-       NLA_PUT_U32(skb, TCA_FLOW_KEYS, f->keymask);
-       NLA_PUT_U32(skb, TCA_FLOW_MODE, f->mode);
+       if (nla_put_u32(skb, TCA_FLOW_KEYS, f->keymask) ||
+           nla_put_u32(skb, TCA_FLOW_MODE, f->mode))
+               goto nla_put_failure;
 
        if (f->mask != ~0 || f->xor != 0) {
-               NLA_PUT_U32(skb, TCA_FLOW_MASK, f->mask);
-               NLA_PUT_U32(skb, TCA_FLOW_XOR, f->xor);
+               if (nla_put_u32(skb, TCA_FLOW_MASK, f->mask) ||
+                   nla_put_u32(skb, TCA_FLOW_XOR, f->xor))
+                       goto nla_put_failure;
        }
-       if (f->rshift)
-               NLA_PUT_U32(skb, TCA_FLOW_RSHIFT, f->rshift);
-       if (f->addend)
-               NLA_PUT_U32(skb, TCA_FLOW_ADDEND, f->addend);
+       if (f->rshift &&
+           nla_put_u32(skb, TCA_FLOW_RSHIFT, f->rshift))
+               goto nla_put_failure;
+       if (f->addend &&
+           nla_put_u32(skb, TCA_FLOW_ADDEND, f->addend))
+               goto nla_put_failure;
 
-       if (f->divisor)
-               NLA_PUT_U32(skb, TCA_FLOW_DIVISOR, f->divisor);
-       if (f->baseclass)
-               NLA_PUT_U32(skb, TCA_FLOW_BASECLASS, f->baseclass);
+       if (f->divisor &&
+           nla_put_u32(skb, TCA_FLOW_DIVISOR, f->divisor))
+               goto nla_put_failure;
+       if (f->baseclass &&
+           nla_put_u32(skb, TCA_FLOW_BASECLASS, f->baseclass))
+               goto nla_put_failure;
 
-       if (f->perturb_period)
-               NLA_PUT_U32(skb, TCA_FLOW_PERTURB, f->perturb_period / HZ);
+       if (f->perturb_period &&
+           nla_put_u32(skb, TCA_FLOW_PERTURB, f->perturb_period / HZ))
+               goto nla_put_failure;
 
        if (tcf_exts_dump(skb, &f->exts, &flow_ext_map) < 0)
                goto nla_put_failure;
index 389af152ec45ae2e3a50313dd36a5797ef4a4048..8384a47972403360c22688d8daa1ebdf34338aad 100644 (file)
@@ -346,14 +346,17 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
        if (nest == NULL)
                goto nla_put_failure;
 
-       if (f->res.classid)
-               NLA_PUT_U32(skb, TCA_FW_CLASSID, f->res.classid);
+       if (f->res.classid &&
+           nla_put_u32(skb, TCA_FW_CLASSID, f->res.classid))
+               goto nla_put_failure;
 #ifdef CONFIG_NET_CLS_IND
-       if (strlen(f->indev))
-               NLA_PUT_STRING(skb, TCA_FW_INDEV, f->indev);
+       if (strlen(f->indev) &&
+           nla_put_string(skb, TCA_FW_INDEV, f->indev))
+               goto nla_put_failure;
 #endif /* CONFIG_NET_CLS_IND */
-       if (head->mask != 0xFFFFFFFF)
-               NLA_PUT_U32(skb, TCA_FW_MASK, head->mask);
+       if (head->mask != 0xFFFFFFFF &&
+           nla_put_u32(skb, TCA_FW_MASK, head->mask))
+               goto nla_put_failure;
 
        if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0)
                goto nla_put_failure;
index 13ab66e9df585d884d687feaa77baf6bc017c8c5..36fec422740154b4addb97e20410da27f1e98622 100644 (file)
@@ -571,17 +571,21 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
 
        if (!(f->handle & 0x8000)) {
                id = f->id & 0xFF;
-               NLA_PUT_U32(skb, TCA_ROUTE4_TO, id);
+               if (nla_put_u32(skb, TCA_ROUTE4_TO, id))
+                       goto nla_put_failure;
        }
        if (f->handle & 0x80000000) {
-               if ((f->handle >> 16) != 0xFFFF)
-                       NLA_PUT_U32(skb, TCA_ROUTE4_IIF, f->iif);
+               if ((f->handle >> 16) != 0xFFFF &&
+                   nla_put_u32(skb, TCA_ROUTE4_IIF, f->iif))
+                       goto nla_put_failure;
        } else {
                id = f->id >> 16;
-               NLA_PUT_U32(skb, TCA_ROUTE4_FROM, id);
+               if (nla_put_u32(skb, TCA_ROUTE4_FROM, id))
+                       goto nla_put_failure;
        }
-       if (f->res.classid)
-               NLA_PUT_U32(skb, TCA_ROUTE4_CLASSID, f->res.classid);
+       if (f->res.classid &&
+           nla_put_u32(skb, TCA_ROUTE4_CLASSID, f->res.classid))
+               goto nla_put_failure;
 
        if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0)
                goto nla_put_failure;
index b01427924f8112dd0b923287976f285fd7674fbf..18ab93ec8d7e3abb9b25514d09485d4a3e3b21c4 100644 (file)
@@ -615,18 +615,22 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh,
        if (nest == NULL)
                goto nla_put_failure;
 
-       NLA_PUT(skb, TCA_RSVP_DST, sizeof(s->dst), &s->dst);
+       if (nla_put(skb, TCA_RSVP_DST, sizeof(s->dst), &s->dst))
+               goto nla_put_failure;
        pinfo.dpi = s->dpi;
        pinfo.spi = f->spi;
        pinfo.protocol = s->protocol;
        pinfo.tunnelid = s->tunnelid;
        pinfo.tunnelhdr = f->tunnelhdr;
        pinfo.pad = 0;
-       NLA_PUT(skb, TCA_RSVP_PINFO, sizeof(pinfo), &pinfo);
-       if (f->res.classid)
-               NLA_PUT_U32(skb, TCA_RSVP_CLASSID, f->res.classid);
-       if (((f->handle >> 8) & 0xFF) != 16)
-               NLA_PUT(skb, TCA_RSVP_SRC, sizeof(f->src), f->src);
+       if (nla_put(skb, TCA_RSVP_PINFO, sizeof(pinfo), &pinfo))
+               goto nla_put_failure;
+       if (f->res.classid &&
+           nla_put_u32(skb, TCA_RSVP_CLASSID, f->res.classid))
+               goto nla_put_failure;
+       if (((f->handle >> 8) & 0xFF) != 16 &&
+           nla_put(skb, TCA_RSVP_SRC, sizeof(f->src), f->src))
+               goto nla_put_failure;
 
        if (tcf_exts_dump(skb, &f->exts, &rsvp_ext_map) < 0)
                goto nla_put_failure;
index dbe199234c6384bd553c5ac743600ac9886bff3b..fe29420d0b0e5a4241dbe7a5190c2f0686ce1fa0 100644 (file)
@@ -438,10 +438,11 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
 
        if (!fh) {
                t->tcm_handle = ~0; /* whatever ... */
-               NLA_PUT_U32(skb, TCA_TCINDEX_HASH, p->hash);
-               NLA_PUT_U16(skb, TCA_TCINDEX_MASK, p->mask);
-               NLA_PUT_U32(skb, TCA_TCINDEX_SHIFT, p->shift);
-               NLA_PUT_U32(skb, TCA_TCINDEX_FALL_THROUGH, p->fall_through);
+               if (nla_put_u32(skb, TCA_TCINDEX_HASH, p->hash) ||
+                   nla_put_u16(skb, TCA_TCINDEX_MASK, p->mask) ||
+                   nla_put_u32(skb, TCA_TCINDEX_SHIFT, p->shift) ||
+                   nla_put_u32(skb, TCA_TCINDEX_FALL_THROUGH, p->fall_through))
+                       goto nla_put_failure;
                nla_nest_end(skb, nest);
        } else {
                if (p->perfect) {
@@ -460,8 +461,9 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
                        }
                }
                pr_debug("handle = %d\n", t->tcm_handle);
-               if (r->res.class)
-                       NLA_PUT_U32(skb, TCA_TCINDEX_CLASSID, r->res.classid);
+               if (r->res.class &&
+                   nla_put_u32(skb, TCA_TCINDEX_CLASSID, r->res.classid))
+                       goto nla_put_failure;
 
                if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0)
                        goto nla_put_failure;
index 939b627b4795f7852323fbd8673a47b43ac1e61b..591b006a8c5a0a5d37b3222e639849a338b2c722 100644 (file)
@@ -733,36 +733,44 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
                struct tc_u_hnode *ht = (struct tc_u_hnode *)fh;
                u32 divisor = ht->divisor + 1;
 
-               NLA_PUT_U32(skb, TCA_U32_DIVISOR, divisor);
+               if (nla_put_u32(skb, TCA_U32_DIVISOR, divisor))
+                       goto nla_put_failure;
        } else {
-               NLA_PUT(skb, TCA_U32_SEL,
-                       sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key),
-                       &n->sel);
+               if (nla_put(skb, TCA_U32_SEL,
+                           sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key),
+                           &n->sel))
+                       goto nla_put_failure;
                if (n->ht_up) {
                        u32 htid = n->handle & 0xFFFFF000;
-                       NLA_PUT_U32(skb, TCA_U32_HASH, htid);
+                       if (nla_put_u32(skb, TCA_U32_HASH, htid))
+                               goto nla_put_failure;
                }
-               if (n->res.classid)
-                       NLA_PUT_U32(skb, TCA_U32_CLASSID, n->res.classid);
-               if (n->ht_down)
-                       NLA_PUT_U32(skb, TCA_U32_LINK, n->ht_down->handle);
+               if (n->res.classid &&
+                   nla_put_u32(skb, TCA_U32_CLASSID, n->res.classid))
+                       goto nla_put_failure;
+               if (n->ht_down &&
+                   nla_put_u32(skb, TCA_U32_LINK, n->ht_down->handle))
+                       goto nla_put_failure;
 
 #ifdef CONFIG_CLS_U32_MARK
-               if (n->mark.val || n->mark.mask)
-                       NLA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark);
+               if ((n->mark.val || n->mark.mask) &&
+                   nla_put(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark))
+                       goto nla_put_failure;
 #endif
 
                if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0)
                        goto nla_put_failure;
 
 #ifdef CONFIG_NET_CLS_IND
-               if (strlen(n->indev))
-                       NLA_PUT_STRING(skb, TCA_U32_INDEV, n->indev);
+               if (strlen(n->indev) &&
+                   nla_put_string(skb, TCA_U32_INDEV, n->indev))
+                       goto nla_put_failure;
 #endif
 #ifdef CONFIG_CLS_U32_PERF
-               NLA_PUT(skb, TCA_U32_PCNT,
-               sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64),
-                       n->pf);
+               if (nla_put(skb, TCA_U32_PCNT,
+                           sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64),
+                           n->pf))
+                       goto nla_put_failure;
 #endif
        }
 
index 1363bf14e61b676567bd4f6de3166b370534fc32..4790c696cbce8364af6552d2028ed0a1880e3a21 100644 (file)
@@ -585,8 +585,9 @@ static void meta_var_apply_extras(struct meta_value *v,
 
 static int meta_var_dump(struct sk_buff *skb, struct meta_value *v, int tlv)
 {
-       if (v->val && v->len)
-               NLA_PUT(skb, tlv, v->len, (void *) v->val);
+       if (v->val && v->len &&
+           nla_put(skb, tlv, v->len, (void *) v->val))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure:
@@ -636,10 +637,13 @@ static void meta_int_apply_extras(struct meta_value *v,
 
 static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv)
 {
-       if (v->len == sizeof(unsigned long))
-               NLA_PUT(skb, tlv, sizeof(unsigned long), &v->val);
-       else if (v->len == sizeof(u32))
-               NLA_PUT_U32(skb, tlv, v->val);
+       if (v->len == sizeof(unsigned long)) {
+               if (nla_put(skb, tlv, sizeof(unsigned long), &v->val))
+                       goto nla_put_failure;
+       } else if (v->len == sizeof(u32)) {
+               if (nla_put_u32(skb, tlv, v->val))
+                       goto nla_put_failure;
+       }
 
        return 0;
 
@@ -831,7 +835,8 @@ static int em_meta_dump(struct sk_buff *skb, struct tcf_ematch *em)
        memcpy(&hdr.left, &meta->lvalue.hdr, sizeof(hdr.left));
        memcpy(&hdr.right, &meta->rvalue.hdr, sizeof(hdr.right));
 
-       NLA_PUT(skb, TCA_EM_META_HDR, sizeof(hdr), &hdr);
+       if (nla_put(skb, TCA_EM_META_HDR, sizeof(hdr), &hdr))
+               goto nla_put_failure;
 
        ops = meta_type_ops(&meta->lvalue);
        if (ops->dump(skb, &meta->lvalue, TCA_EM_META_LVALUE) < 0 ||
index 88d93eb92507be2f80fd90db12a63b11a7e87aeb..aca233c2b84814fd990e7b702290bf87c0a99ef7 100644 (file)
@@ -441,7 +441,8 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv)
        if (top_start == NULL)
                goto nla_put_failure;
 
-       NLA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr);
+       if (nla_put(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr))
+               goto nla_put_failure;
 
        list_start = nla_nest_start(skb, TCA_EMATCH_TREE_LIST);
        if (list_start == NULL)
@@ -457,7 +458,8 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv)
                        .flags = em->flags
                };
 
-               NLA_PUT(skb, i + 1, sizeof(em_hdr), &em_hdr);
+               if (nla_put(skb, i + 1, sizeof(em_hdr), &em_hdr))
+                       goto nla_put_failure;
 
                if (em->ops && em->ops->dump) {
                        if (em->ops->dump(skb, em) < 0)
index 3d8981fde3019ae09130528c3f08e4d632385f2f..d2daefcc205f675bc82500629608dcd0ca90a928 100644 (file)
@@ -426,7 +426,8 @@ static int qdisc_dump_stab(struct sk_buff *skb, struct qdisc_size_table *stab)
        nest = nla_nest_start(skb, TCA_STAB);
        if (nest == NULL)
                goto nla_put_failure;
-       NLA_PUT(skb, TCA_STAB_BASE, sizeof(stab->szopts), &stab->szopts);
+       if (nla_put(skb, TCA_STAB_BASE, sizeof(stab->szopts), &stab->szopts))
+               goto nla_put_failure;
        nla_nest_end(skb, nest);
 
        return skb->len;
@@ -1201,7 +1202,8 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
        tcm->tcm_parent = clid;
        tcm->tcm_handle = q->handle;
        tcm->tcm_info = atomic_read(&q->refcnt);
-       NLA_PUT_STRING(skb, TCA_KIND, q->ops->id);
+       if (nla_put_string(skb, TCA_KIND, q->ops->id))
+               goto nla_put_failure;
        if (q->ops->dump && q->ops->dump(q, skb) < 0)
                goto nla_put_failure;
        q->qstats.qlen = q->q.qlen;
@@ -1505,7 +1507,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
        tcm->tcm_parent = q->handle;
        tcm->tcm_handle = q->handle;
        tcm->tcm_info = 0;
-       NLA_PUT_STRING(skb, TCA_KIND, q->ops->id);
+       if (nla_put_string(skb, TCA_KIND, q->ops->id))
+               goto nla_put_failure;
        if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0)
                goto nla_put_failure;
 
index e25e49061a0d4370ee02f759ab37dc09f3083d03..a77a4fbc069acc911ab7212d303149189f82a7a3 100644 (file)
@@ -601,7 +601,8 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
        if (nest == NULL)
                goto nla_put_failure;
 
-       NLA_PUT(skb, TCA_ATM_HDR, flow->hdr_len, flow->hdr);
+       if (nla_put(skb, TCA_ATM_HDR, flow->hdr_len, flow->hdr))
+               goto nla_put_failure;
        if (flow->vcc) {
                struct sockaddr_atmpvc pvc;
                int state;
@@ -610,15 +611,19 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
                pvc.sap_addr.itf = flow->vcc->dev ? flow->vcc->dev->number : -1;
                pvc.sap_addr.vpi = flow->vcc->vpi;
                pvc.sap_addr.vci = flow->vcc->vci;
-               NLA_PUT(skb, TCA_ATM_ADDR, sizeof(pvc), &pvc);
+               if (nla_put(skb, TCA_ATM_ADDR, sizeof(pvc), &pvc))
+                       goto nla_put_failure;
                state = ATM_VF2VS(flow->vcc->flags);
-               NLA_PUT_U32(skb, TCA_ATM_STATE, state);
+               if (nla_put_u32(skb, TCA_ATM_STATE, state))
+                       goto nla_put_failure;
+       }
+       if (flow->excess) {
+               if (nla_put_u32(skb, TCA_ATM_EXCESS, flow->classid))
+                       goto nla_put_failure;
+       } else {
+               if (nla_put_u32(skb, TCA_ATM_EXCESS, 0))
+                       goto nla_put_failure;
        }
-       if (flow->excess)
-               NLA_PUT_U32(skb, TCA_ATM_EXCESS, flow->classid);
-       else
-               NLA_PUT_U32(skb, TCA_ATM_EXCESS, 0);
-
        nla_nest_end(skb, nest);
        return skb->len;
 
index 24d94c097b35f34bfee4ff5aed2a724e8549176d..6aabd77d1cfdd5cddd34b55dc69699cae9956e57 100644 (file)
@@ -1425,7 +1425,8 @@ static int cbq_dump_rate(struct sk_buff *skb, struct cbq_class *cl)
 {
        unsigned char *b = skb_tail_pointer(skb);
 
-       NLA_PUT(skb, TCA_CBQ_RATE, sizeof(cl->R_tab->rate), &cl->R_tab->rate);
+       if (nla_put(skb, TCA_CBQ_RATE, sizeof(cl->R_tab->rate), &cl->R_tab->rate))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
@@ -1450,7 +1451,8 @@ static int cbq_dump_lss(struct sk_buff *skb, struct cbq_class *cl)
        opt.minidle = (u32)(-cl->minidle);
        opt.offtime = cl->offtime;
        opt.change = ~0;
-       NLA_PUT(skb, TCA_CBQ_LSSOPT, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_CBQ_LSSOPT, sizeof(opt), &opt))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
@@ -1468,7 +1470,8 @@ static int cbq_dump_wrr(struct sk_buff *skb, struct cbq_class *cl)
        opt.priority = cl->priority + 1;
        opt.cpriority = cl->cpriority + 1;
        opt.weight = cl->weight;
-       NLA_PUT(skb, TCA_CBQ_WRROPT, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_CBQ_WRROPT, sizeof(opt), &opt))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
@@ -1485,7 +1488,8 @@ static int cbq_dump_ovl(struct sk_buff *skb, struct cbq_class *cl)
        opt.priority2 = cl->priority2 + 1;
        opt.pad = 0;
        opt.penalty = cl->penalty;
-       NLA_PUT(skb, TCA_CBQ_OVL_STRATEGY, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_CBQ_OVL_STRATEGY, sizeof(opt), &opt))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
@@ -1502,7 +1506,8 @@ static int cbq_dump_fopt(struct sk_buff *skb, struct cbq_class *cl)
                opt.split = cl->split ? cl->split->common.classid : 0;
                opt.defmap = cl->defmap;
                opt.defchange = ~0;
-               NLA_PUT(skb, TCA_CBQ_FOPT, sizeof(opt), &opt);
+               if (nla_put(skb, TCA_CBQ_FOPT, sizeof(opt), &opt))
+                       goto nla_put_failure;
        }
        return skb->len;
 
@@ -1521,7 +1526,8 @@ static int cbq_dump_police(struct sk_buff *skb, struct cbq_class *cl)
                opt.police = cl->police;
                opt.__res1 = 0;
                opt.__res2 = 0;
-               NLA_PUT(skb, TCA_CBQ_POLICE, sizeof(opt), &opt);
+               if (nla_put(skb, TCA_CBQ_POLICE, sizeof(opt), &opt))
+                       goto nla_put_failure;
        }
        return skb->len;
 
index 7e267d7b9c75730ef8351798ec1540b92e31f101..81445cc8196f72c3ad7f3d06ef99e4016be1854f 100644 (file)
@@ -515,8 +515,9 @@ static int choke_dump(struct Qdisc *sch, struct sk_buff *skb)
        if (opts == NULL)
                goto nla_put_failure;
 
-       NLA_PUT(skb, TCA_CHOKE_PARMS, sizeof(opt), &opt);
-       NLA_PUT_U32(skb, TCA_CHOKE_MAX_P, q->parms.max_P);
+       if (nla_put(skb, TCA_CHOKE_PARMS, sizeof(opt), &opt) ||
+           nla_put_u32(skb, TCA_CHOKE_MAX_P, q->parms.max_P))
+               goto nla_put_failure;
        return nla_nest_end(skb, opts);
 
 nla_put_failure:
index 6b7fe4a84f138b903928a8c5f5f90f8fe3b855dc..c2189879359bf7530796a0ed2f04ba8d50aa8981 100644 (file)
@@ -260,7 +260,8 @@ static int drr_dump_class(struct Qdisc *sch, unsigned long arg,
        nest = nla_nest_start(skb, TCA_OPTIONS);
        if (nest == NULL)
                goto nla_put_failure;
-       NLA_PUT_U32(skb, TCA_DRR_QUANTUM, cl->quantum);
+       if (nla_put_u32(skb, TCA_DRR_QUANTUM, cl->quantum))
+               goto nla_put_failure;
        return nla_nest_end(skb, nest);
 
 nla_put_failure:
index 2c790204d042e3ac5ec4f2b322b8a0429628dbb5..389b856c66537eb14b2b7fe0aae49883c503d18f 100644 (file)
@@ -429,8 +429,9 @@ static int dsmark_dump_class(struct Qdisc *sch, unsigned long cl,
        opts = nla_nest_start(skb, TCA_OPTIONS);
        if (opts == NULL)
                goto nla_put_failure;
-       NLA_PUT_U8(skb, TCA_DSMARK_MASK, p->mask[cl - 1]);
-       NLA_PUT_U8(skb, TCA_DSMARK_VALUE, p->value[cl - 1]);
+       if (nla_put_u8(skb, TCA_DSMARK_MASK, p->mask[cl - 1]) ||
+           nla_put_u8(skb, TCA_DSMARK_VALUE, p->value[cl - 1]))
+               goto nla_put_failure;
 
        return nla_nest_end(skb, opts);
 
@@ -447,13 +448,16 @@ static int dsmark_dump(struct Qdisc *sch, struct sk_buff *skb)
        opts = nla_nest_start(skb, TCA_OPTIONS);
        if (opts == NULL)
                goto nla_put_failure;
-       NLA_PUT_U16(skb, TCA_DSMARK_INDICES, p->indices);
+       if (nla_put_u16(skb, TCA_DSMARK_INDICES, p->indices))
+               goto nla_put_failure;
 
-       if (p->default_index != NO_DEFAULT_INDEX)
-               NLA_PUT_U16(skb, TCA_DSMARK_DEFAULT_INDEX, p->default_index);
+       if (p->default_index != NO_DEFAULT_INDEX &&
+           nla_put_u16(skb, TCA_DSMARK_DEFAULT_INDEX, p->default_index))
+               goto nla_put_failure;
 
-       if (p->set_tc_index)
-               NLA_PUT_FLAG(skb, TCA_DSMARK_SET_TC_INDEX);
+       if (p->set_tc_index &&
+           nla_put_flag(skb, TCA_DSMARK_SET_TC_INDEX))
+               goto nla_put_failure;
 
        return nla_nest_end(skb, opts);
 
index 66effe2da8e0e65775c563a4fc4771429db45411..e15a9eb29087794ccc71408f467e9ae37f9c086b 100644 (file)
@@ -85,7 +85,8 @@ static int fifo_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
        struct tc_fifo_qopt opt = { .limit = sch->limit };
 
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
index 67fc573e013a063b524fa8b85512a28c887689f9..0eb1202c22a64c75f36499b6e91d726ed1597e8d 100644 (file)
@@ -512,7 +512,8 @@ static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
        struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
 
        memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
+               goto nla_put_failure;
        return skb->len;
 
 nla_put_failure:
index 0b15236be7b609251199a36b5fdd0f9b6075b18f..55e3310edc94fee8595b7ca53aa2bb60281485bb 100644 (file)
@@ -521,14 +521,16 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
        opts = nla_nest_start(skb, TCA_OPTIONS);
        if (opts == NULL)
                goto nla_put_failure;
-       NLA_PUT(skb, TCA_GRED_DPS, sizeof(sopt), &sopt);
+       if (nla_put(skb, TCA_GRED_DPS, sizeof(sopt), &sopt))
+               goto nla_put_failure;
 
        for (i = 0; i < MAX_DPs; i++) {
                struct gred_sched_data *q = table->tab[i];
 
                max_p[i] = q ? q->parms.max_P : 0;
        }
-       NLA_PUT(skb, TCA_GRED_MAX_P, sizeof(max_p), max_p);
+       if (nla_put(skb, TCA_GRED_MAX_P, sizeof(max_p), max_p))
+               goto nla_put_failure;
 
        parms = nla_nest_start(skb, TCA_GRED_PARMS);
        if (parms == NULL)
index 9bdca2e011e9122de321353037d4ed2891008601..8db3e2c72827ff28094b20e34f0b26b3815d0437 100644 (file)
@@ -1305,7 +1305,8 @@ hfsc_dump_sc(struct sk_buff *skb, int attr, struct internal_sc *sc)
        tsc.m1 = sm2m(sc->sm1);
        tsc.d  = dx2d(sc->dx);
        tsc.m2 = sm2m(sc->sm2);
-       NLA_PUT(skb, attr, sizeof(tsc), &tsc);
+       if (nla_put(skb, attr, sizeof(tsc), &tsc))
+               goto nla_put_failure;
 
        return skb->len;
 
@@ -1573,7 +1574,8 @@ hfsc_dump_qdisc(struct Qdisc *sch, struct sk_buff *skb)
        }
 
        qopt.defcls = q->defcls;
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(qopt), &qopt))
+               goto nla_put_failure;
        return skb->len;
 
  nla_put_failure:
index 29b942ce9e824866c4d74de75a38c652f1999cb3..2ea6f196e3c823bcf6760af88b554248d93f165a 100644 (file)
@@ -1051,7 +1051,8 @@ static int htb_dump(struct Qdisc *sch, struct sk_buff *skb)
        nest = nla_nest_start(skb, TCA_OPTIONS);
        if (nest == NULL)
                goto nla_put_failure;
-       NLA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt);
+       if (nla_put(skb, TCA_HTB_INIT, sizeof(gopt), &gopt))
+               goto nla_put_failure;
        nla_nest_end(skb, nest);
 
        spin_unlock_bh(root_lock);
@@ -1090,7 +1091,8 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
        opt.quantum = cl->quantum;
        opt.prio = cl->prio;
        opt.level = cl->level;
-       NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_HTB_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
 
        nla_nest_end(skb, nest);
        spin_unlock_bh(root_lock);
index 28de43092330abc125423d5328babc709b1f986f..d1831ca966d4540a2ced9eb88539817773e36898 100644 (file)
@@ -247,7 +247,8 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
                opt.offset[i] = dev->tc_to_txq[i].offset;
        }
 
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
+               goto nla_put_failure;
 
        return skb->len;
 nla_put_failure:
index 49131d7a7446eafb22c121ce987f0fd7e4e233a5..2a2b096d9a664b12a2fa7b4b9a91e4ff9b233f27 100644 (file)
@@ -284,7 +284,8 @@ static int multiq_dump(struct Qdisc *sch, struct sk_buff *skb)
        opt.bands = q->bands;
        opt.max_bands = q->max_bands;
 
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
+               goto nla_put_failure;
 
        return skb->len;
 
index 5da548fa7ae9d46de78f5b75152e1a84b99ca9a7..110973145a4bcd4a25d0521df8afa667790ed79f 100644 (file)
@@ -834,7 +834,8 @@ static int dump_loss_model(const struct netem_sched_data *q,
                        .p23 = q->clg.a5,
                };
 
-               NLA_PUT(skb, NETEM_LOSS_GI, sizeof(gi), &gi);
+               if (nla_put(skb, NETEM_LOSS_GI, sizeof(gi), &gi))
+                       goto nla_put_failure;
                break;
        }
        case CLG_GILB_ELL: {
@@ -845,7 +846,8 @@ static int dump_loss_model(const struct netem_sched_data *q,
                        .k1 = q->clg.a4,
                };
 
-               NLA_PUT(skb, NETEM_LOSS_GE, sizeof(ge), &ge);
+               if (nla_put(skb, NETEM_LOSS_GE, sizeof(ge), &ge))
+                       goto nla_put_failure;
                break;
        }
        }
@@ -874,26 +876,31 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb)
        qopt.loss = q->loss;
        qopt.gap = q->gap;
        qopt.duplicate = q->duplicate;
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(qopt), &qopt))
+               goto nla_put_failure;
 
        cor.delay_corr = q->delay_cor.rho;
        cor.loss_corr = q->loss_cor.rho;
        cor.dup_corr = q->dup_cor.rho;
-       NLA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
+       if (nla_put(skb, TCA_NETEM_CORR, sizeof(cor), &cor))
+               goto nla_put_failure;
 
        reorder.probability = q->reorder;
        reorder.correlation = q->reorder_cor.rho;
-       NLA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
+       if (nla_put(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder))
+               goto nla_put_failure;
 
        corrupt.probability = q->corrupt;
        corrupt.correlation = q->corrupt_cor.rho;
-       NLA_PUT(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt);
+       if (nla_put(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt))
+               goto nla_put_failure;
 
        rate.rate = q->rate;
        rate.packet_overhead = q->packet_overhead;
        rate.cell_size = q->cell_size;
        rate.cell_overhead = q->cell_overhead;
-       NLA_PUT(skb, TCA_NETEM_RATE, sizeof(rate), &rate);
+       if (nla_put(skb, TCA_NETEM_RATE, sizeof(rate), &rate))
+               goto nla_put_failure;
 
        if (dump_loss_model(q, skb) != 0)
                goto nla_put_failure;
index b5d56a22b1d20f2605771ed8360a75f5d2f8ce75..79359b69ad8d6fcf35b6937673d4ae332bbf5158 100644 (file)
@@ -247,7 +247,8 @@ static int prio_dump(struct Qdisc *sch, struct sk_buff *skb)
        opt.bands = q->bands;
        memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX + 1);
 
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
+               goto nla_put_failure;
 
        return skb->len;
 
index e68cb440756a4c33ce1108d464ea51b1c0b95631..9af01f3df18c66b6325c8afe628758b56e306952 100644 (file)
@@ -429,8 +429,9 @@ static int qfq_dump_class(struct Qdisc *sch, unsigned long arg,
        nest = nla_nest_start(skb, TCA_OPTIONS);
        if (nest == NULL)
                goto nla_put_failure;
-       NLA_PUT_U32(skb, TCA_QFQ_WEIGHT, ONE_FP/cl->inv_w);
-       NLA_PUT_U32(skb, TCA_QFQ_LMAX, cl->lmax);
+       if (nla_put_u32(skb, TCA_QFQ_WEIGHT, ONE_FP/cl->inv_w) ||
+           nla_put_u32(skb, TCA_QFQ_LMAX, cl->lmax))
+               goto nla_put_failure;
        return nla_nest_end(skb, nest);
 
 nla_put_failure:
index a5cc3012cf42902a496276d8c4e0932b6ae4b53f..633e32defdcc61291554e9457d5e13c2f6b87a1e 100644 (file)
@@ -272,8 +272,9 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
        opts = nla_nest_start(skb, TCA_OPTIONS);
        if (opts == NULL)
                goto nla_put_failure;
-       NLA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt);
-       NLA_PUT_U32(skb, TCA_RED_MAX_P, q->parms.max_P);
+       if (nla_put(skb, TCA_RED_PARMS, sizeof(opt), &opt) ||
+           nla_put_u32(skb, TCA_RED_MAX_P, q->parms.max_P))
+               goto nla_put_failure;
        return nla_nest_end(skb, opts);
 
 nla_put_failure:
index d7eea99333e96a33a953106a3a0f2fdb32a12385..74305c883bd3ee842c535bbc27f003d389207346 100644 (file)
@@ -570,7 +570,8 @@ static int sfb_dump(struct Qdisc *sch, struct sk_buff *skb)
 
        sch->qstats.backlog = q->qdisc->qstats.backlog;
        opts = nla_nest_start(skb, TCA_OPTIONS);
-       NLA_PUT(skb, TCA_SFB_PARMS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_SFB_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
        return nla_nest_end(skb, opts);
 
 nla_put_failure:
index 02a21abea65e20c207fe77d81f0240957c259970..d3a1bc26dbfc536350ebaaecfdcb5426b7eacec5 100644 (file)
@@ -812,7 +812,8 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
        memcpy(&opt.stats, &q->stats, sizeof(opt.stats));
        opt.flags       = q->flags;
 
-       NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
+               goto nla_put_failure;
 
        return skb->len;
 
index b8e156319d7bc48c261ccad7110bbeb84ba44856..4b056c15e90c7f79ed7f37236fd5ace197092114 100644 (file)
@@ -359,7 +359,8 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
                memset(&opt.peakrate, 0, sizeof(opt.peakrate));
        opt.mtu = q->mtu;
        opt.buffer = q->buffer;
-       NLA_PUT(skb, TCA_TBF_PARMS, sizeof(opt), &opt);
+       if (nla_put(skb, TCA_TBF_PARMS, sizeof(opt), &opt))
+               goto nla_put_failure;
 
        nla_nest_end(skb, nest);
        return skb->len;