diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-23 01:11:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:11:10 -0500 |
commit | 1e90474c377e92db7262a8968a45c1dd980ca9e5 (patch) | |
tree | 645af56dcb17cf1a76fd3b7f1a8b833a3fffc3d7 /net/sched/sch_netem.c | |
parent | 01480e1cf5e2118eba8a8968239f3242072f9563 (diff) |
[NET_SCHED]: Convert packet schedulers from rtnetlink to new netlink API
Convert packet schedulers to use the netlink API. Unfortunately a gradual
conversion is not possible without breaking compilation in the middle or
adding lots of casts, so this patch converts them all in one step. The
patch has been mostly generated automatically with some minor edits to
at least allow seperate conversion of classifiers and actions.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_netem.c')
-rw-r--r-- | net/sched/sch_netem.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 6c344ade33c2..a7b58df4546d 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -313,21 +313,21 @@ static void netem_reset(struct Qdisc *sch) | |||
313 | /* Pass size change message down to embedded FIFO */ | 313 | /* Pass size change message down to embedded FIFO */ |
314 | static int set_fifo_limit(struct Qdisc *q, int limit) | 314 | static int set_fifo_limit(struct Qdisc *q, int limit) |
315 | { | 315 | { |
316 | struct rtattr *rta; | 316 | struct nlattr *nla; |
317 | int ret = -ENOMEM; | 317 | int ret = -ENOMEM; |
318 | 318 | ||
319 | /* Hack to avoid sending change message to non-FIFO */ | 319 | /* Hack to avoid sending change message to non-FIFO */ |
320 | if (strncmp(q->ops->id + 1, "fifo", 4) != 0) | 320 | if (strncmp(q->ops->id + 1, "fifo", 4) != 0) |
321 | return 0; | 321 | return 0; |
322 | 322 | ||
323 | rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL); | 323 | nla = kmalloc(nla_attr_size(sizeof(struct tc_fifo_qopt)), GFP_KERNEL); |
324 | if (rta) { | 324 | if (nla) { |
325 | rta->rta_type = RTM_NEWQDISC; | 325 | nla->nla_type = RTM_NEWQDISC; |
326 | rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt)); | 326 | nla->nla_len = nla_attr_size(sizeof(struct tc_fifo_qopt)); |
327 | ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit; | 327 | ((struct tc_fifo_qopt *)nla_data(nla))->limit = limit; |
328 | 328 | ||
329 | ret = q->ops->change(q, rta); | 329 | ret = q->ops->change(q, nla); |
330 | kfree(rta); | 330 | kfree(nla); |
331 | } | 331 | } |
332 | return ret; | 332 | return ret; |
333 | } | 333 | } |
@@ -336,11 +336,11 @@ static int set_fifo_limit(struct Qdisc *q, int limit) | |||
336 | * Distribution data is a variable size payload containing | 336 | * Distribution data is a variable size payload containing |
337 | * signed 16 bit values. | 337 | * signed 16 bit values. |
338 | */ | 338 | */ |
339 | static int get_dist_table(struct Qdisc *sch, const struct rtattr *attr) | 339 | static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr) |
340 | { | 340 | { |
341 | struct netem_sched_data *q = qdisc_priv(sch); | 341 | struct netem_sched_data *q = qdisc_priv(sch); |
342 | unsigned long n = RTA_PAYLOAD(attr)/sizeof(__s16); | 342 | unsigned long n = nla_len(attr)/sizeof(__s16); |
343 | const __s16 *data = RTA_DATA(attr); | 343 | const __s16 *data = nla_data(attr); |
344 | struct disttable *d; | 344 | struct disttable *d; |
345 | int i; | 345 | int i; |
346 | 346 | ||
@@ -363,12 +363,12 @@ static int get_dist_table(struct Qdisc *sch, const struct rtattr *attr) | |||
363 | return 0; | 363 | return 0; |
364 | } | 364 | } |
365 | 365 | ||
366 | static int get_correlation(struct Qdisc *sch, const struct rtattr *attr) | 366 | static int get_correlation(struct Qdisc *sch, const struct nlattr *attr) |
367 | { | 367 | { |
368 | struct netem_sched_data *q = qdisc_priv(sch); | 368 | struct netem_sched_data *q = qdisc_priv(sch); |
369 | const struct tc_netem_corr *c = RTA_DATA(attr); | 369 | const struct tc_netem_corr *c = nla_data(attr); |
370 | 370 | ||
371 | if (RTA_PAYLOAD(attr) != sizeof(*c)) | 371 | if (nla_len(attr) != sizeof(*c)) |
372 | return -EINVAL; | 372 | return -EINVAL; |
373 | 373 | ||
374 | init_crandom(&q->delay_cor, c->delay_corr); | 374 | init_crandom(&q->delay_cor, c->delay_corr); |
@@ -377,12 +377,12 @@ static int get_correlation(struct Qdisc *sch, const struct rtattr *attr) | |||
377 | return 0; | 377 | return 0; |
378 | } | 378 | } |
379 | 379 | ||
380 | static int get_reorder(struct Qdisc *sch, const struct rtattr *attr) | 380 | static int get_reorder(struct Qdisc *sch, const struct nlattr *attr) |
381 | { | 381 | { |
382 | struct netem_sched_data *q = qdisc_priv(sch); | 382 | struct netem_sched_data *q = qdisc_priv(sch); |
383 | const struct tc_netem_reorder *r = RTA_DATA(attr); | 383 | const struct tc_netem_reorder *r = nla_data(attr); |
384 | 384 | ||
385 | if (RTA_PAYLOAD(attr) != sizeof(*r)) | 385 | if (nla_len(attr) != sizeof(*r)) |
386 | return -EINVAL; | 386 | return -EINVAL; |
387 | 387 | ||
388 | q->reorder = r->probability; | 388 | q->reorder = r->probability; |
@@ -390,12 +390,12 @@ static int get_reorder(struct Qdisc *sch, const struct rtattr *attr) | |||
390 | return 0; | 390 | return 0; |
391 | } | 391 | } |
392 | 392 | ||
393 | static int get_corrupt(struct Qdisc *sch, const struct rtattr *attr) | 393 | static int get_corrupt(struct Qdisc *sch, const struct nlattr *attr) |
394 | { | 394 | { |
395 | struct netem_sched_data *q = qdisc_priv(sch); | 395 | struct netem_sched_data *q = qdisc_priv(sch); |
396 | const struct tc_netem_corrupt *r = RTA_DATA(attr); | 396 | const struct tc_netem_corrupt *r = nla_data(attr); |
397 | 397 | ||
398 | if (RTA_PAYLOAD(attr) != sizeof(*r)) | 398 | if (nla_len(attr) != sizeof(*r)) |
399 | return -EINVAL; | 399 | return -EINVAL; |
400 | 400 | ||
401 | q->corrupt = r->probability; | 401 | q->corrupt = r->probability; |
@@ -404,16 +404,16 @@ static int get_corrupt(struct Qdisc *sch, const struct rtattr *attr) | |||
404 | } | 404 | } |
405 | 405 | ||
406 | /* Parse netlink message to set options */ | 406 | /* Parse netlink message to set options */ |
407 | static int netem_change(struct Qdisc *sch, struct rtattr *opt) | 407 | static int netem_change(struct Qdisc *sch, struct nlattr *opt) |
408 | { | 408 | { |
409 | struct netem_sched_data *q = qdisc_priv(sch); | 409 | struct netem_sched_data *q = qdisc_priv(sch); |
410 | struct tc_netem_qopt *qopt; | 410 | struct tc_netem_qopt *qopt; |
411 | int ret; | 411 | int ret; |
412 | 412 | ||
413 | if (opt == NULL || RTA_PAYLOAD(opt) < sizeof(*qopt)) | 413 | if (opt == NULL || nla_len(opt) < sizeof(*qopt)) |
414 | return -EINVAL; | 414 | return -EINVAL; |
415 | 415 | ||
416 | qopt = RTA_DATA(opt); | 416 | qopt = nla_data(opt); |
417 | ret = set_fifo_limit(q->qdisc, qopt->limit); | 417 | ret = set_fifo_limit(q->qdisc, qopt->limit); |
418 | if (ret) { | 418 | if (ret) { |
419 | pr_debug("netem: can't set fifo limit\n"); | 419 | pr_debug("netem: can't set fifo limit\n"); |
@@ -437,33 +437,33 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt) | |||
437 | /* Handle nested options after initial queue options. | 437 | /* Handle nested options after initial queue options. |
438 | * Should have put all options in nested format but too late now. | 438 | * Should have put all options in nested format but too late now. |
439 | */ | 439 | */ |
440 | if (RTA_PAYLOAD(opt) > sizeof(*qopt)) { | 440 | if (nla_len(opt) > sizeof(*qopt)) { |
441 | struct rtattr *tb[TCA_NETEM_MAX]; | 441 | struct nlattr *tb[TCA_NETEM_MAX + 1]; |
442 | if (rtattr_parse(tb, TCA_NETEM_MAX, | 442 | if (nla_parse(tb, TCA_NETEM_MAX, |
443 | RTA_DATA(opt) + sizeof(*qopt), | 443 | nla_data(opt) + sizeof(*qopt), |
444 | RTA_PAYLOAD(opt) - sizeof(*qopt))) | 444 | nla_len(opt) - sizeof(*qopt), NULL)) |
445 | return -EINVAL; | 445 | return -EINVAL; |
446 | 446 | ||
447 | if (tb[TCA_NETEM_CORR-1]) { | 447 | if (tb[TCA_NETEM_CORR]) { |
448 | ret = get_correlation(sch, tb[TCA_NETEM_CORR-1]); | 448 | ret = get_correlation(sch, tb[TCA_NETEM_CORR]); |
449 | if (ret) | 449 | if (ret) |
450 | return ret; | 450 | return ret; |
451 | } | 451 | } |
452 | 452 | ||
453 | if (tb[TCA_NETEM_DELAY_DIST-1]) { | 453 | if (tb[TCA_NETEM_DELAY_DIST]) { |
454 | ret = get_dist_table(sch, tb[TCA_NETEM_DELAY_DIST-1]); | 454 | ret = get_dist_table(sch, tb[TCA_NETEM_DELAY_DIST]); |
455 | if (ret) | 455 | if (ret) |
456 | return ret; | 456 | return ret; |
457 | } | 457 | } |
458 | 458 | ||
459 | if (tb[TCA_NETEM_REORDER-1]) { | 459 | if (tb[TCA_NETEM_REORDER]) { |
460 | ret = get_reorder(sch, tb[TCA_NETEM_REORDER-1]); | 460 | ret = get_reorder(sch, tb[TCA_NETEM_REORDER]); |
461 | if (ret) | 461 | if (ret) |
462 | return ret; | 462 | return ret; |
463 | } | 463 | } |
464 | 464 | ||
465 | if (tb[TCA_NETEM_CORRUPT-1]) { | 465 | if (tb[TCA_NETEM_CORRUPT]) { |
466 | ret = get_corrupt(sch, tb[TCA_NETEM_CORRUPT-1]); | 466 | ret = get_corrupt(sch, tb[TCA_NETEM_CORRUPT]); |
467 | if (ret) | 467 | if (ret) |
468 | return ret; | 468 | return ret; |
469 | } | 469 | } |
@@ -515,13 +515,13 @@ static int tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch) | |||
515 | return qdisc_reshape_fail(nskb, sch); | 515 | return qdisc_reshape_fail(nskb, sch); |
516 | } | 516 | } |
517 | 517 | ||
518 | static int tfifo_init(struct Qdisc *sch, struct rtattr *opt) | 518 | static int tfifo_init(struct Qdisc *sch, struct nlattr *opt) |
519 | { | 519 | { |
520 | struct fifo_sched_data *q = qdisc_priv(sch); | 520 | struct fifo_sched_data *q = qdisc_priv(sch); |
521 | 521 | ||
522 | if (opt) { | 522 | if (opt) { |
523 | struct tc_fifo_qopt *ctl = RTA_DATA(opt); | 523 | struct tc_fifo_qopt *ctl = nla_data(opt); |
524 | if (RTA_PAYLOAD(opt) < sizeof(*ctl)) | 524 | if (nla_len(opt) < sizeof(*ctl)) |
525 | return -EINVAL; | 525 | return -EINVAL; |
526 | 526 | ||
527 | q->limit = ctl->limit; | 527 | q->limit = ctl->limit; |
@@ -537,10 +537,10 @@ static int tfifo_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
537 | struct fifo_sched_data *q = qdisc_priv(sch); | 537 | struct fifo_sched_data *q = qdisc_priv(sch); |
538 | struct tc_fifo_qopt opt = { .limit = q->limit }; | 538 | struct tc_fifo_qopt opt = { .limit = q->limit }; |
539 | 539 | ||
540 | RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); | 540 | NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); |
541 | return skb->len; | 541 | return skb->len; |
542 | 542 | ||
543 | rtattr_failure: | 543 | nla_put_failure: |
544 | return -1; | 544 | return -1; |
545 | } | 545 | } |
546 | 546 | ||
@@ -557,7 +557,7 @@ static struct Qdisc_ops tfifo_qdisc_ops __read_mostly = { | |||
557 | .dump = tfifo_dump, | 557 | .dump = tfifo_dump, |
558 | }; | 558 | }; |
559 | 559 | ||
560 | static int netem_init(struct Qdisc *sch, struct rtattr *opt) | 560 | static int netem_init(struct Qdisc *sch, struct nlattr *opt) |
561 | { | 561 | { |
562 | struct netem_sched_data *q = qdisc_priv(sch); | 562 | struct netem_sched_data *q = qdisc_priv(sch); |
563 | int ret; | 563 | int ret; |
@@ -595,7 +595,7 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
595 | { | 595 | { |
596 | const struct netem_sched_data *q = qdisc_priv(sch); | 596 | const struct netem_sched_data *q = qdisc_priv(sch); |
597 | unsigned char *b = skb_tail_pointer(skb); | 597 | unsigned char *b = skb_tail_pointer(skb); |
598 | struct rtattr *rta = (struct rtattr *) b; | 598 | struct nlattr *nla = (struct nlattr *) b; |
599 | struct tc_netem_qopt qopt; | 599 | struct tc_netem_qopt qopt; |
600 | struct tc_netem_corr cor; | 600 | struct tc_netem_corr cor; |
601 | struct tc_netem_reorder reorder; | 601 | struct tc_netem_reorder reorder; |
@@ -607,26 +607,26 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
607 | qopt.loss = q->loss; | 607 | qopt.loss = q->loss; |
608 | qopt.gap = q->gap; | 608 | qopt.gap = q->gap; |
609 | qopt.duplicate = q->duplicate; | 609 | qopt.duplicate = q->duplicate; |
610 | RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt); | 610 | NLA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt); |
611 | 611 | ||
612 | cor.delay_corr = q->delay_cor.rho; | 612 | cor.delay_corr = q->delay_cor.rho; |
613 | cor.loss_corr = q->loss_cor.rho; | 613 | cor.loss_corr = q->loss_cor.rho; |
614 | cor.dup_corr = q->dup_cor.rho; | 614 | cor.dup_corr = q->dup_cor.rho; |
615 | RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor); | 615 | NLA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor); |
616 | 616 | ||
617 | reorder.probability = q->reorder; | 617 | reorder.probability = q->reorder; |
618 | reorder.correlation = q->reorder_cor.rho; | 618 | reorder.correlation = q->reorder_cor.rho; |
619 | RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder); | 619 | NLA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder); |
620 | 620 | ||
621 | corrupt.probability = q->corrupt; | 621 | corrupt.probability = q->corrupt; |
622 | corrupt.correlation = q->corrupt_cor.rho; | 622 | corrupt.correlation = q->corrupt_cor.rho; |
623 | RTA_PUT(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt); | 623 | NLA_PUT(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt); |
624 | 624 | ||
625 | rta->rta_len = skb_tail_pointer(skb) - b; | 625 | nla->nla_len = skb_tail_pointer(skb) - b; |
626 | 626 | ||
627 | return skb->len; | 627 | return skb->len; |
628 | 628 | ||
629 | rtattr_failure: | 629 | nla_put_failure: |
630 | nlmsg_trim(skb, b); | 630 | nlmsg_trim(skb, b); |
631 | return -1; | 631 | return -1; |
632 | } | 632 | } |
@@ -678,7 +678,7 @@ static void netem_put(struct Qdisc *sch, unsigned long arg) | |||
678 | } | 678 | } |
679 | 679 | ||
680 | static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid, | 680 | static int netem_change_class(struct Qdisc *sch, u32 classid, u32 parentid, |
681 | struct rtattr **tca, unsigned long *arg) | 681 | struct nlattr **tca, unsigned long *arg) |
682 | { | 682 | { |
683 | return -ENOSYS; | 683 | return -ENOSYS; |
684 | } | 684 | } |