[NET_SCHED]: Use nla_nest_start/nla_nest_end
[linux-2.6-block.git] / net / sched / sch_cbq.c
index 585f8a6ec7ec2315ea861f3c135a27585e9e8450..da0f6c0152de8f261f698e9bc8f3ed97e29e271f 100644 (file)
@@ -1565,18 +1565,18 @@ static int cbq_dump_attr(struct sk_buff *skb, struct cbq_class *cl)
 static int cbq_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
        struct cbq_sched_data *q = qdisc_priv(sch);
-       unsigned char *b = skb_tail_pointer(skb);
-       struct nlattr *nla;
+       struct nlattr *nest;
 
-       nla = (struct nlattr*)b;
-       NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
+       nest = nla_nest_start(skb, TCA_OPTIONS);
+       if (nest == NULL)
+               goto nla_put_failure;
        if (cbq_dump_attr(skb, &q->link) < 0)
                goto nla_put_failure;
-       nla->nla_len = skb_tail_pointer(skb) - b;
+       nla_nest_end(skb, nest);
        return skb->len;
 
 nla_put_failure:
-       nlmsg_trim(skb, b);
+       nla_nest_cancel(skb, nest);
        return -1;
 }
 
@@ -1594,8 +1594,7 @@ cbq_dump_class(struct Qdisc *sch, unsigned long arg,
               struct sk_buff *skb, struct tcmsg *tcm)
 {
        struct cbq_class *cl = (struct cbq_class*)arg;
-       unsigned char *b = skb_tail_pointer(skb);
-       struct nlattr *nla;
+       struct nlattr *nest;
 
        if (cl->tparent)
                tcm->tcm_parent = cl->tparent->classid;
@@ -1604,15 +1603,16 @@ cbq_dump_class(struct Qdisc *sch, unsigned long arg,
        tcm->tcm_handle = cl->classid;
        tcm->tcm_info = cl->q->handle;
 
-       nla = (struct nlattr*)b;
-       NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
+       nest = nla_nest_start(skb, TCA_OPTIONS);
+       if (nest == NULL)
+               goto nla_put_failure;
        if (cbq_dump_attr(skb, cl) < 0)
                goto nla_put_failure;
-       nla->nla_len = skb_tail_pointer(skb) - b;
+       nla_nest_end(skb, nest);
        return skb->len;
 
 nla_put_failure:
-       nlmsg_trim(skb, b);
+       nla_nest_cancel(skb, nest);
        return -1;
 }