aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 01:11:50 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:11 -0500
commit7ba699c604ab811972eee2e041fd6b07659a2e6e (patch)
tree4f76f69a25ce27ee0dd0c417df75acf00b1a36a0 /net
parentadd93b610a4e66d36d0cf0b2596c3d3bcfdaee39 (diff)
[NET_SCHED]: Convert actions 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')
-rw-r--r--net/sched/act_api.c214
-rw-r--r--net/sched/act_gact.c28
-rw-r--r--net/sched/act_ipt.c46
-rw-r--r--net/sched/act_mirred.c18
-rw-r--r--net/sched/act_nat.c18
-rw-r--r--net/sched/act_pedit.c20
-rw-r--r--net/sched/act_police.c52
-rw-r--r--net/sched/act_simple.c24
-rw-r--r--net/sched/cls_api.c6
9 files changed, 214 insertions, 212 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 11f3097a6912..ebd21d2cb5f1 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -68,7 +68,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
68{ 68{
69 struct tcf_common *p; 69 struct tcf_common *p;
70 int err = 0, index = -1,i = 0, s_i = 0, n_i = 0; 70 int err = 0, index = -1,i = 0, s_i = 0, n_i = 0;
71 struct rtattr *r ; 71 struct nlattr *r ;
72 72
73 read_lock_bh(hinfo->lock); 73 read_lock_bh(hinfo->lock);
74 74
@@ -83,15 +83,15 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
83 continue; 83 continue;
84 a->priv = p; 84 a->priv = p;
85 a->order = n_i; 85 a->order = n_i;
86 r = (struct rtattr *)skb_tail_pointer(skb); 86 r = (struct nlattr *)skb_tail_pointer(skb);
87 RTA_PUT(skb, a->order, 0, NULL); 87 NLA_PUT(skb, a->order, 0, NULL);
88 err = tcf_action_dump_1(skb, a, 0, 0); 88 err = tcf_action_dump_1(skb, a, 0, 0);
89 if (err < 0) { 89 if (err < 0) {
90 index--; 90 index--;
91 nlmsg_trim(skb, r); 91 nlmsg_trim(skb, r);
92 goto done; 92 goto done;
93 } 93 }
94 r->rta_len = skb_tail_pointer(skb) - (u8 *)r; 94 r->nla_len = skb_tail_pointer(skb) - (u8 *)r;
95 n_i++; 95 n_i++;
96 if (n_i >= TCA_ACT_MAX_PRIO) 96 if (n_i >= TCA_ACT_MAX_PRIO)
97 goto done; 97 goto done;
@@ -103,7 +103,7 @@ done:
103 cb->args[0] += n_i; 103 cb->args[0] += n_i;
104 return n_i; 104 return n_i;
105 105
106rtattr_failure: 106nla_put_failure:
107 nlmsg_trim(skb, r); 107 nlmsg_trim(skb, r);
108 goto done; 108 goto done;
109} 109}
@@ -112,12 +112,12 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
112 struct tcf_hashinfo *hinfo) 112 struct tcf_hashinfo *hinfo)
113{ 113{
114 struct tcf_common *p, *s_p; 114 struct tcf_common *p, *s_p;
115 struct rtattr *r ; 115 struct nlattr *r ;
116 int i= 0, n_i = 0; 116 int i= 0, n_i = 0;
117 117
118 r = (struct rtattr *)skb_tail_pointer(skb); 118 r = (struct nlattr *)skb_tail_pointer(skb);
119 RTA_PUT(skb, a->order, 0, NULL); 119 NLA_PUT(skb, a->order, 0, NULL);
120 RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); 120 NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
121 for (i = 0; i < (hinfo->hmask + 1); i++) { 121 for (i = 0; i < (hinfo->hmask + 1); i++) {
122 p = hinfo->htab[tcf_hash(i, hinfo->hmask)]; 122 p = hinfo->htab[tcf_hash(i, hinfo->hmask)];
123 123
@@ -129,11 +129,11 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
129 p = s_p; 129 p = s_p;
130 } 130 }
131 } 131 }
132 RTA_PUT(skb, TCA_FCNT, 4, &n_i); 132 NLA_PUT(skb, TCA_FCNT, 4, &n_i);
133 r->rta_len = skb_tail_pointer(skb) - (u8 *)r; 133 r->nla_len = skb_tail_pointer(skb) - (u8 *)r;
134 134
135 return n_i; 135 return n_i;
136rtattr_failure: 136nla_put_failure:
137 nlmsg_trim(skb, r); 137 nlmsg_trim(skb, r);
138 return -EINVAL; 138 return -EINVAL;
139} 139}
@@ -211,7 +211,7 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind,
211} 211}
212EXPORT_SYMBOL(tcf_hash_check); 212EXPORT_SYMBOL(tcf_hash_check);
213 213
214struct tcf_common *tcf_hash_create(u32 index, struct rtattr *est, struct tc_action *a, int size, int bind, u32 *idx_gen, struct tcf_hashinfo *hinfo) 214struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a, int size, int bind, u32 *idx_gen, struct tcf_hashinfo *hinfo)
215{ 215{
216 struct tcf_common *p = kzalloc(size, GFP_KERNEL); 216 struct tcf_common *p = kzalloc(size, GFP_KERNEL);
217 217
@@ -227,7 +227,7 @@ struct tcf_common *tcf_hash_create(u32 index, struct rtattr *est, struct tc_acti
227 p->tcfc_tm.lastuse = jiffies; 227 p->tcfc_tm.lastuse = jiffies;
228 if (est) 228 if (est)
229 gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est, 229 gen_new_estimator(&p->tcfc_bstats, &p->tcfc_rate_est,
230 &p->tcfc_lock, (struct nlattr *)est); 230 &p->tcfc_lock, est);
231 a->priv = (void *) p; 231 a->priv = (void *) p;
232 return p; 232 return p;
233} 233}
@@ -305,15 +305,15 @@ static struct tc_action_ops *tc_lookup_action_n(char *kind)
305 return a; 305 return a;
306} 306}
307 307
308/* lookup by rtattr */ 308/* lookup by nlattr */
309static struct tc_action_ops *tc_lookup_action(struct rtattr *kind) 309static struct tc_action_ops *tc_lookup_action(struct nlattr *kind)
310{ 310{
311 struct tc_action_ops *a = NULL; 311 struct tc_action_ops *a = NULL;
312 312
313 if (kind) { 313 if (kind) {
314 read_lock(&act_mod_lock); 314 read_lock(&act_mod_lock);
315 for (a = act_base; a; a = a->next) { 315 for (a = act_base; a; a = a->next) {
316 if (rtattr_strcmp(kind, a->kind) == 0) { 316 if (nla_strcmp(kind, a->kind) == 0) {
317 if (!try_module_get(a->owner)) { 317 if (!try_module_get(a->owner)) {
318 read_unlock(&act_mod_lock); 318 read_unlock(&act_mod_lock);
319 return NULL; 319 return NULL;
@@ -414,22 +414,22 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
414{ 414{
415 int err = -EINVAL; 415 int err = -EINVAL;
416 unsigned char *b = skb_tail_pointer(skb); 416 unsigned char *b = skb_tail_pointer(skb);
417 struct rtattr *r; 417 struct nlattr *r;
418 418
419 if (a->ops == NULL || a->ops->dump == NULL) 419 if (a->ops == NULL || a->ops->dump == NULL)
420 return err; 420 return err;
421 421
422 RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); 422 NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
423 if (tcf_action_copy_stats(skb, a, 0)) 423 if (tcf_action_copy_stats(skb, a, 0))
424 goto rtattr_failure; 424 goto nla_put_failure;
425 r = (struct rtattr *)skb_tail_pointer(skb); 425 r = (struct nlattr *)skb_tail_pointer(skb);
426 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 426 NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
427 if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) { 427 if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) {
428 r->rta_len = skb_tail_pointer(skb) - (u8 *)r; 428 r->nla_len = skb_tail_pointer(skb) - (u8 *)r;
429 return err; 429 return err;
430 } 430 }
431 431
432rtattr_failure: 432nla_put_failure:
433 nlmsg_trim(skb, b); 433 nlmsg_trim(skb, b);
434 return -1; 434 return -1;
435} 435}
@@ -441,45 +441,45 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref)
441 struct tc_action *a; 441 struct tc_action *a;
442 int err = -EINVAL; 442 int err = -EINVAL;
443 unsigned char *b = skb_tail_pointer(skb); 443 unsigned char *b = skb_tail_pointer(skb);
444 struct rtattr *r ; 444 struct nlattr *r ;
445 445
446 while ((a = act) != NULL) { 446 while ((a = act) != NULL) {
447 r = (struct rtattr *)skb_tail_pointer(skb); 447 r = (struct nlattr *)skb_tail_pointer(skb);
448 act = a->next; 448 act = a->next;
449 RTA_PUT(skb, a->order, 0, NULL); 449 NLA_PUT(skb, a->order, 0, NULL);
450 err = tcf_action_dump_1(skb, a, bind, ref); 450 err = tcf_action_dump_1(skb, a, bind, ref);
451 if (err < 0) 451 if (err < 0)
452 goto errout; 452 goto errout;
453 r->rta_len = skb_tail_pointer(skb) - (u8 *)r; 453 r->nla_len = skb_tail_pointer(skb) - (u8 *)r;
454 } 454 }
455 455
456 return 0; 456 return 0;
457 457
458rtattr_failure: 458nla_put_failure:
459 err = -EINVAL; 459 err = -EINVAL;
460errout: 460errout:
461 nlmsg_trim(skb, b); 461 nlmsg_trim(skb, b);
462 return err; 462 return err;
463} 463}
464 464
465struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, 465struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
466 char *name, int ovr, int bind, int *err) 466 char *name, int ovr, int bind, int *err)
467{ 467{
468 struct tc_action *a; 468 struct tc_action *a;
469 struct tc_action_ops *a_o; 469 struct tc_action_ops *a_o;
470 char act_name[IFNAMSIZ]; 470 char act_name[IFNAMSIZ];
471 struct rtattr *tb[TCA_ACT_MAX+1]; 471 struct nlattr *tb[TCA_ACT_MAX+1];
472 struct rtattr *kind; 472 struct nlattr *kind;
473 473
474 *err = -EINVAL; 474 *err = -EINVAL;
475 475
476 if (name == NULL) { 476 if (name == NULL) {
477 if (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0) 477 if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
478 goto err_out; 478 goto err_out;
479 kind = tb[TCA_ACT_KIND-1]; 479 kind = tb[TCA_ACT_KIND];
480 if (kind == NULL) 480 if (kind == NULL)
481 goto err_out; 481 goto err_out;
482 if (rtattr_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ) 482 if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)
483 goto err_out; 483 goto err_out;
484 } else { 484 } else {
485 if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ) 485 if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ)
@@ -517,9 +517,9 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
517 517
518 /* backward compatibility for policer */ 518 /* backward compatibility for policer */
519 if (name == NULL) 519 if (name == NULL)
520 *err = a_o->init(tb[TCA_ACT_OPTIONS-1], est, a, ovr, bind); 520 *err = a_o->init(tb[TCA_ACT_OPTIONS], est, a, ovr, bind);
521 else 521 else
522 *err = a_o->init(rta, est, a, ovr, bind); 522 *err = a_o->init(nla, est, a, ovr, bind);
523 if (*err < 0) 523 if (*err < 0)
524 goto err_free; 524 goto err_free;
525 525
@@ -542,23 +542,23 @@ err_out:
542 return NULL; 542 return NULL;
543} 543}
544 544
545struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est, 545struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est,
546 char *name, int ovr, int bind, int *err) 546 char *name, int ovr, int bind, int *err)
547{ 547{
548 struct rtattr *tb[TCA_ACT_MAX_PRIO+1]; 548 struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
549 struct tc_action *head = NULL, *act, *act_prev = NULL; 549 struct tc_action *head = NULL, *act, *act_prev = NULL;
550 int i; 550 int i;
551 551
552 if (rtattr_parse_nested(tb, TCA_ACT_MAX_PRIO, rta) < 0) { 552 if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0) {
553 *err = -EINVAL; 553 *err = -EINVAL;
554 return head; 554 return head;
555 } 555 }
556 556
557 for (i=0; i < TCA_ACT_MAX_PRIO && tb[i]; i++) { 557 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
558 act = tcf_action_init_1(tb[i], est, name, ovr, bind, err); 558 act = tcf_action_init_1(tb[i], est, name, ovr, bind, err);
559 if (act == NULL) 559 if (act == NULL)
560 goto err; 560 goto err;
561 act->order = i+1; 561 act->order = i;
562 562
563 if (head == NULL) 563 if (head == NULL)
564 head = act; 564 head = act;
@@ -625,7 +625,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
625 struct tcamsg *t; 625 struct tcamsg *t;
626 struct nlmsghdr *nlh; 626 struct nlmsghdr *nlh;
627 unsigned char *b = skb_tail_pointer(skb); 627 unsigned char *b = skb_tail_pointer(skb);
628 struct rtattr *x; 628 struct nlattr *x;
629 629
630 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags); 630 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags);
631 631
@@ -634,18 +634,18 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
634 t->tca__pad1 = 0; 634 t->tca__pad1 = 0;
635 t->tca__pad2 = 0; 635 t->tca__pad2 = 0;
636 636
637 x = (struct rtattr *)skb_tail_pointer(skb); 637 x = (struct nlattr *)skb_tail_pointer(skb);
638 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 638 NLA_PUT(skb, TCA_ACT_TAB, 0, NULL);
639 639
640 if (tcf_action_dump(skb, a, bind, ref) < 0) 640 if (tcf_action_dump(skb, a, bind, ref) < 0)
641 goto rtattr_failure; 641 goto nla_put_failure;
642 642
643 x->rta_len = skb_tail_pointer(skb) - (u8 *)x; 643 x->nla_len = skb_tail_pointer(skb) - (u8 *)x;
644 644
645 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 645 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
646 return skb->len; 646 return skb->len;
647 647
648rtattr_failure: 648nla_put_failure:
649nlmsg_failure: 649nlmsg_failure:
650 nlmsg_trim(skb, b); 650 nlmsg_trim(skb, b);
651 return -1; 651 return -1;
@@ -668,20 +668,20 @@ act_get_notify(u32 pid, struct nlmsghdr *n, struct tc_action *a, int event)
668} 668}
669 669
670static struct tc_action * 670static struct tc_action *
671tcf_action_get_1(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int *err) 671tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int *err)
672{ 672{
673 struct rtattr *tb[TCA_ACT_MAX+1]; 673 struct nlattr *tb[TCA_ACT_MAX+1];
674 struct tc_action *a; 674 struct tc_action *a;
675 int index; 675 int index;
676 676
677 *err = -EINVAL; 677 *err = -EINVAL;
678 if (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0) 678 if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
679 return NULL; 679 return NULL;
680 680
681 if (tb[TCA_ACT_INDEX - 1] == NULL || 681 if (tb[TCA_ACT_INDEX] == NULL ||
682 RTA_PAYLOAD(tb[TCA_ACT_INDEX - 1]) < sizeof(index)) 682 nla_len(tb[TCA_ACT_INDEX]) < sizeof(index))
683 return NULL; 683 return NULL;
684 index = *(int *)RTA_DATA(tb[TCA_ACT_INDEX - 1]); 684 index = *(int *)nla_data(tb[TCA_ACT_INDEX]);
685 685
686 *err = -ENOMEM; 686 *err = -ENOMEM;
687 a = kzalloc(sizeof(struct tc_action), GFP_KERNEL); 687 a = kzalloc(sizeof(struct tc_action), GFP_KERNEL);
@@ -689,7 +689,7 @@ tcf_action_get_1(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int *err)
689 return NULL; 689 return NULL;
690 690
691 *err = -EINVAL; 691 *err = -EINVAL;
692 a->ops = tc_lookup_action(tb[TCA_ACT_KIND - 1]); 692 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
693 if (a->ops == NULL) 693 if (a->ops == NULL)
694 goto err_free; 694 goto err_free;
695 if (a->ops->lookup == NULL) 695 if (a->ops->lookup == NULL)
@@ -731,16 +731,16 @@ static struct tc_action *create_a(int i)
731 return act; 731 return act;
732} 732}
733 733
734static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid) 734static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
735{ 735{
736 struct sk_buff *skb; 736 struct sk_buff *skb;
737 unsigned char *b; 737 unsigned char *b;
738 struct nlmsghdr *nlh; 738 struct nlmsghdr *nlh;
739 struct tcamsg *t; 739 struct tcamsg *t;
740 struct netlink_callback dcb; 740 struct netlink_callback dcb;
741 struct rtattr *x; 741 struct nlattr *x;
742 struct rtattr *tb[TCA_ACT_MAX+1]; 742 struct nlattr *tb[TCA_ACT_MAX+1];
743 struct rtattr *kind; 743 struct nlattr *kind;
744 struct tc_action *a = create_a(0); 744 struct tc_action *a = create_a(0);
745 int err = -EINVAL; 745 int err = -EINVAL;
746 746
@@ -758,10 +758,10 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
758 758
759 b = skb_tail_pointer(skb); 759 b = skb_tail_pointer(skb);
760 760
761 if (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0) 761 if (nla_parse_nested(tb, TCA_ACT_MAX, nla, NULL) < 0)
762 goto err_out; 762 goto err_out;
763 763
764 kind = tb[TCA_ACT_KIND-1]; 764 kind = tb[TCA_ACT_KIND];
765 a->ops = tc_lookup_action(kind); 765 a->ops = tc_lookup_action(kind);
766 if (a->ops == NULL) 766 if (a->ops == NULL)
767 goto err_out; 767 goto err_out;
@@ -772,14 +772,14 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
772 t->tca__pad1 = 0; 772 t->tca__pad1 = 0;
773 t->tca__pad2 = 0; 773 t->tca__pad2 = 0;
774 774
775 x = (struct rtattr *)skb_tail_pointer(skb); 775 x = (struct nlattr *)skb_tail_pointer(skb);
776 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 776 NLA_PUT(skb, TCA_ACT_TAB, 0, NULL);
777 777
778 err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); 778 err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
779 if (err < 0) 779 if (err < 0)
780 goto rtattr_failure; 780 goto nla_put_failure;
781 781
782 x->rta_len = skb_tail_pointer(skb) - (u8 *)x; 782 x->nla_len = skb_tail_pointer(skb) - (u8 *)x;
783 783
784 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 784 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
785 nlh->nlmsg_flags |= NLM_F_ROOT; 785 nlh->nlmsg_flags |= NLM_F_ROOT;
@@ -791,7 +791,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
791 791
792 return err; 792 return err;
793 793
794rtattr_failure: 794nla_put_failure:
795nlmsg_failure: 795nlmsg_failure:
796 module_put(a->ops->owner); 796 module_put(a->ops->owner);
797err_out: 797err_out:
@@ -801,13 +801,13 @@ err_out:
801} 801}
802 802
803static int 803static int
804tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event) 804tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event)
805{ 805{
806 int i, ret = 0; 806 int i, ret = 0;
807 struct rtattr *tb[TCA_ACT_MAX_PRIO+1]; 807 struct nlattr *tb[TCA_ACT_MAX_PRIO+1];
808 struct tc_action *head = NULL, *act, *act_prev = NULL; 808 struct tc_action *head = NULL, *act, *act_prev = NULL;
809 809
810 if (rtattr_parse_nested(tb, TCA_ACT_MAX_PRIO, rta) < 0) 810 if (nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL) < 0)
811 return -EINVAL; 811 return -EINVAL;
812 812
813 if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { 813 if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) {
@@ -815,11 +815,11 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
815 return tca_action_flush(tb[0], n, pid); 815 return tca_action_flush(tb[0], n, pid);
816 } 816 }
817 817
818 for (i=0; i < TCA_ACT_MAX_PRIO && tb[i]; i++) { 818 for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
819 act = tcf_action_get_1(tb[i], n, pid, &ret); 819 act = tcf_action_get_1(tb[i], n, pid, &ret);
820 if (act == NULL) 820 if (act == NULL)
821 goto err; 821 goto err;
822 act->order = i+1; 822 act->order = i;
823 823
824 if (head == NULL) 824 if (head == NULL)
825 head = act; 825 head = act;
@@ -865,7 +865,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
865 struct tcamsg *t; 865 struct tcamsg *t;
866 struct nlmsghdr *nlh; 866 struct nlmsghdr *nlh;
867 struct sk_buff *skb; 867 struct sk_buff *skb;
868 struct rtattr *x; 868 struct nlattr *x;
869 unsigned char *b; 869 unsigned char *b;
870 int err = 0; 870 int err = 0;
871 871
@@ -881,13 +881,13 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
881 t->tca__pad1 = 0; 881 t->tca__pad1 = 0;
882 t->tca__pad2 = 0; 882 t->tca__pad2 = 0;
883 883
884 x = (struct rtattr *)skb_tail_pointer(skb); 884 x = (struct nlattr *)skb_tail_pointer(skb);
885 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 885 NLA_PUT(skb, TCA_ACT_TAB, 0, NULL);
886 886
887 if (tcf_action_dump(skb, a, 0, 0) < 0) 887 if (tcf_action_dump(skb, a, 0, 0) < 0)
888 goto rtattr_failure; 888 goto nla_put_failure;
889 889
890 x->rta_len = skb_tail_pointer(skb) - (u8 *)x; 890 x->nla_len = skb_tail_pointer(skb) - (u8 *)x;
891 891
892 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 892 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
893 NETLINK_CB(skb).dst_group = RTNLGRP_TC; 893 NETLINK_CB(skb).dst_group = RTNLGRP_TC;
@@ -897,7 +897,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
897 err = 0; 897 err = 0;
898 return err; 898 return err;
899 899
900rtattr_failure: 900nla_put_failure:
901nlmsg_failure: 901nlmsg_failure:
902 kfree_skb(skb); 902 kfree_skb(skb);
903 return -1; 903 return -1;
@@ -905,14 +905,14 @@ nlmsg_failure:
905 905
906 906
907static int 907static int
908tcf_action_add(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int ovr) 908tcf_action_add(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int ovr)
909{ 909{
910 int ret = 0; 910 int ret = 0;
911 struct tc_action *act; 911 struct tc_action *act;
912 struct tc_action *a; 912 struct tc_action *a;
913 u32 seq = n->nlmsg_seq; 913 u32 seq = n->nlmsg_seq;
914 914
915 act = tcf_action_init(rta, NULL, NULL, ovr, 0, &ret); 915 act = tcf_action_init(nla, NULL, NULL, ovr, 0, &ret);
916 if (act == NULL) 916 if (act == NULL)
917 goto done; 917 goto done;
918 918
@@ -931,14 +931,18 @@ done:
931static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg) 931static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
932{ 932{
933 struct net *net = skb->sk->sk_net; 933 struct net *net = skb->sk->sk_net;
934 struct rtattr **tca = arg; 934 struct nlattr *tca[TCA_ACT_MAX + 1];
935 u32 pid = skb ? NETLINK_CB(skb).pid : 0; 935 u32 pid = skb ? NETLINK_CB(skb).pid : 0;
936 int ret = 0, ovr = 0; 936 int ret = 0, ovr = 0;
937 937
938 if (net != &init_net) 938 if (net != &init_net)
939 return -EINVAL; 939 return -EINVAL;
940 940
941 if (tca[TCA_ACT_TAB-1] == NULL) { 941 ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL);
942 if (ret < 0)
943 return ret;
944
945 if (tca[TCA_ACT_TAB] == NULL) {
942 printk("tc_ctl_action: received NO action attribs\n"); 946 printk("tc_ctl_action: received NO action attribs\n");
943 return -EINVAL; 947 return -EINVAL;
944 } 948 }
@@ -956,15 +960,15 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
956 if (n->nlmsg_flags&NLM_F_REPLACE) 960 if (n->nlmsg_flags&NLM_F_REPLACE)
957 ovr = 1; 961 ovr = 1;
958replay: 962replay:
959 ret = tcf_action_add(tca[TCA_ACT_TAB-1], n, pid, ovr); 963 ret = tcf_action_add(tca[TCA_ACT_TAB], n, pid, ovr);
960 if (ret == -EAGAIN) 964 if (ret == -EAGAIN)
961 goto replay; 965 goto replay;
962 break; 966 break;
963 case RTM_DELACTION: 967 case RTM_DELACTION:
964 ret = tca_action_gd(tca[TCA_ACT_TAB-1], n, pid, RTM_DELACTION); 968 ret = tca_action_gd(tca[TCA_ACT_TAB], n, pid, RTM_DELACTION);
965 break; 969 break;
966 case RTM_GETACTION: 970 case RTM_GETACTION:
967 ret = tca_action_gd(tca[TCA_ACT_TAB-1], n, pid, RTM_GETACTION); 971 ret = tca_action_gd(tca[TCA_ACT_TAB], n, pid, RTM_GETACTION);
968 break; 972 break;
969 default: 973 default:
970 BUG(); 974 BUG();
@@ -973,33 +977,33 @@ replay:
973 return ret; 977 return ret;
974} 978}
975 979
976static struct rtattr * 980static struct nlattr *
977find_dump_kind(struct nlmsghdr *n) 981find_dump_kind(struct nlmsghdr *n)
978{ 982{
979 struct rtattr *tb1, *tb2[TCA_ACT_MAX+1]; 983 struct nlattr *tb1, *tb2[TCA_ACT_MAX+1];
980 struct rtattr *tb[TCA_ACT_MAX_PRIO + 1]; 984 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
981 struct rtattr *rta[TCAA_MAX + 1]; 985 struct nlattr *nla[TCAA_MAX + 1];
982 struct rtattr *kind; 986 struct nlattr *kind;
983 int min_len = NLMSG_LENGTH(sizeof(struct tcamsg)); 987 int min_len = NLMSG_LENGTH(sizeof(struct tcamsg));
984 int attrlen = n->nlmsg_len - NLMSG_ALIGN(min_len); 988 int attrlen = n->nlmsg_len - NLMSG_ALIGN(min_len);
985 struct rtattr *attr = (void *) n + NLMSG_ALIGN(min_len); 989 struct nlattr *attr = (void *) n + NLMSG_ALIGN(min_len);
986 990
987 if (rtattr_parse(rta, TCAA_MAX, attr, attrlen) < 0) 991 if (nla_parse(nla, TCAA_MAX, attr, attrlen, NULL) < 0)
988 return NULL; 992 return NULL;
989 tb1 = rta[TCA_ACT_TAB - 1]; 993 tb1 = nla[TCA_ACT_TAB];
990 if (tb1 == NULL) 994 if (tb1 == NULL)
991 return NULL; 995 return NULL;
992 996
993 if (rtattr_parse(tb, TCA_ACT_MAX_PRIO, RTA_DATA(tb1), 997 if (nla_parse(tb, TCA_ACT_MAX_PRIO, nla_data(tb1),
994 NLMSG_ALIGN(RTA_PAYLOAD(tb1))) < 0) 998 NLMSG_ALIGN(nla_len(tb1)), NULL) < 0)
995 return NULL; 999 return NULL;
996 if (tb[0] == NULL) 1000 if (tb[0] == NULL)
997 return NULL; 1001 return NULL;
998 1002
999 if (rtattr_parse(tb2, TCA_ACT_MAX, RTA_DATA(tb[0]), 1003 if (nla_parse(tb2, TCA_ACT_MAX, nla_data(tb[0]),
1000 RTA_PAYLOAD(tb[0])) < 0) 1004 nla_len(tb[0]), NULL) < 0)
1001 return NULL; 1005 return NULL;
1002 kind = tb2[TCA_ACT_KIND-1]; 1006 kind = tb2[TCA_ACT_KIND];
1003 1007
1004 return kind; 1008 return kind;
1005} 1009}
@@ -1010,12 +1014,12 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1010 struct net *net = skb->sk->sk_net; 1014 struct net *net = skb->sk->sk_net;
1011 struct nlmsghdr *nlh; 1015 struct nlmsghdr *nlh;
1012 unsigned char *b = skb_tail_pointer(skb); 1016 unsigned char *b = skb_tail_pointer(skb);
1013 struct rtattr *x; 1017 struct nlattr *x;
1014 struct tc_action_ops *a_o; 1018 struct tc_action_ops *a_o;
1015 struct tc_action a; 1019 struct tc_action a;
1016 int ret = 0; 1020 int ret = 0;
1017 struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh); 1021 struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh);
1018 struct rtattr *kind = find_dump_kind(cb->nlh); 1022 struct nlattr *kind = find_dump_kind(cb->nlh);
1019 1023
1020 if (net != &init_net) 1024 if (net != &init_net)
1021 return 0; 1025 return 0;
@@ -1035,7 +1039,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1035 1039
1036 if (a_o->walk == NULL) { 1040 if (a_o->walk == NULL) {
1037 printk("tc_dump_action: %s !capable of dumping table\n", a_o->kind); 1041 printk("tc_dump_action: %s !capable of dumping table\n", a_o->kind);
1038 goto rtattr_failure; 1042 goto nla_put_failure;
1039 } 1043 }
1040 1044
1041 nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, 1045 nlh = NLMSG_PUT(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
@@ -1045,15 +1049,15 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1045 t->tca__pad1 = 0; 1049 t->tca__pad1 = 0;
1046 t->tca__pad2 = 0; 1050 t->tca__pad2 = 0;
1047 1051
1048 x = (struct rtattr *)skb_tail_pointer(skb); 1052 x = (struct nlattr *)skb_tail_pointer(skb);
1049 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 1053 NLA_PUT(skb, TCA_ACT_TAB, 0, NULL);
1050 1054
1051 ret = a_o->walk(skb, cb, RTM_GETACTION, &a); 1055 ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
1052 if (ret < 0) 1056 if (ret < 0)
1053 goto rtattr_failure; 1057 goto nla_put_failure;
1054 1058
1055 if (ret > 0) { 1059 if (ret > 0) {
1056 x->rta_len = skb_tail_pointer(skb) - (u8 *)x; 1060 x->nla_len = skb_tail_pointer(skb) - (u8 *)x;
1057 ret = skb->len; 1061 ret = skb->len;
1058 } else 1062 } else
1059 nlmsg_trim(skb, x); 1063 nlmsg_trim(skb, x);
@@ -1064,7 +1068,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1064 module_put(a_o->owner); 1068 module_put(a_o->owner);
1065 return skb->len; 1069 return skb->len;
1066 1070
1067rtattr_failure: 1071nla_put_failure:
1068nlmsg_failure: 1072nlmsg_failure:
1069 module_put(a_o->owner); 1073 module_put(a_o->owner);
1070 nlmsg_trim(skb, b); 1074 nlmsg_trim(skb, b);
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index a9631e426d91..5402cf885f95 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -53,26 +53,26 @@ typedef int (*g_rand)(struct tcf_gact *gact);
53static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ }; 53static g_rand gact_rand[MAX_RAND]= { NULL, gact_net_rand, gact_determ };
54#endif /* CONFIG_GACT_PROB */ 54#endif /* CONFIG_GACT_PROB */
55 55
56static int tcf_gact_init(struct rtattr *rta, struct rtattr *est, 56static int tcf_gact_init(struct nlattr *nla, struct nlattr *est,
57 struct tc_action *a, int ovr, int bind) 57 struct tc_action *a, int ovr, int bind)
58{ 58{
59 struct rtattr *tb[TCA_GACT_MAX]; 59 struct nlattr *tb[TCA_GACT_MAX + 1];
60 struct tc_gact *parm; 60 struct tc_gact *parm;
61 struct tcf_gact *gact; 61 struct tcf_gact *gact;
62 struct tcf_common *pc; 62 struct tcf_common *pc;
63 int ret = 0; 63 int ret = 0;
64 64
65 if (rta == NULL || rtattr_parse_nested(tb, TCA_GACT_MAX, rta) < 0) 65 if (nla == NULL || nla_parse_nested(tb, TCA_GACT_MAX, nla, NULL) < 0)
66 return -EINVAL; 66 return -EINVAL;
67 67
68 if (tb[TCA_GACT_PARMS - 1] == NULL || 68 if (tb[TCA_GACT_PARMS] == NULL ||
69 RTA_PAYLOAD(tb[TCA_GACT_PARMS - 1]) < sizeof(*parm)) 69 nla_len(tb[TCA_GACT_PARMS]) < sizeof(*parm))
70 return -EINVAL; 70 return -EINVAL;
71 parm = RTA_DATA(tb[TCA_GACT_PARMS - 1]); 71 parm = nla_data(tb[TCA_GACT_PARMS]);
72 72
73 if (tb[TCA_GACT_PROB-1] != NULL) 73 if (tb[TCA_GACT_PROB] != NULL)
74#ifdef CONFIG_GACT_PROB 74#ifdef CONFIG_GACT_PROB
75 if (RTA_PAYLOAD(tb[TCA_GACT_PROB-1]) < sizeof(struct tc_gact_p)) 75 if (nla_len(tb[TCA_GACT_PROB]) < sizeof(struct tc_gact_p))
76 return -EINVAL; 76 return -EINVAL;
77#else 77#else
78 return -EOPNOTSUPP; 78 return -EOPNOTSUPP;
@@ -97,8 +97,8 @@ static int tcf_gact_init(struct rtattr *rta, struct rtattr *est,
97 spin_lock_bh(&gact->tcf_lock); 97 spin_lock_bh(&gact->tcf_lock);
98 gact->tcf_action = parm->action; 98 gact->tcf_action = parm->action;
99#ifdef CONFIG_GACT_PROB 99#ifdef CONFIG_GACT_PROB
100 if (tb[TCA_GACT_PROB-1] != NULL) { 100 if (tb[TCA_GACT_PROB] != NULL) {
101 struct tc_gact_p *p_parm = RTA_DATA(tb[TCA_GACT_PROB-1]); 101 struct tc_gact_p *p_parm = nla_data(tb[TCA_GACT_PROB]);
102 gact->tcfg_paction = p_parm->paction; 102 gact->tcfg_paction = p_parm->paction;
103 gact->tcfg_pval = p_parm->pval; 103 gact->tcfg_pval = p_parm->pval;
104 gact->tcfg_ptype = p_parm->ptype; 104 gact->tcfg_ptype = p_parm->ptype;
@@ -154,23 +154,23 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
154 opt.refcnt = gact->tcf_refcnt - ref; 154 opt.refcnt = gact->tcf_refcnt - ref;
155 opt.bindcnt = gact->tcf_bindcnt - bind; 155 opt.bindcnt = gact->tcf_bindcnt - bind;
156 opt.action = gact->tcf_action; 156 opt.action = gact->tcf_action;
157 RTA_PUT(skb, TCA_GACT_PARMS, sizeof(opt), &opt); 157 NLA_PUT(skb, TCA_GACT_PARMS, sizeof(opt), &opt);
158#ifdef CONFIG_GACT_PROB 158#ifdef CONFIG_GACT_PROB
159 if (gact->tcfg_ptype) { 159 if (gact->tcfg_ptype) {
160 struct tc_gact_p p_opt; 160 struct tc_gact_p p_opt;
161 p_opt.paction = gact->tcfg_paction; 161 p_opt.paction = gact->tcfg_paction;
162 p_opt.pval = gact->tcfg_pval; 162 p_opt.pval = gact->tcfg_pval;
163 p_opt.ptype = gact->tcfg_ptype; 163 p_opt.ptype = gact->tcfg_ptype;
164 RTA_PUT(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt); 164 NLA_PUT(skb, TCA_GACT_PROB, sizeof(p_opt), &p_opt);
165 } 165 }
166#endif 166#endif
167 t.install = jiffies_to_clock_t(jiffies - gact->tcf_tm.install); 167 t.install = jiffies_to_clock_t(jiffies - gact->tcf_tm.install);
168 t.lastuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.lastuse); 168 t.lastuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.lastuse);
169 t.expires = jiffies_to_clock_t(gact->tcf_tm.expires); 169 t.expires = jiffies_to_clock_t(gact->tcf_tm.expires);
170 RTA_PUT(skb, TCA_GACT_TM, sizeof(t), &t); 170 NLA_PUT(skb, TCA_GACT_TM, sizeof(t), &t);
171 return skb->len; 171 return skb->len;
172 172
173rtattr_failure: 173nla_put_failure:
174 nlmsg_trim(skb, b); 174 nlmsg_trim(skb, b);
175 return -1; 175 return -1;
176} 176}
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index fa006e06ce33..fee5282637cc 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -92,10 +92,10 @@ static int tcf_ipt_release(struct tcf_ipt *ipt, int bind)
92 return ret; 92 return ret;
93} 93}
94 94
95static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est, 95static int tcf_ipt_init(struct nlattr *nla, struct nlattr *est,
96 struct tc_action *a, int ovr, int bind) 96 struct tc_action *a, int ovr, int bind)
97{ 97{
98 struct rtattr *tb[TCA_IPT_MAX]; 98 struct nlattr *tb[TCA_IPT_MAX + 1];
99 struct tcf_ipt *ipt; 99 struct tcf_ipt *ipt;
100 struct tcf_common *pc; 100 struct tcf_common *pc;
101 struct ipt_entry_target *td, *t; 101 struct ipt_entry_target *td, *t;
@@ -104,22 +104,22 @@ static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est,
104 u32 hook = 0; 104 u32 hook = 0;
105 u32 index = 0; 105 u32 index = 0;
106 106
107 if (rta == NULL || rtattr_parse_nested(tb, TCA_IPT_MAX, rta) < 0) 107 if (nla == NULL || nla_parse_nested(tb, TCA_IPT_MAX, nla, NULL) < 0)
108 return -EINVAL; 108 return -EINVAL;
109 109
110 if (tb[TCA_IPT_HOOK-1] == NULL || 110 if (tb[TCA_IPT_HOOK] == NULL ||
111 RTA_PAYLOAD(tb[TCA_IPT_HOOK-1]) < sizeof(u32)) 111 nla_len(tb[TCA_IPT_HOOK]) < sizeof(u32))
112 return -EINVAL; 112 return -EINVAL;
113 if (tb[TCA_IPT_TARG-1] == NULL || 113 if (tb[TCA_IPT_TARG] == NULL ||
114 RTA_PAYLOAD(tb[TCA_IPT_TARG-1]) < sizeof(*t)) 114 nla_len(tb[TCA_IPT_TARG]) < sizeof(*t))
115 return -EINVAL; 115 return -EINVAL;
116 td = (struct ipt_entry_target *)RTA_DATA(tb[TCA_IPT_TARG-1]); 116 td = (struct ipt_entry_target *)nla_data(tb[TCA_IPT_TARG]);
117 if (RTA_PAYLOAD(tb[TCA_IPT_TARG-1]) < td->u.target_size) 117 if (nla_len(tb[TCA_IPT_TARG]) < td->u.target_size)
118 return -EINVAL; 118 return -EINVAL;
119 119
120 if (tb[TCA_IPT_INDEX-1] != NULL && 120 if (tb[TCA_IPT_INDEX] != NULL &&
121 RTA_PAYLOAD(tb[TCA_IPT_INDEX-1]) >= sizeof(u32)) 121 nla_len(tb[TCA_IPT_INDEX]) >= sizeof(u32))
122 index = *(u32 *)RTA_DATA(tb[TCA_IPT_INDEX-1]); 122 index = *(u32 *)nla_data(tb[TCA_IPT_INDEX]);
123 123
124 pc = tcf_hash_check(index, a, bind, &ipt_hash_info); 124 pc = tcf_hash_check(index, a, bind, &ipt_hash_info);
125 if (!pc) { 125 if (!pc) {
@@ -136,14 +136,14 @@ static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est,
136 } 136 }
137 ipt = to_ipt(pc); 137 ipt = to_ipt(pc);
138 138
139 hook = *(u32 *)RTA_DATA(tb[TCA_IPT_HOOK-1]); 139 hook = *(u32 *)nla_data(tb[TCA_IPT_HOOK]);
140 140
141 err = -ENOMEM; 141 err = -ENOMEM;
142 tname = kmalloc(IFNAMSIZ, GFP_KERNEL); 142 tname = kmalloc(IFNAMSIZ, GFP_KERNEL);
143 if (unlikely(!tname)) 143 if (unlikely(!tname))
144 goto err1; 144 goto err1;
145 if (tb[TCA_IPT_TABLE - 1] == NULL || 145 if (tb[TCA_IPT_TABLE] == NULL ||
146 rtattr_strlcpy(tname, tb[TCA_IPT_TABLE-1], IFNAMSIZ) >= IFNAMSIZ) 146 nla_strlcpy(tname, tb[TCA_IPT_TABLE], IFNAMSIZ) >= IFNAMSIZ)
147 strcpy(tname, "mangle"); 147 strcpy(tname, "mangle");
148 148
149 t = kmemdup(td, td->u.target_size, GFP_KERNEL); 149 t = kmemdup(td, td->u.target_size, GFP_KERNEL);
@@ -243,25 +243,25 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
243 243
244 t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC); 244 t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC);
245 if (unlikely(!t)) 245 if (unlikely(!t))
246 goto rtattr_failure; 246 goto nla_put_failure;
247 247
248 c.bindcnt = ipt->tcf_bindcnt - bind; 248 c.bindcnt = ipt->tcf_bindcnt - bind;
249 c.refcnt = ipt->tcf_refcnt - ref; 249 c.refcnt = ipt->tcf_refcnt - ref;
250 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name); 250 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name);
251 251
252 RTA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t); 252 NLA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t);
253 RTA_PUT(skb, TCA_IPT_INDEX, 4, &ipt->tcf_index); 253 NLA_PUT(skb, TCA_IPT_INDEX, 4, &ipt->tcf_index);
254 RTA_PUT(skb, TCA_IPT_HOOK, 4, &ipt->tcfi_hook); 254 NLA_PUT(skb, TCA_IPT_HOOK, 4, &ipt->tcfi_hook);
255 RTA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c); 255 NLA_PUT(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c);
256 RTA_PUT(skb, TCA_IPT_TABLE, IFNAMSIZ, ipt->tcfi_tname); 256 NLA_PUT(skb, TCA_IPT_TABLE, IFNAMSIZ, ipt->tcfi_tname);
257 tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install); 257 tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install);
258 tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse); 258 tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse);
259 tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires); 259 tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires);
260 RTA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm); 260 NLA_PUT(skb, TCA_IPT_TM, sizeof (tm), &tm);
261 kfree(t); 261 kfree(t);
262 return skb->len; 262 return skb->len;
263 263
264rtattr_failure: 264nla_put_failure:
265 nlmsg_trim(skb, b); 265 nlmsg_trim(skb, b);
266 kfree(t); 266 kfree(t);
267 return -1; 267 return -1;
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index c3fde9180f9d..db943a8c7388 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -54,10 +54,10 @@ static inline int tcf_mirred_release(struct tcf_mirred *m, int bind)
54 return 0; 54 return 0;
55} 55}
56 56
57static int tcf_mirred_init(struct rtattr *rta, struct rtattr *est, 57static int tcf_mirred_init(struct nlattr *nla, struct nlattr *est,
58 struct tc_action *a, int ovr, int bind) 58 struct tc_action *a, int ovr, int bind)
59{ 59{
60 struct rtattr *tb[TCA_MIRRED_MAX]; 60 struct nlattr *tb[TCA_MIRRED_MAX + 1];
61 struct tc_mirred *parm; 61 struct tc_mirred *parm;
62 struct tcf_mirred *m; 62 struct tcf_mirred *m;
63 struct tcf_common *pc; 63 struct tcf_common *pc;
@@ -65,13 +65,13 @@ static int tcf_mirred_init(struct rtattr *rta, struct rtattr *est,
65 int ret = 0; 65 int ret = 0;
66 int ok_push = 0; 66 int ok_push = 0;
67 67
68 if (rta == NULL || rtattr_parse_nested(tb, TCA_MIRRED_MAX, rta) < 0) 68 if (nla == NULL || nla_parse_nested(tb, TCA_MIRRED_MAX, nla, NULL) < 0)
69 return -EINVAL; 69 return -EINVAL;
70 70
71 if (tb[TCA_MIRRED_PARMS-1] == NULL || 71 if (tb[TCA_MIRRED_PARMS] == NULL ||
72 RTA_PAYLOAD(tb[TCA_MIRRED_PARMS-1]) < sizeof(*parm)) 72 nla_len(tb[TCA_MIRRED_PARMS]) < sizeof(*parm))
73 return -EINVAL; 73 return -EINVAL;
74 parm = RTA_DATA(tb[TCA_MIRRED_PARMS-1]); 74 parm = nla_data(tb[TCA_MIRRED_PARMS]);
75 75
76 if (parm->ifindex) { 76 if (parm->ifindex) {
77 dev = __dev_get_by_index(&init_net, parm->ifindex); 77 dev = __dev_get_by_index(&init_net, parm->ifindex);
@@ -207,14 +207,14 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, i
207 opt.bindcnt = m->tcf_bindcnt - bind; 207 opt.bindcnt = m->tcf_bindcnt - bind;
208 opt.eaction = m->tcfm_eaction; 208 opt.eaction = m->tcfm_eaction;
209 opt.ifindex = m->tcfm_ifindex; 209 opt.ifindex = m->tcfm_ifindex;
210 RTA_PUT(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt); 210 NLA_PUT(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt);
211 t.install = jiffies_to_clock_t(jiffies - m->tcf_tm.install); 211 t.install = jiffies_to_clock_t(jiffies - m->tcf_tm.install);
212 t.lastuse = jiffies_to_clock_t(jiffies - m->tcf_tm.lastuse); 212 t.lastuse = jiffies_to_clock_t(jiffies - m->tcf_tm.lastuse);
213 t.expires = jiffies_to_clock_t(m->tcf_tm.expires); 213 t.expires = jiffies_to_clock_t(m->tcf_tm.expires);
214 RTA_PUT(skb, TCA_MIRRED_TM, sizeof(t), &t); 214 NLA_PUT(skb, TCA_MIRRED_TM, sizeof(t), &t);
215 return skb->len; 215 return skb->len;
216 216
217rtattr_failure: 217nla_put_failure:
218 nlmsg_trim(skb, b); 218 nlmsg_trim(skb, b);
219 return -1; 219 return -1;
220} 220}
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index da5c1eae4222..be007bb31b59 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -40,22 +40,22 @@ static struct tcf_hashinfo nat_hash_info = {
40 .lock = &nat_lock, 40 .lock = &nat_lock,
41}; 41};
42 42
43static int tcf_nat_init(struct rtattr *rta, struct rtattr *est, 43static int tcf_nat_init(struct nlattr *nla, struct nlattr *est,
44 struct tc_action *a, int ovr, int bind) 44 struct tc_action *a, int ovr, int bind)
45{ 45{
46 struct rtattr *tb[TCA_NAT_MAX]; 46 struct nlattr *tb[TCA_NAT_MAX + 1];
47 struct tc_nat *parm; 47 struct tc_nat *parm;
48 int ret = 0; 48 int ret = 0;
49 struct tcf_nat *p; 49 struct tcf_nat *p;
50 struct tcf_common *pc; 50 struct tcf_common *pc;
51 51
52 if (rta == NULL || rtattr_parse_nested(tb, TCA_NAT_MAX, rta) < 0) 52 if (nla == NULL || nla_parse_nested(tb, TCA_NAT_MAX, nla, NULL) < 0)
53 return -EINVAL; 53 return -EINVAL;
54 54
55 if (tb[TCA_NAT_PARMS - 1] == NULL || 55 if (tb[TCA_NAT_PARMS] == NULL ||
56 RTA_PAYLOAD(tb[TCA_NAT_PARMS - 1]) < sizeof(*parm)) 56 nla_len(tb[TCA_NAT_PARMS]) < sizeof(*parm))
57 return -EINVAL; 57 return -EINVAL;
58 parm = RTA_DATA(tb[TCA_NAT_PARMS - 1]); 58 parm = nla_data(tb[TCA_NAT_PARMS]);
59 59
60 pc = tcf_hash_check(parm->index, a, bind, &nat_hash_info); 60 pc = tcf_hash_check(parm->index, a, bind, &nat_hash_info);
61 if (!pc) { 61 if (!pc) {
@@ -275,17 +275,17 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
275 opt->refcnt = p->tcf_refcnt - ref; 275 opt->refcnt = p->tcf_refcnt - ref;
276 opt->bindcnt = p->tcf_bindcnt - bind; 276 opt->bindcnt = p->tcf_bindcnt - bind;
277 277
278 RTA_PUT(skb, TCA_NAT_PARMS, s, opt); 278 NLA_PUT(skb, TCA_NAT_PARMS, s, opt);
279 t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install); 279 t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
280 t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse); 280 t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
281 t.expires = jiffies_to_clock_t(p->tcf_tm.expires); 281 t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
282 RTA_PUT(skb, TCA_NAT_TM, sizeof(t), &t); 282 NLA_PUT(skb, TCA_NAT_TM, sizeof(t), &t);
283 283
284 kfree(opt); 284 kfree(opt);
285 285
286 return skb->len; 286 return skb->len;
287 287
288rtattr_failure: 288nla_put_failure:
289 nlmsg_trim(skb, b); 289 nlmsg_trim(skb, b);
290 kfree(opt); 290 kfree(opt);
291 return -1; 291 return -1;
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index b46fab5fb323..88d8a15a1921 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -33,10 +33,10 @@ static struct tcf_hashinfo pedit_hash_info = {
33 .lock = &pedit_lock, 33 .lock = &pedit_lock,
34}; 34};
35 35
36static int tcf_pedit_init(struct rtattr *rta, struct rtattr *est, 36static int tcf_pedit_init(struct nlattr *nla, struct nlattr *est,
37 struct tc_action *a, int ovr, int bind) 37 struct tc_action *a, int ovr, int bind)
38{ 38{
39 struct rtattr *tb[TCA_PEDIT_MAX]; 39 struct nlattr *tb[TCA_PEDIT_MAX + 1];
40 struct tc_pedit *parm; 40 struct tc_pedit *parm;
41 int ret = 0; 41 int ret = 0;
42 struct tcf_pedit *p; 42 struct tcf_pedit *p;
@@ -44,15 +44,15 @@ static int tcf_pedit_init(struct rtattr *rta, struct rtattr *est,
44 struct tc_pedit_key *keys = NULL; 44 struct tc_pedit_key *keys = NULL;
45 int ksize; 45 int ksize;
46 46
47 if (rta == NULL || rtattr_parse_nested(tb, TCA_PEDIT_MAX, rta) < 0) 47 if (nla == NULL || nla_parse_nested(tb, TCA_PEDIT_MAX, nla, NULL) < 0)
48 return -EINVAL; 48 return -EINVAL;
49 49
50 if (tb[TCA_PEDIT_PARMS - 1] == NULL || 50 if (tb[TCA_PEDIT_PARMS] == NULL ||
51 RTA_PAYLOAD(tb[TCA_PEDIT_PARMS-1]) < sizeof(*parm)) 51 nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm))
52 return -EINVAL; 52 return -EINVAL;
53 parm = RTA_DATA(tb[TCA_PEDIT_PARMS-1]); 53 parm = nla_data(tb[TCA_PEDIT_PARMS]);
54 ksize = parm->nkeys * sizeof(struct tc_pedit_key); 54 ksize = parm->nkeys * sizeof(struct tc_pedit_key);
55 if (RTA_PAYLOAD(tb[TCA_PEDIT_PARMS-1]) < sizeof(*parm) + ksize) 55 if (nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm) + ksize)
56 return -EINVAL; 56 return -EINVAL;
57 57
58 pc = tcf_hash_check(parm->index, a, bind, &pedit_hash_info); 58 pc = tcf_hash_check(parm->index, a, bind, &pedit_hash_info);
@@ -206,15 +206,15 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
206 opt->refcnt = p->tcf_refcnt - ref; 206 opt->refcnt = p->tcf_refcnt - ref;
207 opt->bindcnt = p->tcf_bindcnt - bind; 207 opt->bindcnt = p->tcf_bindcnt - bind;
208 208
209 RTA_PUT(skb, TCA_PEDIT_PARMS, s, opt); 209 NLA_PUT(skb, TCA_PEDIT_PARMS, s, opt);
210 t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install); 210 t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install);
211 t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse); 211 t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse);
212 t.expires = jiffies_to_clock_t(p->tcf_tm.expires); 212 t.expires = jiffies_to_clock_t(p->tcf_tm.expires);
213 RTA_PUT(skb, TCA_PEDIT_TM, sizeof(t), &t); 213 NLA_PUT(skb, TCA_PEDIT_TM, sizeof(t), &t);
214 kfree(opt); 214 kfree(opt);
215 return skb->len; 215 return skb->len;
216 216
217rtattr_failure: 217nla_put_failure:
218 nlmsg_trim(skb, b); 218 nlmsg_trim(skb, b);
219 kfree(opt); 219 kfree(opt);
220 return -1; 220 return -1;
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 07ffdf9c5e59..3af5759aac26 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -54,7 +54,7 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
54{ 54{
55 struct tcf_common *p; 55 struct tcf_common *p;
56 int err = 0, index = -1, i = 0, s_i = 0, n_i = 0; 56 int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
57 struct rtattr *r; 57 struct nlattr *r;
58 58
59 read_lock_bh(&police_lock); 59 read_lock_bh(&police_lock);
60 60
@@ -69,8 +69,8 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
69 continue; 69 continue;
70 a->priv = p; 70 a->priv = p;
71 a->order = index; 71 a->order = index;
72 r = (struct rtattr *)skb_tail_pointer(skb); 72 r = (struct nlattr *)skb_tail_pointer(skb);
73 RTA_PUT(skb, a->order, 0, NULL); 73 NLA_PUT(skb, a->order, 0, NULL);
74 if (type == RTM_DELACTION) 74 if (type == RTM_DELACTION)
75 err = tcf_action_dump_1(skb, a, 0, 1); 75 err = tcf_action_dump_1(skb, a, 0, 1);
76 else 76 else
@@ -80,7 +80,7 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
80 nlmsg_trim(skb, r); 80 nlmsg_trim(skb, r);
81 goto done; 81 goto done;
82 } 82 }
83 r->rta_len = skb_tail_pointer(skb) - (u8 *)r; 83 r->nla_len = skb_tail_pointer(skb) - (u8 *)r;
84 n_i++; 84 n_i++;
85 } 85 }
86 } 86 }
@@ -90,7 +90,7 @@ done:
90 cb->args[0] += n_i; 90 cb->args[0] += n_i;
91 return n_i; 91 return n_i;
92 92
93rtattr_failure: 93nla_put_failure:
94 nlmsg_trim(skb, r); 94 nlmsg_trim(skb, r);
95 goto done; 95 goto done;
96} 96}
@@ -118,32 +118,32 @@ static void tcf_police_destroy(struct tcf_police *p)
118 BUG_TRAP(0); 118 BUG_TRAP(0);
119} 119}
120 120
121static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est, 121static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est,
122 struct tc_action *a, int ovr, int bind) 122 struct tc_action *a, int ovr, int bind)
123{ 123{
124 unsigned h; 124 unsigned h;
125 int ret = 0, err; 125 int ret = 0, err;
126 struct rtattr *tb[TCA_POLICE_MAX]; 126 struct nlattr *tb[TCA_POLICE_MAX + 1];
127 struct tc_police *parm; 127 struct tc_police *parm;
128 struct tcf_police *police; 128 struct tcf_police *police;
129 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; 129 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
130 int size; 130 int size;
131 131
132 if (rta == NULL || rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0) 132 if (nla == NULL || nla_parse_nested(tb, TCA_POLICE_MAX, nla, NULL) < 0)
133 return -EINVAL; 133 return -EINVAL;
134 134
135 if (tb[TCA_POLICE_TBF-1] == NULL) 135 if (tb[TCA_POLICE_TBF] == NULL)
136 return -EINVAL; 136 return -EINVAL;
137 size = RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]); 137 size = nla_len(tb[TCA_POLICE_TBF]);
138 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat)) 138 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
139 return -EINVAL; 139 return -EINVAL;
140 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]); 140 parm = nla_data(tb[TCA_POLICE_TBF]);
141 141
142 if (tb[TCA_POLICE_RESULT-1] != NULL && 142 if (tb[TCA_POLICE_RESULT] != NULL &&
143 RTA_PAYLOAD(tb[TCA_POLICE_RESULT-1]) != sizeof(u32)) 143 nla_len(tb[TCA_POLICE_RESULT]) != sizeof(u32))
144 return -EINVAL; 144 return -EINVAL;
145 if (tb[TCA_POLICE_RESULT-1] != NULL && 145 if (tb[TCA_POLICE_RESULT] != NULL &&
146 RTA_PAYLOAD(tb[TCA_POLICE_RESULT-1]) != sizeof(u32)) 146 nla_len(tb[TCA_POLICE_RESULT]) != sizeof(u32))
147 return -EINVAL; 147 return -EINVAL;
148 148
149 if (parm->index) { 149 if (parm->index) {
@@ -174,12 +174,12 @@ static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,
174override: 174override:
175 if (parm->rate.rate) { 175 if (parm->rate.rate) {
176 err = -ENOMEM; 176 err = -ENOMEM;
177 R_tab = qdisc_get_rtab(&parm->rate, (struct nlattr *)tb[TCA_POLICE_RATE-1]); 177 R_tab = qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE]);
178 if (R_tab == NULL) 178 if (R_tab == NULL)
179 goto failure; 179 goto failure;
180 if (parm->peakrate.rate) { 180 if (parm->peakrate.rate) {
181 P_tab = qdisc_get_rtab(&parm->peakrate, 181 P_tab = qdisc_get_rtab(&parm->peakrate,
182 (struct nlattr *)tb[TCA_POLICE_PEAKRATE-1]); 182 tb[TCA_POLICE_PEAKRATE]);
183 if (P_tab == NULL) { 183 if (P_tab == NULL) {
184 qdisc_put_rtab(R_tab); 184 qdisc_put_rtab(R_tab);
185 goto failure; 185 goto failure;
@@ -197,8 +197,8 @@ override:
197 police->tcfp_P_tab = P_tab; 197 police->tcfp_P_tab = P_tab;
198 } 198 }
199 199
200 if (tb[TCA_POLICE_RESULT-1]) 200 if (tb[TCA_POLICE_RESULT])
201 police->tcfp_result = *(u32*)RTA_DATA(tb[TCA_POLICE_RESULT-1]); 201 police->tcfp_result = *(u32*)nla_data(tb[TCA_POLICE_RESULT]);
202 police->tcfp_toks = police->tcfp_burst = parm->burst; 202 police->tcfp_toks = police->tcfp_burst = parm->burst;
203 police->tcfp_mtu = parm->mtu; 203 police->tcfp_mtu = parm->mtu;
204 if (police->tcfp_mtu == 0) { 204 if (police->tcfp_mtu == 0) {
@@ -210,13 +210,13 @@ override:
210 police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); 210 police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu);
211 police->tcf_action = parm->action; 211 police->tcf_action = parm->action;
212 212
213 if (tb[TCA_POLICE_AVRATE-1]) 213 if (tb[TCA_POLICE_AVRATE])
214 police->tcfp_ewma_rate = 214 police->tcfp_ewma_rate =
215 *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]); 215 *(u32*)nla_data(tb[TCA_POLICE_AVRATE]);
216 if (est) 216 if (est)
217 gen_replace_estimator(&police->tcf_bstats, 217 gen_replace_estimator(&police->tcf_bstats,
218 &police->tcf_rate_est, 218 &police->tcf_rate_est,
219 &police->tcf_lock, (struct nlattr *)est); 219 &police->tcf_lock, est);
220 220
221 spin_unlock_bh(&police->tcf_lock); 221 spin_unlock_bh(&police->tcf_lock);
222 if (ret != ACT_P_CREATED) 222 if (ret != ACT_P_CREATED)
@@ -332,15 +332,15 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
332 opt.peakrate = police->tcfp_P_tab->rate; 332 opt.peakrate = police->tcfp_P_tab->rate;
333 else 333 else
334 memset(&opt.peakrate, 0, sizeof(opt.peakrate)); 334 memset(&opt.peakrate, 0, sizeof(opt.peakrate));
335 RTA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt); 335 NLA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt);
336 if (police->tcfp_result) 336 if (police->tcfp_result)
337 RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int), 337 NLA_PUT(skb, TCA_POLICE_RESULT, sizeof(int),
338 &police->tcfp_result); 338 &police->tcfp_result);
339 if (police->tcfp_ewma_rate) 339 if (police->tcfp_ewma_rate)
340 RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate); 340 NLA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate);
341 return skb->len; 341 return skb->len;
342 342
343rtattr_failure: 343nla_put_failure:
344 nlmsg_trim(skb, b); 344 nlmsg_trim(skb, b);
345 return -1; 345 return -1;
346} 346}
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index fb84ef33d14f..d3226e24070b 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -84,10 +84,10 @@ static int realloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata)
84 return alloc_defdata(d, datalen, defdata); 84 return alloc_defdata(d, datalen, defdata);
85} 85}
86 86
87static int tcf_simp_init(struct rtattr *rta, struct rtattr *est, 87static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
88 struct tc_action *a, int ovr, int bind) 88 struct tc_action *a, int ovr, int bind)
89{ 89{
90 struct rtattr *tb[TCA_DEF_MAX]; 90 struct nlattr *tb[TCA_DEF_MAX + 1];
91 struct tc_defact *parm; 91 struct tc_defact *parm;
92 struct tcf_defact *d; 92 struct tcf_defact *d;
93 struct tcf_common *pc; 93 struct tcf_common *pc;
@@ -95,19 +95,19 @@ static int tcf_simp_init(struct rtattr *rta, struct rtattr *est,
95 u32 datalen = 0; 95 u32 datalen = 0;
96 int ret = 0; 96 int ret = 0;
97 97
98 if (rta == NULL || rtattr_parse_nested(tb, TCA_DEF_MAX, rta) < 0) 98 if (nla == NULL || nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL) < 0)
99 return -EINVAL; 99 return -EINVAL;
100 100
101 if (tb[TCA_DEF_PARMS - 1] == NULL || 101 if (tb[TCA_DEF_PARMS] == NULL ||
102 RTA_PAYLOAD(tb[TCA_DEF_PARMS - 1]) < sizeof(*parm)) 102 nla_len(tb[TCA_DEF_PARMS]) < sizeof(*parm))
103 return -EINVAL; 103 return -EINVAL;
104 104
105 parm = RTA_DATA(tb[TCA_DEF_PARMS - 1]); 105 parm = nla_data(tb[TCA_DEF_PARMS]);
106 defdata = RTA_DATA(tb[TCA_DEF_DATA - 1]); 106 defdata = nla_data(tb[TCA_DEF_DATA]);
107 if (defdata == NULL) 107 if (defdata == NULL)
108 return -EINVAL; 108 return -EINVAL;
109 109
110 datalen = RTA_PAYLOAD(tb[TCA_DEF_DATA - 1]); 110 datalen = nla_len(tb[TCA_DEF_DATA]);
111 if (datalen <= 0) 111 if (datalen <= 0)
112 return -EINVAL; 112 return -EINVAL;
113 113
@@ -164,15 +164,15 @@ static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
164 opt.refcnt = d->tcf_refcnt - ref; 164 opt.refcnt = d->tcf_refcnt - ref;
165 opt.bindcnt = d->tcf_bindcnt - bind; 165 opt.bindcnt = d->tcf_bindcnt - bind;
166 opt.action = d->tcf_action; 166 opt.action = d->tcf_action;
167 RTA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); 167 NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt);
168 RTA_PUT(skb, TCA_DEF_DATA, d->tcfd_datalen, d->tcfd_defdata); 168 NLA_PUT(skb, TCA_DEF_DATA, d->tcfd_datalen, d->tcfd_defdata);
169 t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); 169 t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
170 t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); 170 t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
171 t.expires = jiffies_to_clock_t(d->tcf_tm.expires); 171 t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
172 RTA_PUT(skb, TCA_DEF_TM, sizeof(t), &t); 172 NLA_PUT(skb, TCA_DEF_TM, sizeof(t), &t);
173 return skb->len; 173 return skb->len;
174 174
175rtattr_failure: 175nla_put_failure:
176 nlmsg_trim(skb, b); 176 nlmsg_trim(skb, b);
177 return -1; 177 return -1;
178} 178}
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 87be2b2fc29a..d870478e3640 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -491,8 +491,7 @@ int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb,
491 struct tc_action *act; 491 struct tc_action *act;
492 492
493 if (map->police && tb[map->police]) { 493 if (map->police && tb[map->police]) {
494 act = tcf_action_init_1((struct rtattr *)tb[map->police], 494 act = tcf_action_init_1(tb[map->police], rate_tlv,
495 (struct rtattr *)rate_tlv,
496 "police", TCA_ACT_NOREPLACE, 495 "police", TCA_ACT_NOREPLACE,
497 TCA_ACT_BIND, &err); 496 TCA_ACT_BIND, &err);
498 if (act == NULL) 497 if (act == NULL)
@@ -501,8 +500,7 @@ int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb,
501 act->type = TCA_OLD_COMPAT; 500 act->type = TCA_OLD_COMPAT;
502 exts->action = act; 501 exts->action = act;
503 } else if (map->action && tb[map->action]) { 502 } else if (map->action && tb[map->action]) {
504 act = tcf_action_init((struct rtattr *)tb[map->action], 503 act = tcf_action_init(tb[map->action], rate_tlv, NULL,
505 (struct rtattr *)rate_tlv, NULL,
506 TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err); 504 TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
507 if (act == NULL) 505 if (act == NULL)
508 return err; 506 return err;