]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sched/act_police.c
Merge branch 'linus' into x86/pat
[linux-2.6-omap-h63xx.git] / net / sched / act_police.c
index ee2f1b64dd70942eccbd68e97d3e948794318b0d..0898120bbcc0b64ecf79e8ec589a7dad6c0cda70 100644 (file)
@@ -119,6 +119,13 @@ static void tcf_police_destroy(struct tcf_police *p)
        BUG_TRAP(0);
 }
 
+static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {
+       [TCA_POLICE_RATE]       = { .len = TC_RTAB_SIZE },
+       [TCA_POLICE_PEAKRATE]   = { .len = TC_RTAB_SIZE },
+       [TCA_POLICE_AVRATE]     = { .type = NLA_U32 },
+       [TCA_POLICE_RESULT]     = { .type = NLA_U32 },
+};
+
 static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est,
                                 struct tc_action *a, int ovr, int bind)
 {
@@ -133,7 +140,7 @@ static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est,
        if (nla == NULL)
                return -EINVAL;
 
-       err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, NULL);
+       err = nla_parse_nested(tb, TCA_POLICE_MAX, nla, police_policy);
        if (err < 0)
                return err;
 
@@ -144,13 +151,6 @@ static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est,
                return -EINVAL;
        parm = nla_data(tb[TCA_POLICE_TBF]);
 
-       if (tb[TCA_POLICE_RESULT] != NULL &&
-           nla_len(tb[TCA_POLICE_RESULT]) != sizeof(u32))
-               return -EINVAL;
-       if (tb[TCA_POLICE_RESULT] != NULL &&
-           nla_len(tb[TCA_POLICE_RESULT]) != sizeof(u32))
-               return -EINVAL;
-
        if (parm->index) {
                struct tcf_common *pc;
 
@@ -203,7 +203,7 @@ override:
        }
 
        if (tb[TCA_POLICE_RESULT])
-               police->tcfp_result = *(u32*)nla_data(tb[TCA_POLICE_RESULT]);
+               police->tcfp_result = nla_get_u32(tb[TCA_POLICE_RESULT]);
        police->tcfp_toks = police->tcfp_burst = parm->burst;
        police->tcfp_mtu = parm->mtu;
        if (police->tcfp_mtu == 0) {
@@ -216,8 +216,7 @@ override:
        police->tcf_action = parm->action;
 
        if (tb[TCA_POLICE_AVRATE])
-               police->tcfp_ewma_rate =
-                       *(u32*)nla_data(tb[TCA_POLICE_AVRATE]);
+               police->tcfp_ewma_rate = nla_get_u32(tb[TCA_POLICE_AVRATE]);
        if (est)
                gen_replace_estimator(&police->tcf_bstats,
                                      &police->tcf_rate_est,
@@ -339,10 +338,9 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
                memset(&opt.peakrate, 0, sizeof(opt.peakrate));
        NLA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt);
        if (police->tcfp_result)
-               NLA_PUT(skb, TCA_POLICE_RESULT, sizeof(int),
-                       &police->tcfp_result);
+               NLA_PUT_U32(skb, TCA_POLICE_RESULT, police->tcfp_result);
        if (police->tcfp_ewma_rate)
-               NLA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate);
+               NLA_PUT_U32(skb, TCA_POLICE_AVRATE, police->tcfp_ewma_rate);
        return skb->len;
 
 nla_put_failure: