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/em_meta.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/em_meta.c')
-rw-r--r-- | net/sched/em_meta.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index ceda8890ab0e..92b6863e928d 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
@@ -542,11 +542,11 @@ static int meta_var_compare(struct meta_obj *a, struct meta_obj *b) | |||
542 | return r; | 542 | return r; |
543 | } | 543 | } |
544 | 544 | ||
545 | static int meta_var_change(struct meta_value *dst, struct rtattr *rta) | 545 | static int meta_var_change(struct meta_value *dst, struct nlattr *nla) |
546 | { | 546 | { |
547 | int len = RTA_PAYLOAD(rta); | 547 | int len = nla_len(nla); |
548 | 548 | ||
549 | dst->val = (unsigned long)kmemdup(RTA_DATA(rta), len, GFP_KERNEL); | 549 | dst->val = (unsigned long)kmemdup(nla_data(nla), len, GFP_KERNEL); |
550 | if (dst->val == 0UL) | 550 | if (dst->val == 0UL) |
551 | return -ENOMEM; | 551 | return -ENOMEM; |
552 | dst->len = len; | 552 | dst->len = len; |
@@ -570,10 +570,10 @@ static void meta_var_apply_extras(struct meta_value *v, | |||
570 | static int meta_var_dump(struct sk_buff *skb, struct meta_value *v, int tlv) | 570 | static int meta_var_dump(struct sk_buff *skb, struct meta_value *v, int tlv) |
571 | { | 571 | { |
572 | if (v->val && v->len) | 572 | if (v->val && v->len) |
573 | RTA_PUT(skb, tlv, v->len, (void *) v->val); | 573 | NLA_PUT(skb, tlv, v->len, (void *) v->val); |
574 | return 0; | 574 | return 0; |
575 | 575 | ||
576 | rtattr_failure: | 576 | nla_put_failure: |
577 | return -1; | 577 | return -1; |
578 | } | 578 | } |
579 | 579 | ||
@@ -594,13 +594,13 @@ static int meta_int_compare(struct meta_obj *a, struct meta_obj *b) | |||
594 | return 1; | 594 | return 1; |
595 | } | 595 | } |
596 | 596 | ||
597 | static int meta_int_change(struct meta_value *dst, struct rtattr *rta) | 597 | static int meta_int_change(struct meta_value *dst, struct nlattr *nla) |
598 | { | 598 | { |
599 | if (RTA_PAYLOAD(rta) >= sizeof(unsigned long)) { | 599 | if (nla_len(nla) >= sizeof(unsigned long)) { |
600 | dst->val = *(unsigned long *) RTA_DATA(rta); | 600 | dst->val = *(unsigned long *) nla_data(nla); |
601 | dst->len = sizeof(unsigned long); | 601 | dst->len = sizeof(unsigned long); |
602 | } else if (RTA_PAYLOAD(rta) == sizeof(u32)) { | 602 | } else if (nla_len(nla) == sizeof(u32)) { |
603 | dst->val = *(u32 *) RTA_DATA(rta); | 603 | dst->val = *(u32 *) nla_data(nla); |
604 | dst->len = sizeof(u32); | 604 | dst->len = sizeof(u32); |
605 | } else | 605 | } else |
606 | return -EINVAL; | 606 | return -EINVAL; |
@@ -621,15 +621,15 @@ static void meta_int_apply_extras(struct meta_value *v, | |||
621 | static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv) | 621 | static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv) |
622 | { | 622 | { |
623 | if (v->len == sizeof(unsigned long)) | 623 | if (v->len == sizeof(unsigned long)) |
624 | RTA_PUT(skb, tlv, sizeof(unsigned long), &v->val); | 624 | NLA_PUT(skb, tlv, sizeof(unsigned long), &v->val); |
625 | else if (v->len == sizeof(u32)) { | 625 | else if (v->len == sizeof(u32)) { |
626 | u32 d = v->val; | 626 | u32 d = v->val; |
627 | RTA_PUT(skb, tlv, sizeof(d), &d); | 627 | NLA_PUT(skb, tlv, sizeof(d), &d); |
628 | } | 628 | } |
629 | 629 | ||
630 | return 0; | 630 | return 0; |
631 | 631 | ||
632 | rtattr_failure: | 632 | nla_put_failure: |
633 | return -1; | 633 | return -1; |
634 | } | 634 | } |
635 | 635 | ||
@@ -641,7 +641,7 @@ struct meta_type_ops | |||
641 | { | 641 | { |
642 | void (*destroy)(struct meta_value *); | 642 | void (*destroy)(struct meta_value *); |
643 | int (*compare)(struct meta_obj *, struct meta_obj *); | 643 | int (*compare)(struct meta_obj *, struct meta_obj *); |
644 | int (*change)(struct meta_value *, struct rtattr *); | 644 | int (*change)(struct meta_value *, struct nlattr *); |
645 | void (*apply_extras)(struct meta_value *, struct meta_obj *); | 645 | void (*apply_extras)(struct meta_value *, struct meta_obj *); |
646 | int (*dump)(struct sk_buff *, struct meta_value *, int); | 646 | int (*dump)(struct sk_buff *, struct meta_value *, int); |
647 | }; | 647 | }; |
@@ -729,13 +729,13 @@ static inline void meta_delete(struct meta_match *meta) | |||
729 | kfree(meta); | 729 | kfree(meta); |
730 | } | 730 | } |
731 | 731 | ||
732 | static inline int meta_change_data(struct meta_value *dst, struct rtattr *rta) | 732 | static inline int meta_change_data(struct meta_value *dst, struct nlattr *nla) |
733 | { | 733 | { |
734 | if (rta) { | 734 | if (nla) { |
735 | if (RTA_PAYLOAD(rta) == 0) | 735 | if (nla_len(nla) == 0) |
736 | return -EINVAL; | 736 | return -EINVAL; |
737 | 737 | ||
738 | return meta_type_ops(dst)->change(dst, rta); | 738 | return meta_type_ops(dst)->change(dst, nla); |
739 | } | 739 | } |
740 | 740 | ||
741 | return 0; | 741 | return 0; |
@@ -750,17 +750,17 @@ static int em_meta_change(struct tcf_proto *tp, void *data, int len, | |||
750 | struct tcf_ematch *m) | 750 | struct tcf_ematch *m) |
751 | { | 751 | { |
752 | int err = -EINVAL; | 752 | int err = -EINVAL; |
753 | struct rtattr *tb[TCA_EM_META_MAX]; | 753 | struct nlattr *tb[TCA_EM_META_MAX + 1]; |
754 | struct tcf_meta_hdr *hdr; | 754 | struct tcf_meta_hdr *hdr; |
755 | struct meta_match *meta = NULL; | 755 | struct meta_match *meta = NULL; |
756 | 756 | ||
757 | if (rtattr_parse(tb, TCA_EM_META_MAX, data, len) < 0) | 757 | if (nla_parse(tb, TCA_EM_META_MAX, data, len, NULL) < 0) |
758 | goto errout; | 758 | goto errout; |
759 | 759 | ||
760 | if (tb[TCA_EM_META_HDR-1] == NULL || | 760 | if (tb[TCA_EM_META_HDR] == NULL || |
761 | RTA_PAYLOAD(tb[TCA_EM_META_HDR-1]) < sizeof(*hdr)) | 761 | nla_len(tb[TCA_EM_META_HDR]) < sizeof(*hdr)) |
762 | goto errout; | 762 | goto errout; |
763 | hdr = RTA_DATA(tb[TCA_EM_META_HDR-1]); | 763 | hdr = nla_data(tb[TCA_EM_META_HDR]); |
764 | 764 | ||
765 | if (TCF_META_TYPE(hdr->left.kind) != TCF_META_TYPE(hdr->right.kind) || | 765 | if (TCF_META_TYPE(hdr->left.kind) != TCF_META_TYPE(hdr->right.kind) || |
766 | TCF_META_TYPE(hdr->left.kind) > TCF_META_TYPE_MAX || | 766 | TCF_META_TYPE(hdr->left.kind) > TCF_META_TYPE_MAX || |
@@ -781,8 +781,8 @@ static int em_meta_change(struct tcf_proto *tp, void *data, int len, | |||
781 | goto errout; | 781 | goto errout; |
782 | } | 782 | } |
783 | 783 | ||
784 | if (meta_change_data(&meta->lvalue, tb[TCA_EM_META_LVALUE-1]) < 0 || | 784 | if (meta_change_data(&meta->lvalue, tb[TCA_EM_META_LVALUE]) < 0 || |
785 | meta_change_data(&meta->rvalue, tb[TCA_EM_META_RVALUE-1]) < 0) | 785 | meta_change_data(&meta->rvalue, tb[TCA_EM_META_RVALUE]) < 0) |
786 | goto errout; | 786 | goto errout; |
787 | 787 | ||
788 | m->datalen = sizeof(*meta); | 788 | m->datalen = sizeof(*meta); |
@@ -811,16 +811,16 @@ static int em_meta_dump(struct sk_buff *skb, struct tcf_ematch *em) | |||
811 | memcpy(&hdr.left, &meta->lvalue.hdr, sizeof(hdr.left)); | 811 | memcpy(&hdr.left, &meta->lvalue.hdr, sizeof(hdr.left)); |
812 | memcpy(&hdr.right, &meta->rvalue.hdr, sizeof(hdr.right)); | 812 | memcpy(&hdr.right, &meta->rvalue.hdr, sizeof(hdr.right)); |
813 | 813 | ||
814 | RTA_PUT(skb, TCA_EM_META_HDR, sizeof(hdr), &hdr); | 814 | NLA_PUT(skb, TCA_EM_META_HDR, sizeof(hdr), &hdr); |
815 | 815 | ||
816 | ops = meta_type_ops(&meta->lvalue); | 816 | ops = meta_type_ops(&meta->lvalue); |
817 | if (ops->dump(skb, &meta->lvalue, TCA_EM_META_LVALUE) < 0 || | 817 | if (ops->dump(skb, &meta->lvalue, TCA_EM_META_LVALUE) < 0 || |
818 | ops->dump(skb, &meta->rvalue, TCA_EM_META_RVALUE) < 0) | 818 | ops->dump(skb, &meta->rvalue, TCA_EM_META_RVALUE) < 0) |
819 | goto rtattr_failure; | 819 | goto nla_put_failure; |
820 | 820 | ||
821 | return 0; | 821 | return 0; |
822 | 822 | ||
823 | rtattr_failure: | 823 | nla_put_failure: |
824 | return -1; | 824 | return -1; |
825 | } | 825 | } |
826 | 826 | ||