diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-23 01:11:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:11:11 -0500 |
commit | add93b610a4e66d36d0cf0b2596c3d3bcfdaee39 (patch) | |
tree | 073873879eb3b87981ee015f0f1ca48da8f1c696 /net/sched/cls_tcindex.c | |
parent | 1e90474c377e92db7262a8968a45c1dd980ca9e5 (diff) |
[NET_SCHED]: Convert classifiers from rtnetlink to new netlink API
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_tcindex.c')
-rw-r--r-- | net/sched/cls_tcindex.c | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index e36977b17fa6..ed8023944fe5 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c | |||
@@ -196,7 +196,7 @@ valid_perfect_hash(struct tcindex_data *p) | |||
196 | static int | 196 | static int |
197 | tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | 197 | tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, |
198 | struct tcindex_data *p, struct tcindex_filter_result *r, | 198 | struct tcindex_data *p, struct tcindex_filter_result *r, |
199 | struct rtattr **tb, struct rtattr *est) | 199 | struct nlattr **tb, struct nlattr *est) |
200 | { | 200 | { |
201 | int err, balloc = 0; | 201 | int err, balloc = 0; |
202 | struct tcindex_filter_result new_filter_result, *old_r = r; | 202 | struct tcindex_filter_result new_filter_result, *old_r = r; |
@@ -218,22 +218,22 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
218 | memset(&cr, 0, sizeof(cr)); | 218 | memset(&cr, 0, sizeof(cr)); |
219 | 219 | ||
220 | err = -EINVAL; | 220 | err = -EINVAL; |
221 | if (tb[TCA_TCINDEX_HASH-1]) { | 221 | if (tb[TCA_TCINDEX_HASH]) { |
222 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_HASH-1]) < sizeof(u32)) | 222 | if (nla_len(tb[TCA_TCINDEX_HASH]) < sizeof(u32)) |
223 | goto errout; | 223 | goto errout; |
224 | cp.hash = *(u32 *) RTA_DATA(tb[TCA_TCINDEX_HASH-1]); | 224 | cp.hash = *(u32 *) nla_data(tb[TCA_TCINDEX_HASH]); |
225 | } | 225 | } |
226 | 226 | ||
227 | if (tb[TCA_TCINDEX_MASK-1]) { | 227 | if (tb[TCA_TCINDEX_MASK]) { |
228 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_MASK-1]) < sizeof(u16)) | 228 | if (nla_len(tb[TCA_TCINDEX_MASK]) < sizeof(u16)) |
229 | goto errout; | 229 | goto errout; |
230 | cp.mask = *(u16 *) RTA_DATA(tb[TCA_TCINDEX_MASK-1]); | 230 | cp.mask = *(u16 *) nla_data(tb[TCA_TCINDEX_MASK]); |
231 | } | 231 | } |
232 | 232 | ||
233 | if (tb[TCA_TCINDEX_SHIFT-1]) { | 233 | if (tb[TCA_TCINDEX_SHIFT]) { |
234 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_SHIFT-1]) < sizeof(int)) | 234 | if (nla_len(tb[TCA_TCINDEX_SHIFT]) < sizeof(int)) |
235 | goto errout; | 235 | goto errout; |
236 | cp.shift = *(int *) RTA_DATA(tb[TCA_TCINDEX_SHIFT-1]); | 236 | cp.shift = *(int *) nla_data(tb[TCA_TCINDEX_SHIFT]); |
237 | } | 237 | } |
238 | 238 | ||
239 | err = -EBUSY; | 239 | err = -EBUSY; |
@@ -248,11 +248,11 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
248 | goto errout; | 248 | goto errout; |
249 | 249 | ||
250 | err = -EINVAL; | 250 | err = -EINVAL; |
251 | if (tb[TCA_TCINDEX_FALL_THROUGH-1]) { | 251 | if (tb[TCA_TCINDEX_FALL_THROUGH]) { |
252 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_FALL_THROUGH-1]) < sizeof(u32)) | 252 | if (nla_len(tb[TCA_TCINDEX_FALL_THROUGH]) < sizeof(u32)) |
253 | goto errout; | 253 | goto errout; |
254 | cp.fall_through = | 254 | cp.fall_through = |
255 | *(u32 *) RTA_DATA(tb[TCA_TCINDEX_FALL_THROUGH-1]); | 255 | *(u32 *) nla_data(tb[TCA_TCINDEX_FALL_THROUGH]); |
256 | } | 256 | } |
257 | 257 | ||
258 | if (!cp.hash) { | 258 | if (!cp.hash) { |
@@ -304,8 +304,8 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
304 | goto errout_alloc; | 304 | goto errout_alloc; |
305 | } | 305 | } |
306 | 306 | ||
307 | if (tb[TCA_TCINDEX_CLASSID-1]) { | 307 | if (tb[TCA_TCINDEX_CLASSID]) { |
308 | cr.res.classid = *(u32 *) RTA_DATA(tb[TCA_TCINDEX_CLASSID-1]); | 308 | cr.res.classid = *(u32 *) nla_data(tb[TCA_TCINDEX_CLASSID]); |
309 | tcf_bind_filter(tp, &cr.res, base); | 309 | tcf_bind_filter(tp, &cr.res, base); |
310 | } | 310 | } |
311 | 311 | ||
@@ -344,10 +344,10 @@ errout: | |||
344 | 344 | ||
345 | static int | 345 | static int |
346 | tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, | 346 | tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, |
347 | struct rtattr **tca, unsigned long *arg) | 347 | struct nlattr **tca, unsigned long *arg) |
348 | { | 348 | { |
349 | struct rtattr *opt = tca[TCA_OPTIONS-1]; | 349 | struct nlattr *opt = tca[TCA_OPTIONS]; |
350 | struct rtattr *tb[TCA_TCINDEX_MAX]; | 350 | struct nlattr *tb[TCA_TCINDEX_MAX + 1]; |
351 | struct tcindex_data *p = PRIV(tp); | 351 | struct tcindex_data *p = PRIV(tp); |
352 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg; | 352 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg; |
353 | 353 | ||
@@ -358,10 +358,10 @@ tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
358 | if (!opt) | 358 | if (!opt) |
359 | return 0; | 359 | return 0; |
360 | 360 | ||
361 | if (rtattr_parse_nested(tb, TCA_TCINDEX_MAX, opt) < 0) | 361 | if (nla_parse_nested(tb, TCA_TCINDEX_MAX, opt, NULL) < 0) |
362 | return -EINVAL; | 362 | return -EINVAL; |
363 | 363 | ||
364 | return tcindex_set_parms(tp, base, handle, p, r, tb, tca[TCA_RATE-1]); | 364 | return tcindex_set_parms(tp, base, handle, p, r, tb, tca[TCA_RATE]); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
@@ -435,21 +435,21 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, | |||
435 | struct tcindex_data *p = PRIV(tp); | 435 | struct tcindex_data *p = PRIV(tp); |
436 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; | 436 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; |
437 | unsigned char *b = skb_tail_pointer(skb); | 437 | unsigned char *b = skb_tail_pointer(skb); |
438 | struct rtattr *rta; | 438 | struct nlattr *nla; |
439 | 439 | ||
440 | pr_debug("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n", | 440 | pr_debug("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n", |
441 | tp, fh, skb, t, p, r, b); | 441 | tp, fh, skb, t, p, r, b); |
442 | pr_debug("p->perfect %p p->h %p\n", p->perfect, p->h); | 442 | pr_debug("p->perfect %p p->h %p\n", p->perfect, p->h); |
443 | rta = (struct rtattr *) b; | 443 | nla = (struct nlattr *) b; |
444 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 444 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
445 | if (!fh) { | 445 | if (!fh) { |
446 | t->tcm_handle = ~0; /* whatever ... */ | 446 | t->tcm_handle = ~0; /* whatever ... */ |
447 | RTA_PUT(skb, TCA_TCINDEX_HASH, sizeof(p->hash), &p->hash); | 447 | NLA_PUT(skb, TCA_TCINDEX_HASH, sizeof(p->hash), &p->hash); |
448 | RTA_PUT(skb, TCA_TCINDEX_MASK, sizeof(p->mask), &p->mask); | 448 | NLA_PUT(skb, TCA_TCINDEX_MASK, sizeof(p->mask), &p->mask); |
449 | RTA_PUT(skb, TCA_TCINDEX_SHIFT, sizeof(p->shift), &p->shift); | 449 | NLA_PUT(skb, TCA_TCINDEX_SHIFT, sizeof(p->shift), &p->shift); |
450 | RTA_PUT(skb, TCA_TCINDEX_FALL_THROUGH, sizeof(p->fall_through), | 450 | NLA_PUT(skb, TCA_TCINDEX_FALL_THROUGH, sizeof(p->fall_through), |
451 | &p->fall_through); | 451 | &p->fall_through); |
452 | rta->rta_len = skb_tail_pointer(skb) - b; | 452 | nla->nla_len = skb_tail_pointer(skb) - b; |
453 | } else { | 453 | } else { |
454 | if (p->perfect) { | 454 | if (p->perfect) { |
455 | t->tcm_handle = r-p->perfect; | 455 | t->tcm_handle = r-p->perfect; |
@@ -468,19 +468,19 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, | |||
468 | } | 468 | } |
469 | pr_debug("handle = %d\n", t->tcm_handle); | 469 | pr_debug("handle = %d\n", t->tcm_handle); |
470 | if (r->res.class) | 470 | if (r->res.class) |
471 | RTA_PUT(skb, TCA_TCINDEX_CLASSID, 4, &r->res.classid); | 471 | NLA_PUT(skb, TCA_TCINDEX_CLASSID, 4, &r->res.classid); |
472 | 472 | ||
473 | if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) | 473 | if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) |
474 | goto rtattr_failure; | 474 | goto nla_put_failure; |
475 | rta->rta_len = skb_tail_pointer(skb) - b; | 475 | nla->nla_len = skb_tail_pointer(skb) - b; |
476 | 476 | ||
477 | if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0) | 477 | if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0) |
478 | goto rtattr_failure; | 478 | goto nla_put_failure; |
479 | } | 479 | } |
480 | 480 | ||
481 | return skb->len; | 481 | return skb->len; |
482 | 482 | ||
483 | rtattr_failure: | 483 | nla_put_failure: |
484 | nlmsg_trim(skb, b); | 484 | nlmsg_trim(skb, b); |
485 | return -1; | 485 | return -1; |
486 | } | 486 | } |