]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sched/sch_tbf.c
svc: Add a generic transport svc_create_xprt function
[linux-2.6-omap-h63xx.git] / net / sched / sch_tbf.c
index 6c4ad7e677b3486e43a65cc2a3424f7dbc15ec7f..0b7d78f59d8cb727c1ac0506a5cbdf8cd36f153f 100644 (file)
@@ -270,9 +270,15 @@ static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
        return NULL;
 }
 
+static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = {
+       [TCA_TBF_PARMS] = { .len = sizeof(struct tc_tbf_qopt) },
+       [TCA_TBF_RTAB]  = { .type = NLA_BINARY, .len = TC_RTAB_SIZE },
+       [TCA_TBF_PTAB]  = { .type = NLA_BINARY, .len = TC_RTAB_SIZE },
+};
+
 static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
 {
-       int err = -EINVAL;
+       int err;
        struct tbf_sched_data *q = qdisc_priv(sch);
        struct nlattr *tb[TCA_TBF_PTAB + 1];
        struct tc_tbf_qopt *qopt;
@@ -281,9 +287,12 @@ static int tbf_change(struct Qdisc* sch, struct nlattr *opt)
        struct Qdisc *child = NULL;
        int max_size,n;
 
-       if (nla_parse_nested(tb, TCA_TBF_PTAB, opt, NULL) ||
-           tb[TCA_TBF_PARMS] == NULL ||
-           nla_len(tb[TCA_TBF_PARMS]) < sizeof(*qopt))
+       err = nla_parse_nested(tb, TCA_TBF_PTAB, opt, tbf_policy);
+       if (err < 0)
+               return err;
+
+       err = -EINVAL;
+       if (tb[TCA_TBF_PARMS] == NULL)
                goto done;
 
        qopt = nla_data(tb[TCA_TBF_PARMS]);
@@ -371,12 +380,12 @@ static void tbf_destroy(struct Qdisc *sch)
 static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
        struct tbf_sched_data *q = qdisc_priv(sch);
-       unsigned char *b = skb_tail_pointer(skb);
-       struct nlattr *nla;
+       struct nlattr *nest;
        struct tc_tbf_qopt opt;
 
-       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;
 
        opt.limit = q->limit;
        opt.rate = q->R_tab->rate;
@@ -387,12 +396,12 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
        opt.mtu = q->mtu;
        opt.buffer = q->buffer;
        NLA_PUT(skb, TCA_TBF_PARMS, sizeof(opt), &opt);
-       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;
 }