X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=net%2Fsched%2Fcls_rsvp.h;h=7034ea4530e578c0e59da24ece7dc1790125d4cb;hb=e857b33d1879fc4284e3151222eee2415c1de88a;hp=77097e023f77b3b2c0150b6be85ef33f9c426f66;hpb=4b3550ef530cfc153fa91f0b37cbda448bad11c6;p=linux-2.6-omap-h63xx.git diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index 77097e023f7..7034ea4530e 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h @@ -397,6 +397,15 @@ static u32 gen_tunnel(struct rsvp_head *data) return 0; } +static const struct nla_policy rsvp_policy[TCA_RSVP_MAX + 1] = { + [TCA_RSVP_CLASSID] = { .type = NLA_U32 }, + [TCA_RSVP_DST] = { .type = NLA_BINARY, + .len = RSVP_DST_LEN * sizeof(u32) }, + [TCA_RSVP_SRC] = { .type = NLA_BINARY, + .len = RSVP_DST_LEN * sizeof(u32) }, + [TCA_RSVP_PINFO] = { .len = sizeof(struct tc_rsvp_pinfo) }, +}; + static int rsvp_change(struct tcf_proto *tp, unsigned long base, u32 handle, struct nlattr **tca, @@ -416,7 +425,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, if (opt == NULL) return handle ? -EINVAL : 0; - err = nla_parse_nested(tb, TCA_RSVP_MAX, opt, NULL); + err = nla_parse_nested(tb, TCA_RSVP_MAX, opt, rsvp_policy); if (err < 0) return err; @@ -430,7 +439,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, if (f->handle != handle && handle) goto errout2; if (tb[TCA_RSVP_CLASSID-1]) { - f->res.classid = *(u32*)nla_data(tb[TCA_RSVP_CLASSID-1]); + f->res.classid = nla_get_u32(tb[TCA_RSVP_CLASSID-1]); tcf_bind_filter(tp, &f->res, base); } @@ -452,30 +461,17 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, h2 = 16; if (tb[TCA_RSVP_SRC-1]) { - err = -EINVAL; - if (nla_len(tb[TCA_RSVP_SRC-1]) != sizeof(f->src)) - goto errout; memcpy(f->src, nla_data(tb[TCA_RSVP_SRC-1]), sizeof(f->src)); h2 = hash_src(f->src); } if (tb[TCA_RSVP_PINFO-1]) { - err = -EINVAL; - if (nla_len(tb[TCA_RSVP_PINFO-1]) < sizeof(struct tc_rsvp_pinfo)) - goto errout; pinfo = nla_data(tb[TCA_RSVP_PINFO-1]); f->spi = pinfo->spi; f->tunnelhdr = pinfo->tunnelhdr; } - if (tb[TCA_RSVP_CLASSID-1]) { - err = -EINVAL; - if (nla_len(tb[TCA_RSVP_CLASSID-1]) != 4) - goto errout; - f->res.classid = *(u32*)nla_data(tb[TCA_RSVP_CLASSID-1]); - } + if (tb[TCA_RSVP_CLASSID-1]) + f->res.classid = nla_get_u32(tb[TCA_RSVP_CLASSID-1]); - err = -EINVAL; - if (nla_len(tb[TCA_RSVP_DST-1]) != sizeof(f->src)) - goto errout; dst = nla_data(tb[TCA_RSVP_DST-1]); h1 = hash_dst(dst, pinfo ? pinfo->protocol : 0, pinfo ? pinfo->tunnelid : 0); @@ -617,7 +613,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, pinfo.pad = 0; NLA_PUT(skb, TCA_RSVP_PINFO, sizeof(pinfo), &pinfo); if (f->res.classid) - NLA_PUT(skb, TCA_RSVP_CLASSID, 4, &f->res.classid); + NLA_PUT_U32(skb, TCA_RSVP_CLASSID, f->res.classid); if (((f->handle>>8)&0xFF) != 16) NLA_PUT(skb, TCA_RSVP_SRC, sizeof(f->src), f->src);