diff options
Diffstat (limited to 'net/sched/act_simple.c')
-rw-r--r-- | net/sched/act_simple.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index fb84ef33d14f..fbde461b716c 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c @@ -84,30 +84,37 @@ static int realloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata) return alloc_defdata(d, datalen, defdata); } -static int tcf_simp_init(struct rtattr *rta, struct rtattr *est, +static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { + [TCA_DEF_PARMS] = { .len = sizeof(struct tc_defact) }, +}; + +static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, struct tc_action *a, int ovr, int bind) { - struct rtattr *tb[TCA_DEF_MAX]; + struct nlattr *tb[TCA_DEF_MAX + 1]; struct tc_defact *parm; struct tcf_defact *d; struct tcf_common *pc; void *defdata; u32 datalen = 0; - int ret = 0; + int ret = 0, err; - if (rta == NULL || rtattr_parse_nested(tb, TCA_DEF_MAX, rta) < 0) + if (nla == NULL) return -EINVAL; - if (tb[TCA_DEF_PARMS - 1] == NULL || - RTA_PAYLOAD(tb[TCA_DEF_PARMS - 1]) < sizeof(*parm)) + err = nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL); + if (err < 0) + return err; + + if (tb[TCA_DEF_PARMS] == NULL) return -EINVAL; - parm = RTA_DATA(tb[TCA_DEF_PARMS - 1]); - defdata = RTA_DATA(tb[TCA_DEF_DATA - 1]); + parm = nla_data(tb[TCA_DEF_PARMS]); + defdata = nla_data(tb[TCA_DEF_DATA]); if (defdata == NULL) return -EINVAL; - datalen = RTA_PAYLOAD(tb[TCA_DEF_DATA - 1]); + datalen = nla_len(tb[TCA_DEF_DATA]); if (datalen <= 0) return -EINVAL; @@ -164,15 +171,15 @@ static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, opt.refcnt = d->tcf_refcnt - ref; opt.bindcnt = d->tcf_bindcnt - bind; opt.action = d->tcf_action; - RTA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); - RTA_PUT(skb, TCA_DEF_DATA, d->tcfd_datalen, d->tcfd_defdata); + NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); + NLA_PUT(skb, TCA_DEF_DATA, d->tcfd_datalen, d->tcfd_defdata); t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); t.expires = jiffies_to_clock_t(d->tcf_tm.expires); - RTA_PUT(skb, TCA_DEF_TM, sizeof(t), &t); + NLA_PUT(skb, TCA_DEF_TM, sizeof(t), &t); return skb->len; -rtattr_failure: +nla_put_failure: nlmsg_trim(skb, b); return -1; } |