]> err.no Git - linux-2.6/commitdiff
[PKT_SCHED]: Make dsmark use the new dumping macros
authorThomas Graf <tgraf@suug.ch>
Sun, 19 Jun 2005 05:53:12 +0000 (22:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 19 Jun 2005 05:53:12 +0000 (22:53 -0700)
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_dsmark.c

index 66abf139f4bf14901b69b0e1b593659f5230f647..ac0efeae312e4532a33e565c5411757365d19c46 100644 (file)
@@ -428,50 +428,46 @@ static void dsmark_destroy(struct Qdisc *sch)
 
 
 static int dsmark_dump_class(struct Qdisc *sch, unsigned long cl,
-    struct sk_buff *skb, struct tcmsg *tcm)
+                            struct sk_buff *skb, struct tcmsg *tcm)
 {
        struct dsmark_qdisc_data *p = PRIV(sch);
-       unsigned char *b = skb->tail;
-       struct rtattr *rta;
+       struct rtattr *opts = NULL;
 
-       DPRINTK("dsmark_dump_class(sch %p,[qdisc %p],class %ld\n",sch,p,cl);
-       if (!cl || cl > p->indices)
+       DPRINTK("dsmark_dump_class(sch %p,[qdisc %p],class %ld\n", sch, p, cl);
+
+       if (!dsmark_valid_index(p, cl))
                return -EINVAL;
-       tcm->tcm_handle = TC_H_MAKE(TC_H_MAJ(sch->handle),cl-1);
-       rta = (struct rtattr *) b;
-       RTA_PUT(skb,TCA_OPTIONS,0,NULL);
-       RTA_PUT(skb,TCA_DSMARK_MASK,1,&p->mask[cl-1]);
-       RTA_PUT(skb,TCA_DSMARK_VALUE,1,&p->value[cl-1]);
-       rta->rta_len = skb->tail-b;
-       return skb->len;
+
+       tcm->tcm_handle = TC_H_MAKE(TC_H_MAJ(sch->handle), cl-1);
+
+       opts = RTA_NEST(skb, TCA_OPTIONS);
+       RTA_PUT_U8(skb,TCA_DSMARK_MASK, p->mask[cl-1]);
+       RTA_PUT_U8(skb,TCA_DSMARK_VALUE, p->value[cl-1]);
+
+       return RTA_NEST_END(skb, opts);
 
 rtattr_failure:
-       skb_trim(skb,b-skb->data);
-       return -1;
+       return RTA_NEST_CANCEL(skb, opts);
 }
 
 static int dsmark_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
        struct dsmark_qdisc_data *p = PRIV(sch);
-       unsigned char *b = skb->tail;
-       struct rtattr *rta;
+       struct rtattr *opts = NULL;
 
-       rta = (struct rtattr *) b;
-       RTA_PUT(skb,TCA_OPTIONS,0,NULL);
-       RTA_PUT(skb,TCA_DSMARK_INDICES,sizeof(__u16),&p->indices);
-       if (p->default_index != NO_DEFAULT_INDEX) {
-               __u16 tmp = p->default_index;
+       opts = RTA_NEST(skb, TCA_OPTIONS);
+       RTA_PUT_U16(skb, TCA_DSMARK_INDICES, p->indices);
+
+       if (p->default_index != NO_DEFAULT_INDEX)
+               RTA_PUT_U16(skb, TCA_DSMARK_DEFAULT_INDEX, p->default_index);
 
-               RTA_PUT(skb,TCA_DSMARK_DEFAULT_INDEX, sizeof(__u16), &tmp);
-       }
        if (p->set_tc_index)
-               RTA_PUT(skb, TCA_DSMARK_SET_TC_INDEX, 0, NULL);
-       rta->rta_len = skb->tail-b;
-       return skb->len;
+               RTA_PUT_FLAG(skb, TCA_DSMARK_SET_TC_INDEX);
+
+       return RTA_NEST_END(skb, opts);
 
 rtattr_failure:
-       skb_trim(skb,b-skb->data);
-       return -1;
+       return RTA_NEST_CANCEL(skb, opts);
 }
 
 static struct Qdisc_class_ops dsmark_class_ops = {