diff options
Diffstat (limited to 'net/sched/cls_u32.c')
-rw-r--r-- | net/sched/cls_u32.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 7bf3cd4e7318..aaf5049f951c 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -462,8 +462,8 @@ static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle) | |||
462 | 462 | ||
463 | static int u32_set_parms(struct tcf_proto *tp, unsigned long base, | 463 | static int u32_set_parms(struct tcf_proto *tp, unsigned long base, |
464 | struct tc_u_hnode *ht, | 464 | struct tc_u_hnode *ht, |
465 | struct tc_u_knode *n, struct rtattr **tb, | 465 | struct tc_u_knode *n, struct nlattr **tb, |
466 | struct rtattr *est) | 466 | struct nlattr *est) |
467 | { | 467 | { |
468 | int err; | 468 | int err; |
469 | struct tcf_exts e; | 469 | struct tcf_exts e; |
@@ -473,8 +473,8 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base, | |||
473 | return err; | 473 | return err; |
474 | 474 | ||
475 | err = -EINVAL; | 475 | err = -EINVAL; |
476 | if (tb[TCA_U32_LINK-1]) { | 476 | if (tb[TCA_U32_LINK]) { |
477 | u32 handle = *(u32*)RTA_DATA(tb[TCA_U32_LINK-1]); | 477 | u32 handle = *(u32*)nla_data(tb[TCA_U32_LINK]); |
478 | struct tc_u_hnode *ht_down = NULL; | 478 | struct tc_u_hnode *ht_down = NULL; |
479 | 479 | ||
480 | if (TC_U32_KEY(handle)) | 480 | if (TC_U32_KEY(handle)) |
@@ -495,14 +495,14 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base, | |||
495 | if (ht_down) | 495 | if (ht_down) |
496 | ht_down->refcnt--; | 496 | ht_down->refcnt--; |
497 | } | 497 | } |
498 | if (tb[TCA_U32_CLASSID-1]) { | 498 | if (tb[TCA_U32_CLASSID]) { |
499 | n->res.classid = *(u32*)RTA_DATA(tb[TCA_U32_CLASSID-1]); | 499 | n->res.classid = *(u32*)nla_data(tb[TCA_U32_CLASSID]); |
500 | tcf_bind_filter(tp, &n->res, base); | 500 | tcf_bind_filter(tp, &n->res, base); |
501 | } | 501 | } |
502 | 502 | ||
503 | #ifdef CONFIG_NET_CLS_IND | 503 | #ifdef CONFIG_NET_CLS_IND |
504 | if (tb[TCA_U32_INDEV-1]) { | 504 | if (tb[TCA_U32_INDEV]) { |
505 | err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV-1]); | 505 | err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV]); |
506 | if (err < 0) | 506 | if (err < 0) |
507 | goto errout; | 507 | goto errout; |
508 | } | 508 | } |
@@ -516,33 +516,33 @@ errout: | |||
516 | } | 516 | } |
517 | 517 | ||
518 | static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | 518 | static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, |
519 | struct rtattr **tca, | 519 | struct nlattr **tca, |
520 | unsigned long *arg) | 520 | unsigned long *arg) |
521 | { | 521 | { |
522 | struct tc_u_common *tp_c = tp->data; | 522 | struct tc_u_common *tp_c = tp->data; |
523 | struct tc_u_hnode *ht; | 523 | struct tc_u_hnode *ht; |
524 | struct tc_u_knode *n; | 524 | struct tc_u_knode *n; |
525 | struct tc_u32_sel *s; | 525 | struct tc_u32_sel *s; |
526 | struct rtattr *opt = tca[TCA_OPTIONS-1]; | 526 | struct nlattr *opt = tca[TCA_OPTIONS]; |
527 | struct rtattr *tb[TCA_U32_MAX]; | 527 | struct nlattr *tb[TCA_U32_MAX + 1]; |
528 | u32 htid; | 528 | u32 htid; |
529 | int err; | 529 | int err; |
530 | 530 | ||
531 | if (opt == NULL) | 531 | if (opt == NULL) |
532 | return handle ? -EINVAL : 0; | 532 | return handle ? -EINVAL : 0; |
533 | 533 | ||
534 | if (rtattr_parse_nested(tb, TCA_U32_MAX, opt) < 0) | 534 | if (nla_parse_nested(tb, TCA_U32_MAX, opt, NULL) < 0) |
535 | return -EINVAL; | 535 | return -EINVAL; |
536 | 536 | ||
537 | if ((n = (struct tc_u_knode*)*arg) != NULL) { | 537 | if ((n = (struct tc_u_knode*)*arg) != NULL) { |
538 | if (TC_U32_KEY(n->handle) == 0) | 538 | if (TC_U32_KEY(n->handle) == 0) |
539 | return -EINVAL; | 539 | return -EINVAL; |
540 | 540 | ||
541 | return u32_set_parms(tp, base, n->ht_up, n, tb, tca[TCA_RATE-1]); | 541 | return u32_set_parms(tp, base, n->ht_up, n, tb, tca[TCA_RATE]); |
542 | } | 542 | } |
543 | 543 | ||
544 | if (tb[TCA_U32_DIVISOR-1]) { | 544 | if (tb[TCA_U32_DIVISOR]) { |
545 | unsigned divisor = *(unsigned*)RTA_DATA(tb[TCA_U32_DIVISOR-1]); | 545 | unsigned divisor = *(unsigned*)nla_data(tb[TCA_U32_DIVISOR]); |
546 | 546 | ||
547 | if (--divisor > 0x100) | 547 | if (--divisor > 0x100) |
548 | return -EINVAL; | 548 | return -EINVAL; |
@@ -567,8 +567,8 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
567 | return 0; | 567 | return 0; |
568 | } | 568 | } |
569 | 569 | ||
570 | if (tb[TCA_U32_HASH-1]) { | 570 | if (tb[TCA_U32_HASH]) { |
571 | htid = *(unsigned*)RTA_DATA(tb[TCA_U32_HASH-1]); | 571 | htid = *(unsigned*)nla_data(tb[TCA_U32_HASH]); |
572 | if (TC_U32_HTID(htid) == TC_U32_ROOT) { | 572 | if (TC_U32_HTID(htid) == TC_U32_ROOT) { |
573 | ht = tp->root; | 573 | ht = tp->root; |
574 | htid = ht->handle; | 574 | htid = ht->handle; |
@@ -592,11 +592,11 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
592 | } else | 592 | } else |
593 | handle = gen_new_kid(ht, htid); | 593 | handle = gen_new_kid(ht, htid); |
594 | 594 | ||
595 | if (tb[TCA_U32_SEL-1] == NULL || | 595 | if (tb[TCA_U32_SEL] == NULL || |
596 | RTA_PAYLOAD(tb[TCA_U32_SEL-1]) < sizeof(struct tc_u32_sel)) | 596 | nla_len(tb[TCA_U32_SEL]) < sizeof(struct tc_u32_sel)) |
597 | return -EINVAL; | 597 | return -EINVAL; |
598 | 598 | ||
599 | s = RTA_DATA(tb[TCA_U32_SEL-1]); | 599 | s = nla_data(tb[TCA_U32_SEL]); |
600 | 600 | ||
601 | n = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL); | 601 | n = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL); |
602 | if (n == NULL) | 602 | if (n == NULL) |
@@ -616,23 +616,23 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
616 | n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; | 616 | n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; |
617 | 617 | ||
618 | #ifdef CONFIG_CLS_U32_MARK | 618 | #ifdef CONFIG_CLS_U32_MARK |
619 | if (tb[TCA_U32_MARK-1]) { | 619 | if (tb[TCA_U32_MARK]) { |
620 | struct tc_u32_mark *mark; | 620 | struct tc_u32_mark *mark; |
621 | 621 | ||
622 | if (RTA_PAYLOAD(tb[TCA_U32_MARK-1]) < sizeof(struct tc_u32_mark)) { | 622 | if (nla_len(tb[TCA_U32_MARK]) < sizeof(struct tc_u32_mark)) { |
623 | #ifdef CONFIG_CLS_U32_PERF | 623 | #ifdef CONFIG_CLS_U32_PERF |
624 | kfree(n->pf); | 624 | kfree(n->pf); |
625 | #endif | 625 | #endif |
626 | kfree(n); | 626 | kfree(n); |
627 | return -EINVAL; | 627 | return -EINVAL; |
628 | } | 628 | } |
629 | mark = RTA_DATA(tb[TCA_U32_MARK-1]); | 629 | mark = nla_data(tb[TCA_U32_MARK]); |
630 | memcpy(&n->mark, mark, sizeof(struct tc_u32_mark)); | 630 | memcpy(&n->mark, mark, sizeof(struct tc_u32_mark)); |
631 | n->mark.success = 0; | 631 | n->mark.success = 0; |
632 | } | 632 | } |
633 | #endif | 633 | #endif |
634 | 634 | ||
635 | err = u32_set_parms(tp, base, ht, n, tb, tca[TCA_RATE-1]); | 635 | err = u32_set_parms(tp, base, ht, n, tb, tca[TCA_RATE]); |
636 | if (err == 0) { | 636 | if (err == 0) { |
637 | struct tc_u_knode **ins; | 637 | struct tc_u_knode **ins; |
638 | for (ins = &ht->ht[TC_U32_HASH(handle)]; *ins; ins = &(*ins)->next) | 638 | for (ins = &ht->ht[TC_U32_HASH(handle)]; *ins; ins = &(*ins)->next) |
@@ -694,59 +694,59 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, | |||
694 | { | 694 | { |
695 | struct tc_u_knode *n = (struct tc_u_knode*)fh; | 695 | struct tc_u_knode *n = (struct tc_u_knode*)fh; |
696 | unsigned char *b = skb_tail_pointer(skb); | 696 | unsigned char *b = skb_tail_pointer(skb); |
697 | struct rtattr *rta; | 697 | struct nlattr *nla; |
698 | 698 | ||
699 | if (n == NULL) | 699 | if (n == NULL) |
700 | return skb->len; | 700 | return skb->len; |
701 | 701 | ||
702 | t->tcm_handle = n->handle; | 702 | t->tcm_handle = n->handle; |
703 | 703 | ||
704 | rta = (struct rtattr*)b; | 704 | nla = (struct nlattr*)b; |
705 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 705 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
706 | 706 | ||
707 | if (TC_U32_KEY(n->handle) == 0) { | 707 | if (TC_U32_KEY(n->handle) == 0) { |
708 | struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; | 708 | struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; |
709 | u32 divisor = ht->divisor+1; | 709 | u32 divisor = ht->divisor+1; |
710 | RTA_PUT(skb, TCA_U32_DIVISOR, 4, &divisor); | 710 | NLA_PUT(skb, TCA_U32_DIVISOR, 4, &divisor); |
711 | } else { | 711 | } else { |
712 | RTA_PUT(skb, TCA_U32_SEL, | 712 | NLA_PUT(skb, TCA_U32_SEL, |
713 | sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), | 713 | sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), |
714 | &n->sel); | 714 | &n->sel); |
715 | if (n->ht_up) { | 715 | if (n->ht_up) { |
716 | u32 htid = n->handle & 0xFFFFF000; | 716 | u32 htid = n->handle & 0xFFFFF000; |
717 | RTA_PUT(skb, TCA_U32_HASH, 4, &htid); | 717 | NLA_PUT(skb, TCA_U32_HASH, 4, &htid); |
718 | } | 718 | } |
719 | if (n->res.classid) | 719 | if (n->res.classid) |
720 | RTA_PUT(skb, TCA_U32_CLASSID, 4, &n->res.classid); | 720 | NLA_PUT(skb, TCA_U32_CLASSID, 4, &n->res.classid); |
721 | if (n->ht_down) | 721 | if (n->ht_down) |
722 | RTA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle); | 722 | NLA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle); |
723 | 723 | ||
724 | #ifdef CONFIG_CLS_U32_MARK | 724 | #ifdef CONFIG_CLS_U32_MARK |
725 | if (n->mark.val || n->mark.mask) | 725 | if (n->mark.val || n->mark.mask) |
726 | RTA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark); | 726 | NLA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark); |
727 | #endif | 727 | #endif |
728 | 728 | ||
729 | if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) | 729 | if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) |
730 | goto rtattr_failure; | 730 | goto nla_put_failure; |
731 | 731 | ||
732 | #ifdef CONFIG_NET_CLS_IND | 732 | #ifdef CONFIG_NET_CLS_IND |
733 | if(strlen(n->indev)) | 733 | if(strlen(n->indev)) |
734 | RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev); | 734 | NLA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev); |
735 | #endif | 735 | #endif |
736 | #ifdef CONFIG_CLS_U32_PERF | 736 | #ifdef CONFIG_CLS_U32_PERF |
737 | RTA_PUT(skb, TCA_U32_PCNT, | 737 | NLA_PUT(skb, TCA_U32_PCNT, |
738 | sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64), | 738 | sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64), |
739 | n->pf); | 739 | n->pf); |
740 | #endif | 740 | #endif |
741 | } | 741 | } |
742 | 742 | ||
743 | rta->rta_len = skb_tail_pointer(skb) - b; | 743 | nla->nla_len = skb_tail_pointer(skb) - b; |
744 | if (TC_U32_KEY(n->handle)) | 744 | if (TC_U32_KEY(n->handle)) |
745 | if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) | 745 | if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) |
746 | goto rtattr_failure; | 746 | goto nla_put_failure; |
747 | return skb->len; | 747 | return skb->len; |
748 | 748 | ||
749 | rtattr_failure: | 749 | nla_put_failure: |
750 | nlmsg_trim(skb, b); | 750 | nlmsg_trim(skb, b); |
751 | return -1; | 751 | return -1; |
752 | } | 752 | } |