]> err.no Git - linux-2.6/blobdiff - net/sched/sch_atm.c
the scheduled ieee80211 softmac removal
[linux-2.6] / net / sched / sch_atm.c
index aaa32a22726d1da6370f686db675ab9fdda06c40..33527341638427c3bf9e97385a7f7d5ba37f07d8 100644 (file)
@@ -195,6 +195,11 @@ static const u8 llc_oui_ip[] = {
        0x08, 0x00
 };                             /* Ethertype IP (0800) */
 
+static const struct nla_policy atm_policy[TCA_ATM_MAX + 1] = {
+       [TCA_ATM_FD]            = { .type = NLA_U32 },
+       [TCA_ATM_EXCESS]        = { .type = NLA_U32 },
+};
+
 static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
                         struct nlattr **tca, unsigned long *arg)
 {
@@ -225,13 +230,14 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
                return -EBUSY;
        if (opt == NULL)
                return -EINVAL;
-       error = nla_parse_nested(tb, TCA_ATM_MAX, opt, NULL);
+
+       error = nla_parse_nested(tb, TCA_ATM_MAX, opt, atm_policy);
        if (error < 0)
                return error;
 
-       if (!tb[TCA_ATM_FD] || nla_len(tb[TCA_ATM_FD]) < sizeof(fd))
+       if (!tb[TCA_ATM_FD])
                return -EINVAL;
-       fd = *(int *)nla_data(tb[TCA_ATM_FD]);
+       fd = nla_get_u32(tb[TCA_ATM_FD]);
        pr_debug("atm_tc_change: fd %d\n", fd);
        if (tb[TCA_ATM_HDR]) {
                hdr_len = nla_len(tb[TCA_ATM_HDR]);
@@ -243,10 +249,8 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
        if (!tb[TCA_ATM_EXCESS])
                excess = NULL;
        else {
-               if (nla_len(tb[TCA_ATM_EXCESS]) != sizeof(u32))
-                       return -EINVAL;
                excess = (struct atm_flow_data *)
-                       atm_tc_get(sch, *(u32 *)nla_data(tb[TCA_ATM_EXCESS]));
+                       atm_tc_get(sch, nla_get_u32(tb[TCA_ATM_EXCESS]));
                if (!excess)
                        return -ENOENT;
        }
@@ -605,8 +609,7 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
 {
        struct atm_qdisc_data *p = qdisc_priv(sch);
        struct atm_flow_data *flow = (struct atm_flow_data *)cl;
-       unsigned char *b = skb_tail_pointer(skb);
-       struct nlattr *nla;
+       struct nlattr *nest;
 
        pr_debug("atm_tc_dump_class(sch %p,[qdisc %p],flow %p,skb %p,tcm %p)\n",
                sch, p, flow, skb, tcm);
@@ -614,8 +617,11 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
                return -EINVAL;
        tcm->tcm_handle = flow->classid;
        tcm->tcm_info = flow->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;
+
        NLA_PUT(skb, TCA_ATM_HDR, flow->hdr_len, flow->hdr);
        if (flow->vcc) {
                struct sockaddr_atmpvc pvc;
@@ -627,20 +633,19 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl,
                pvc.sap_addr.vci = flow->vcc->vci;
                NLA_PUT(skb, TCA_ATM_ADDR, sizeof(pvc), &pvc);
                state = ATM_VF2VS(flow->vcc->flags);
-               NLA_PUT(skb, TCA_ATM_STATE, sizeof(state), &state);
+               NLA_PUT_U32(skb, TCA_ATM_STATE, state);
        }
        if (flow->excess)
-               NLA_PUT(skb, TCA_ATM_EXCESS, sizeof(u32), &flow->classid);
+               NLA_PUT_U32(skb, TCA_ATM_EXCESS, flow->classid);
        else {
-               static u32 zero;
-
-               NLA_PUT(skb, TCA_ATM_EXCESS, sizeof(zero), &zero);
+               NLA_PUT_U32(skb, TCA_ATM_EXCESS, 0);
        }
-       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;
 }
 static int