aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_api.c
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/sched/act_api.c
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/sched/act_api.c')
-rw-r--r--net/sched/act_api.c214
1 files changed, 109 insertions, 105 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);