diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/act_api.c | 84 | ||||
-rw-r--r-- | net/sched/act_police.c | 13 | ||||
-rw-r--r-- | net/sched/cls_api.c | 14 | ||||
-rw-r--r-- | net/sched/cls_basic.c | 12 | ||||
-rw-r--r-- | net/sched/cls_fw.c | 9 | ||||
-rw-r--r-- | net/sched/cls_route.c | 9 | ||||
-rw-r--r-- | net/sched/cls_rsvp.h | 10 | ||||
-rw-r--r-- | net/sched/cls_tcindex.c | 13 | ||||
-rw-r--r-- | net/sched/cls_u32.c | 13 | ||||
-rw-r--r-- | net/sched/ematch.c | 16 | ||||
-rw-r--r-- | net/sched/sch_atm.c | 15 | ||||
-rw-r--r-- | net/sched/sch_cbq.c | 24 | ||||
-rw-r--r-- | net/sched/sch_hfsc.c | 11 | ||||
-rw-r--r-- | net/sched/sch_htb.c | 32 | ||||
-rw-r--r-- | net/sched/sch_ingress.c | 12 | ||||
-rw-r--r-- | net/sched/sch_tbf.c | 12 |
16 files changed, 166 insertions, 133 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 87818d7fb623..36022605fc16 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -69,7 +69,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb, | |||
69 | { | 69 | { |
70 | struct tcf_common *p; | 70 | struct tcf_common *p; |
71 | int err = 0, index = -1,i = 0, s_i = 0, n_i = 0; | 71 | int err = 0, index = -1,i = 0, s_i = 0, n_i = 0; |
72 | struct nlattr *r ; | 72 | struct nlattr *nest; |
73 | 73 | ||
74 | read_lock_bh(hinfo->lock); | 74 | read_lock_bh(hinfo->lock); |
75 | 75 | ||
@@ -84,15 +84,17 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb, | |||
84 | continue; | 84 | continue; |
85 | a->priv = p; | 85 | a->priv = p; |
86 | a->order = n_i; | 86 | a->order = n_i; |
87 | r = (struct nlattr *)skb_tail_pointer(skb); | 87 | |
88 | NLA_PUT(skb, a->order, 0, NULL); | 88 | nest = nla_nest_start(skb, a->order); |
89 | if (nest == NULL) | ||
90 | goto nla_put_failure; | ||
89 | err = tcf_action_dump_1(skb, a, 0, 0); | 91 | err = tcf_action_dump_1(skb, a, 0, 0); |
90 | if (err < 0) { | 92 | if (err < 0) { |
91 | index--; | 93 | index--; |
92 | nlmsg_trim(skb, r); | 94 | nlmsg_trim(skb, nest); |
93 | goto done; | 95 | goto done; |
94 | } | 96 | } |
95 | r->nla_len = skb_tail_pointer(skb) - (u8 *)r; | 97 | nla_nest_end(skb, nest); |
96 | n_i++; | 98 | n_i++; |
97 | if (n_i >= TCA_ACT_MAX_PRIO) | 99 | if (n_i >= TCA_ACT_MAX_PRIO) |
98 | goto done; | 100 | goto done; |
@@ -105,7 +107,7 @@ done: | |||
105 | return n_i; | 107 | return n_i; |
106 | 108 | ||
107 | nla_put_failure: | 109 | nla_put_failure: |
108 | nlmsg_trim(skb, r); | 110 | nla_nest_cancel(skb, nest); |
109 | goto done; | 111 | goto done; |
110 | } | 112 | } |
111 | 113 | ||
@@ -113,11 +115,12 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a, | |||
113 | struct tcf_hashinfo *hinfo) | 115 | struct tcf_hashinfo *hinfo) |
114 | { | 116 | { |
115 | struct tcf_common *p, *s_p; | 117 | struct tcf_common *p, *s_p; |
116 | struct nlattr *r ; | 118 | struct nlattr *nest; |
117 | int i= 0, n_i = 0; | 119 | int i= 0, n_i = 0; |
118 | 120 | ||
119 | r = (struct nlattr *)skb_tail_pointer(skb); | 121 | nest = nla_nest_start(skb, a->order); |
120 | NLA_PUT(skb, a->order, 0, NULL); | 122 | if (nest == NULL) |
123 | goto nla_put_failure; | ||
121 | NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); | 124 | NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); |
122 | for (i = 0; i < (hinfo->hmask + 1); i++) { | 125 | for (i = 0; i < (hinfo->hmask + 1); i++) { |
123 | p = hinfo->htab[tcf_hash(i, hinfo->hmask)]; | 126 | p = hinfo->htab[tcf_hash(i, hinfo->hmask)]; |
@@ -131,11 +134,11 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a, | |||
131 | } | 134 | } |
132 | } | 135 | } |
133 | NLA_PUT(skb, TCA_FCNT, 4, &n_i); | 136 | NLA_PUT(skb, TCA_FCNT, 4, &n_i); |
134 | r->nla_len = skb_tail_pointer(skb) - (u8 *)r; | 137 | nla_nest_end(skb, nest); |
135 | 138 | ||
136 | return n_i; | 139 | return n_i; |
137 | nla_put_failure: | 140 | nla_put_failure: |
138 | nlmsg_trim(skb, r); | 141 | nla_nest_cancel(skb, nest); |
139 | return -EINVAL; | 142 | return -EINVAL; |
140 | } | 143 | } |
141 | 144 | ||
@@ -415,7 +418,7 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) | |||
415 | { | 418 | { |
416 | int err = -EINVAL; | 419 | int err = -EINVAL; |
417 | unsigned char *b = skb_tail_pointer(skb); | 420 | unsigned char *b = skb_tail_pointer(skb); |
418 | struct nlattr *r; | 421 | struct nlattr *nest; |
419 | 422 | ||
420 | if (a->ops == NULL || a->ops->dump == NULL) | 423 | if (a->ops == NULL || a->ops->dump == NULL) |
421 | return err; | 424 | return err; |
@@ -423,10 +426,11 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) | |||
423 | NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); | 426 | NLA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); |
424 | if (tcf_action_copy_stats(skb, a, 0)) | 427 | if (tcf_action_copy_stats(skb, a, 0)) |
425 | goto nla_put_failure; | 428 | goto nla_put_failure; |
426 | r = (struct nlattr *)skb_tail_pointer(skb); | 429 | nest = nla_nest_start(skb, TCA_OPTIONS); |
427 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 430 | if (nest == NULL) |
431 | goto nla_put_failure; | ||
428 | if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) { | 432 | if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) { |
429 | r->nla_len = skb_tail_pointer(skb) - (u8 *)r; | 433 | nla_nest_end(skb, nest); |
430 | return err; | 434 | return err; |
431 | } | 435 | } |
432 | 436 | ||
@@ -441,17 +445,17 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref) | |||
441 | { | 445 | { |
442 | struct tc_action *a; | 446 | struct tc_action *a; |
443 | int err = -EINVAL; | 447 | int err = -EINVAL; |
444 | unsigned char *b = skb_tail_pointer(skb); | 448 | struct nlattr *nest; |
445 | struct nlattr *r ; | ||
446 | 449 | ||
447 | while ((a = act) != NULL) { | 450 | while ((a = act) != NULL) { |
448 | r = (struct nlattr *)skb_tail_pointer(skb); | ||
449 | act = a->next; | 451 | act = a->next; |
450 | NLA_PUT(skb, a->order, 0, NULL); | 452 | nest = nla_nest_start(skb, a->order); |
453 | if (nest == NULL) | ||
454 | goto nla_put_failure; | ||
451 | err = tcf_action_dump_1(skb, a, bind, ref); | 455 | err = tcf_action_dump_1(skb, a, bind, ref); |
452 | if (err < 0) | 456 | if (err < 0) |
453 | goto errout; | 457 | goto errout; |
454 | r->nla_len = skb_tail_pointer(skb) - (u8 *)r; | 458 | nla_nest_end(skb, nest); |
455 | } | 459 | } |
456 | 460 | ||
457 | return 0; | 461 | return 0; |
@@ -459,7 +463,7 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref) | |||
459 | nla_put_failure: | 463 | nla_put_failure: |
460 | err = -EINVAL; | 464 | err = -EINVAL; |
461 | errout: | 465 | errout: |
462 | nlmsg_trim(skb, b); | 466 | nla_nest_cancel(skb, nest); |
463 | return err; | 467 | return err; |
464 | } | 468 | } |
465 | 469 | ||
@@ -627,7 +631,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq, | |||
627 | struct tcamsg *t; | 631 | struct tcamsg *t; |
628 | struct nlmsghdr *nlh; | 632 | struct nlmsghdr *nlh; |
629 | unsigned char *b = skb_tail_pointer(skb); | 633 | unsigned char *b = skb_tail_pointer(skb); |
630 | struct nlattr *x; | 634 | struct nlattr *nest; |
631 | 635 | ||
632 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags); | 636 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags); |
633 | 637 | ||
@@ -636,13 +640,14 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq, | |||
636 | t->tca__pad1 = 0; | 640 | t->tca__pad1 = 0; |
637 | t->tca__pad2 = 0; | 641 | t->tca__pad2 = 0; |
638 | 642 | ||
639 | x = (struct nlattr *)skb_tail_pointer(skb); | 643 | nest = nla_nest_start(skb, TCA_ACT_TAB); |
640 | NLA_PUT(skb, TCA_ACT_TAB, 0, NULL); | 644 | if (nest == NULL) |
645 | goto nla_put_failure; | ||
641 | 646 | ||
642 | if (tcf_action_dump(skb, a, bind, ref) < 0) | 647 | if (tcf_action_dump(skb, a, bind, ref) < 0) |
643 | goto nla_put_failure; | 648 | goto nla_put_failure; |
644 | 649 | ||
645 | x->nla_len = skb_tail_pointer(skb) - (u8 *)x; | 650 | nla_nest_end(skb, nest); |
646 | 651 | ||
647 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 652 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
648 | return skb->len; | 653 | return skb->len; |
@@ -743,7 +748,7 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
743 | struct nlmsghdr *nlh; | 748 | struct nlmsghdr *nlh; |
744 | struct tcamsg *t; | 749 | struct tcamsg *t; |
745 | struct netlink_callback dcb; | 750 | struct netlink_callback dcb; |
746 | struct nlattr *x; | 751 | struct nlattr *nest; |
747 | struct nlattr *tb[TCA_ACT_MAX+1]; | 752 | struct nlattr *tb[TCA_ACT_MAX+1]; |
748 | struct nlattr *kind; | 753 | struct nlattr *kind; |
749 | struct tc_action *a = create_a(0); | 754 | struct tc_action *a = create_a(0); |
@@ -779,14 +784,15 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
779 | t->tca__pad1 = 0; | 784 | t->tca__pad1 = 0; |
780 | t->tca__pad2 = 0; | 785 | t->tca__pad2 = 0; |
781 | 786 | ||
782 | x = (struct nlattr *)skb_tail_pointer(skb); | 787 | nest = nla_nest_start(skb, TCA_ACT_TAB); |
783 | NLA_PUT(skb, TCA_ACT_TAB, 0, NULL); | 788 | if (nest == NULL) |
789 | goto nla_put_failure; | ||
784 | 790 | ||
785 | err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); | 791 | err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); |
786 | if (err < 0) | 792 | if (err < 0) |
787 | goto nla_put_failure; | 793 | goto nla_put_failure; |
788 | 794 | ||
789 | x->nla_len = skb_tail_pointer(skb) - (u8 *)x; | 795 | nla_nest_end(skb, nest); |
790 | 796 | ||
791 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 797 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
792 | nlh->nlmsg_flags |= NLM_F_ROOT; | 798 | nlh->nlmsg_flags |= NLM_F_ROOT; |
@@ -875,7 +881,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, | |||
875 | struct tcamsg *t; | 881 | struct tcamsg *t; |
876 | struct nlmsghdr *nlh; | 882 | struct nlmsghdr *nlh; |
877 | struct sk_buff *skb; | 883 | struct sk_buff *skb; |
878 | struct nlattr *x; | 884 | struct nlattr *nest; |
879 | unsigned char *b; | 885 | unsigned char *b; |
880 | int err = 0; | 886 | int err = 0; |
881 | 887 | ||
@@ -891,13 +897,14 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, | |||
891 | t->tca__pad1 = 0; | 897 | t->tca__pad1 = 0; |
892 | t->tca__pad2 = 0; | 898 | t->tca__pad2 = 0; |
893 | 899 | ||
894 | x = (struct nlattr *)skb_tail_pointer(skb); | 900 | nest = nla_nest_start(skb, TCA_ACT_TAB); |
895 | NLA_PUT(skb, TCA_ACT_TAB, 0, NULL); | 901 | if (nest == NULL) |
902 | goto nla_put_failure; | ||
896 | 903 | ||
897 | if (tcf_action_dump(skb, a, 0, 0) < 0) | 904 | if (tcf_action_dump(skb, a, 0, 0) < 0) |
898 | goto nla_put_failure; | 905 | goto nla_put_failure; |
899 | 906 | ||
900 | x->nla_len = skb_tail_pointer(skb) - (u8 *)x; | 907 | nla_nest_end(skb, nest); |
901 | 908 | ||
902 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 909 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
903 | NETLINK_CB(skb).dst_group = RTNLGRP_TC; | 910 | NETLINK_CB(skb).dst_group = RTNLGRP_TC; |
@@ -1025,7 +1032,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) | |||
1025 | struct net *net = skb->sk->sk_net; | 1032 | struct net *net = skb->sk->sk_net; |
1026 | struct nlmsghdr *nlh; | 1033 | struct nlmsghdr *nlh; |
1027 | unsigned char *b = skb_tail_pointer(skb); | 1034 | unsigned char *b = skb_tail_pointer(skb); |
1028 | struct nlattr *x; | 1035 | struct nlattr *nest; |
1029 | struct tc_action_ops *a_o; | 1036 | struct tc_action_ops *a_o; |
1030 | struct tc_action a; | 1037 | struct tc_action a; |
1031 | int ret = 0; | 1038 | int ret = 0; |
@@ -1060,18 +1067,19 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) | |||
1060 | t->tca__pad1 = 0; | 1067 | t->tca__pad1 = 0; |
1061 | t->tca__pad2 = 0; | 1068 | t->tca__pad2 = 0; |
1062 | 1069 | ||
1063 | x = (struct nlattr *)skb_tail_pointer(skb); | 1070 | nest = nla_nest_start(skb, TCA_ACT_TAB); |
1064 | NLA_PUT(skb, TCA_ACT_TAB, 0, NULL); | 1071 | if (nest == NULL) |
1072 | goto nla_put_failure; | ||
1065 | 1073 | ||
1066 | ret = a_o->walk(skb, cb, RTM_GETACTION, &a); | 1074 | ret = a_o->walk(skb, cb, RTM_GETACTION, &a); |
1067 | if (ret < 0) | 1075 | if (ret < 0) |
1068 | goto nla_put_failure; | 1076 | goto nla_put_failure; |
1069 | 1077 | ||
1070 | if (ret > 0) { | 1078 | if (ret > 0) { |
1071 | x->nla_len = skb_tail_pointer(skb) - (u8 *)x; | 1079 | nla_nest_end(skb, nest); |
1072 | ret = skb->len; | 1080 | ret = skb->len; |
1073 | } else | 1081 | } else |
1074 | nlmsg_trim(skb, x); | 1082 | nla_nest_cancel(skb, nest); |
1075 | 1083 | ||
1076 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 1084 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1077 | if (NETLINK_CB(cb->skb).pid && ret) | 1085 | if (NETLINK_CB(cb->skb).pid && ret) |
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index c0fce9b98412..ee2f1b64dd70 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 nlattr *r; | 57 | struct nlattr *nest; |
58 | 58 | ||
59 | read_lock_bh(&police_lock); | 59 | read_lock_bh(&police_lock); |
60 | 60 | ||
@@ -69,18 +69,19 @@ 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 nlattr *)skb_tail_pointer(skb); | 72 | nest = nla_nest_start(skb, a->order); |
73 | NLA_PUT(skb, a->order, 0, NULL); | 73 | if (nest == NULL) |
74 | goto nla_put_failure; | ||
74 | if (type == RTM_DELACTION) | 75 | if (type == RTM_DELACTION) |
75 | err = tcf_action_dump_1(skb, a, 0, 1); | 76 | err = tcf_action_dump_1(skb, a, 0, 1); |
76 | else | 77 | else |
77 | err = tcf_action_dump_1(skb, a, 0, 0); | 78 | err = tcf_action_dump_1(skb, a, 0, 0); |
78 | if (err < 0) { | 79 | if (err < 0) { |
79 | index--; | 80 | index--; |
80 | nlmsg_trim(skb, r); | 81 | nla_nest_cancel(skb, nest); |
81 | goto done; | 82 | goto done; |
82 | } | 83 | } |
83 | r->nla_len = skb_tail_pointer(skb) - (u8 *)r; | 84 | nla_nest_end(skb, nest); |
84 | n_i++; | 85 | n_i++; |
85 | } | 86 | } |
86 | } | 87 | } |
@@ -91,7 +92,7 @@ done: | |||
91 | return n_i; | 92 | return n_i; |
92 | 93 | ||
93 | nla_put_failure: | 94 | nla_put_failure: |
94 | nlmsg_trim(skb, r); | 95 | nla_nest_cancel(skb, nest); |
95 | goto done; | 96 | goto done; |
96 | } | 97 | } |
97 | 98 | ||
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 92fa1559c211..5584e7cd4b9f 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -544,18 +544,22 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts, | |||
544 | * to work with both old and new modes of entering | 544 | * to work with both old and new modes of entering |
545 | * tc data even if iproute2 was newer - jhs | 545 | * tc data even if iproute2 was newer - jhs |
546 | */ | 546 | */ |
547 | struct nlattr *p_rta = (struct nlattr *)skb_tail_pointer(skb); | 547 | struct nlattr *nest; |
548 | 548 | ||
549 | if (exts->action->type != TCA_OLD_COMPAT) { | 549 | if (exts->action->type != TCA_OLD_COMPAT) { |
550 | NLA_PUT(skb, map->action, 0, NULL); | 550 | nest = nla_nest_start(skb, map->action); |
551 | if (nest == NULL) | ||
552 | goto nla_put_failure; | ||
551 | if (tcf_action_dump(skb, exts->action, 0, 0) < 0) | 553 | if (tcf_action_dump(skb, exts->action, 0, 0) < 0) |
552 | goto nla_put_failure; | 554 | goto nla_put_failure; |
553 | p_rta->nla_len = skb_tail_pointer(skb) - (u8 *)p_rta; | 555 | nla_nest_end(skb, nest); |
554 | } else if (map->police) { | 556 | } else if (map->police) { |
555 | NLA_PUT(skb, map->police, 0, NULL); | 557 | nest = nla_nest_start(skb, map->police); |
558 | if (nest == NULL) | ||
559 | goto nla_put_failure; | ||
556 | if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0) | 560 | if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0) |
557 | goto nla_put_failure; | 561 | goto nla_put_failure; |
558 | p_rta->nla_len = skb_tail_pointer(skb) - (u8 *)p_rta; | 562 | nla_nest_end(skb, nest); |
559 | } | 563 | } |
560 | } | 564 | } |
561 | #endif | 565 | #endif |
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index 524b7885dc32..6d08b429635e 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c | |||
@@ -246,16 +246,16 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh, | |||
246 | struct sk_buff *skb, struct tcmsg *t) | 246 | struct sk_buff *skb, struct tcmsg *t) |
247 | { | 247 | { |
248 | struct basic_filter *f = (struct basic_filter *) fh; | 248 | struct basic_filter *f = (struct basic_filter *) fh; |
249 | unsigned char *b = skb_tail_pointer(skb); | 249 | struct nlattr *nest; |
250 | struct nlattr *nla; | ||
251 | 250 | ||
252 | if (f == NULL) | 251 | if (f == NULL) |
253 | return skb->len; | 252 | return skb->len; |
254 | 253 | ||
255 | t->tcm_handle = f->handle; | 254 | t->tcm_handle = f->handle; |
256 | 255 | ||
257 | nla = (struct nlattr *) b; | 256 | nest = nla_nest_start(skb, TCA_OPTIONS); |
258 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 257 | if (nest == NULL) |
258 | goto nla_put_failure; | ||
259 | 259 | ||
260 | if (f->res.classid) | 260 | if (f->res.classid) |
261 | NLA_PUT(skb, TCA_BASIC_CLASSID, sizeof(u32), &f->res.classid); | 261 | NLA_PUT(skb, TCA_BASIC_CLASSID, sizeof(u32), &f->res.classid); |
@@ -264,11 +264,11 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh, | |||
264 | tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0) | 264 | tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0) |
265 | goto nla_put_failure; | 265 | goto nla_put_failure; |
266 | 266 | ||
267 | nla->nla_len = skb_tail_pointer(skb) - b; | 267 | nla_nest_end(skb, nest); |
268 | return skb->len; | 268 | return skb->len; |
269 | 269 | ||
270 | nla_put_failure: | 270 | nla_put_failure: |
271 | nlmsg_trim(skb, b); | 271 | nla_nest_cancel(skb, nest); |
272 | return -1; | 272 | return -1; |
273 | } | 273 | } |
274 | 274 | ||
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index a1a9f4d26b8c..e3dfbb3046c0 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c | |||
@@ -334,7 +334,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh, | |||
334 | struct fw_head *head = (struct fw_head *)tp->root; | 334 | struct fw_head *head = (struct fw_head *)tp->root; |
335 | struct fw_filter *f = (struct fw_filter*)fh; | 335 | struct fw_filter *f = (struct fw_filter*)fh; |
336 | unsigned char *b = skb_tail_pointer(skb); | 336 | unsigned char *b = skb_tail_pointer(skb); |
337 | struct nlattr *nla; | 337 | struct nlattr *nest; |
338 | 338 | ||
339 | if (f == NULL) | 339 | if (f == NULL) |
340 | return skb->len; | 340 | return skb->len; |
@@ -344,8 +344,9 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh, | |||
344 | if (!f->res.classid && !tcf_exts_is_available(&f->exts)) | 344 | if (!f->res.classid && !tcf_exts_is_available(&f->exts)) |
345 | return skb->len; | 345 | return skb->len; |
346 | 346 | ||
347 | nla = (struct nlattr*)b; | 347 | nest = nla_nest_start(skb, TCA_OPTIONS); |
348 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 348 | if (nest == NULL) |
349 | goto nla_put_failure; | ||
349 | 350 | ||
350 | if (f->res.classid) | 351 | if (f->res.classid) |
351 | NLA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid); | 352 | NLA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid); |
@@ -359,7 +360,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh, | |||
359 | if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0) | 360 | if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0) |
360 | goto nla_put_failure; | 361 | goto nla_put_failure; |
361 | 362 | ||
362 | nla->nla_len = skb_tail_pointer(skb) - b; | 363 | nla_nest_end(skb, nest); |
363 | 364 | ||
364 | if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0) | 365 | if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0) |
365 | goto nla_put_failure; | 366 | goto nla_put_failure; |
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index 3aa8109aa3ce..1ce1f3623d65 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c | |||
@@ -551,7 +551,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, | |||
551 | { | 551 | { |
552 | struct route4_filter *f = (struct route4_filter*)fh; | 552 | struct route4_filter *f = (struct route4_filter*)fh; |
553 | unsigned char *b = skb_tail_pointer(skb); | 553 | unsigned char *b = skb_tail_pointer(skb); |
554 | struct nlattr *nla; | 554 | struct nlattr *nest; |
555 | u32 id; | 555 | u32 id; |
556 | 556 | ||
557 | if (f == NULL) | 557 | if (f == NULL) |
@@ -559,8 +559,9 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, | |||
559 | 559 | ||
560 | t->tcm_handle = f->handle; | 560 | t->tcm_handle = f->handle; |
561 | 561 | ||
562 | nla = (struct nlattr*)b; | 562 | nest = nla_nest_start(skb, TCA_OPTIONS); |
563 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 563 | if (nest == NULL) |
564 | goto nla_put_failure; | ||
564 | 565 | ||
565 | if (!(f->handle&0x8000)) { | 566 | if (!(f->handle&0x8000)) { |
566 | id = f->id&0xFF; | 567 | id = f->id&0xFF; |
@@ -579,7 +580,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, | |||
579 | if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0) | 580 | if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0) |
580 | goto nla_put_failure; | 581 | goto nla_put_failure; |
581 | 582 | ||
582 | nla->nla_len = skb_tail_pointer(skb) - b; | 583 | nla_nest_end(skb, nest); |
583 | 584 | ||
584 | if (tcf_exts_dump_stats(skb, &f->exts, &route_ext_map) < 0) | 585 | if (tcf_exts_dump_stats(skb, &f->exts, &route_ext_map) < 0) |
585 | goto nla_put_failure; | 586 | goto nla_put_failure; |
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index 5747408a7d4c..77097e023f77 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h | |||
@@ -595,7 +595,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, | |||
595 | struct rsvp_filter *f = (struct rsvp_filter*)fh; | 595 | struct rsvp_filter *f = (struct rsvp_filter*)fh; |
596 | struct rsvp_session *s; | 596 | struct rsvp_session *s; |
597 | unsigned char *b = skb_tail_pointer(skb); | 597 | unsigned char *b = skb_tail_pointer(skb); |
598 | struct nlattr *nla; | 598 | struct nlattr *nest; |
599 | struct tc_rsvp_pinfo pinfo; | 599 | struct tc_rsvp_pinfo pinfo; |
600 | 600 | ||
601 | if (f == NULL) | 601 | if (f == NULL) |
@@ -604,9 +604,9 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, | |||
604 | 604 | ||
605 | t->tcm_handle = f->handle; | 605 | t->tcm_handle = f->handle; |
606 | 606 | ||
607 | 607 | nest = nla_nest_start(skb, TCA_OPTIONS); | |
608 | nla = (struct nlattr*)b; | 608 | if (nest == NULL) |
609 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 609 | goto nla_put_failure; |
610 | 610 | ||
611 | NLA_PUT(skb, TCA_RSVP_DST, sizeof(s->dst), &s->dst); | 611 | NLA_PUT(skb, TCA_RSVP_DST, sizeof(s->dst), &s->dst); |
612 | pinfo.dpi = s->dpi; | 612 | pinfo.dpi = s->dpi; |
@@ -624,7 +624,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, | |||
624 | if (tcf_exts_dump(skb, &f->exts, &rsvp_ext_map) < 0) | 624 | if (tcf_exts_dump(skb, &f->exts, &rsvp_ext_map) < 0) |
625 | goto nla_put_failure; | 625 | goto nla_put_failure; |
626 | 626 | ||
627 | nla->nla_len = skb_tail_pointer(skb) - b; | 627 | nla_nest_end(skb, nest); |
628 | 628 | ||
629 | if (tcf_exts_dump_stats(skb, &f->exts, &rsvp_ext_map) < 0) | 629 | if (tcf_exts_dump_stats(skb, &f->exts, &rsvp_ext_map) < 0) |
630 | goto nla_put_failure; | 630 | goto nla_put_failure; |
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index 6b84d276e5ac..cd350d38bdaf 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c | |||
@@ -437,13 +437,16 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, | |||
437 | struct tcindex_data *p = PRIV(tp); | 437 | struct tcindex_data *p = PRIV(tp); |
438 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; | 438 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; |
439 | unsigned char *b = skb_tail_pointer(skb); | 439 | unsigned char *b = skb_tail_pointer(skb); |
440 | struct nlattr *nla; | 440 | struct nlattr *nest; |
441 | 441 | ||
442 | pr_debug("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n", | 442 | pr_debug("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n", |
443 | tp, fh, skb, t, p, r, b); | 443 | tp, fh, skb, t, p, r, b); |
444 | pr_debug("p->perfect %p p->h %p\n", p->perfect, p->h); | 444 | pr_debug("p->perfect %p p->h %p\n", p->perfect, p->h); |
445 | nla = (struct nlattr *) b; | 445 | |
446 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 446 | nest = nla_nest_start(skb, TCA_OPTIONS); |
447 | if (nest == NULL) | ||
448 | goto nla_put_failure; | ||
449 | |||
447 | if (!fh) { | 450 | if (!fh) { |
448 | t->tcm_handle = ~0; /* whatever ... */ | 451 | t->tcm_handle = ~0; /* whatever ... */ |
449 | NLA_PUT(skb, TCA_TCINDEX_HASH, sizeof(p->hash), &p->hash); | 452 | NLA_PUT(skb, TCA_TCINDEX_HASH, sizeof(p->hash), &p->hash); |
@@ -451,7 +454,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, | |||
451 | NLA_PUT(skb, TCA_TCINDEX_SHIFT, sizeof(p->shift), &p->shift); | 454 | NLA_PUT(skb, TCA_TCINDEX_SHIFT, sizeof(p->shift), &p->shift); |
452 | NLA_PUT(skb, TCA_TCINDEX_FALL_THROUGH, sizeof(p->fall_through), | 455 | NLA_PUT(skb, TCA_TCINDEX_FALL_THROUGH, sizeof(p->fall_through), |
453 | &p->fall_through); | 456 | &p->fall_through); |
454 | nla->nla_len = skb_tail_pointer(skb) - b; | 457 | nla_nest_end(skb, nest); |
455 | } else { | 458 | } else { |
456 | if (p->perfect) { | 459 | if (p->perfect) { |
457 | t->tcm_handle = r-p->perfect; | 460 | t->tcm_handle = r-p->perfect; |
@@ -474,7 +477,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, | |||
474 | 477 | ||
475 | if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) | 478 | if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) |
476 | goto nla_put_failure; | 479 | goto nla_put_failure; |
477 | nla->nla_len = skb_tail_pointer(skb) - b; | 480 | nla_nest_end(skb, nest); |
478 | 481 | ||
479 | if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0) | 482 | if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0) |
480 | goto nla_put_failure; | 483 | goto nla_put_failure; |
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 3228cc4ae082..b51c2c324abc 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -694,16 +694,16 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, | |||
694 | struct sk_buff *skb, struct tcmsg *t) | 694 | struct sk_buff *skb, struct tcmsg *t) |
695 | { | 695 | { |
696 | struct tc_u_knode *n = (struct tc_u_knode*)fh; | 696 | struct tc_u_knode *n = (struct tc_u_knode*)fh; |
697 | unsigned char *b = skb_tail_pointer(skb); | 697 | struct nlattr *nest; |
698 | struct nlattr *nla; | ||
699 | 698 | ||
700 | if (n == NULL) | 699 | if (n == NULL) |
701 | return skb->len; | 700 | return skb->len; |
702 | 701 | ||
703 | t->tcm_handle = n->handle; | 702 | t->tcm_handle = n->handle; |
704 | 703 | ||
705 | nla = (struct nlattr*)b; | 704 | nest = nla_nest_start(skb, TCA_OPTIONS); |
706 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 705 | if (nest == NULL) |
706 | goto nla_put_failure; | ||
707 | 707 | ||
708 | if (TC_U32_KEY(n->handle) == 0) { | 708 | if (TC_U32_KEY(n->handle) == 0) { |
709 | struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; | 709 | struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; |
@@ -741,14 +741,15 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, | |||
741 | #endif | 741 | #endif |
742 | } | 742 | } |
743 | 743 | ||
744 | nla->nla_len = skb_tail_pointer(skb) - b; | 744 | nla_nest_end(skb, nest); |
745 | |||
745 | if (TC_U32_KEY(n->handle)) | 746 | if (TC_U32_KEY(n->handle)) |
746 | if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) | 747 | if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) |
747 | goto nla_put_failure; | 748 | goto nla_put_failure; |
748 | return skb->len; | 749 | return skb->len; |
749 | 750 | ||
750 | nla_put_failure: | 751 | nla_put_failure: |
751 | nlmsg_trim(skb, b); | 752 | nla_nest_cancel(skb, nest); |
752 | return -1; | 753 | return -1; |
753 | } | 754 | } |
754 | 755 | ||
diff --git a/net/sched/ematch.c b/net/sched/ematch.c index d2b480f01a40..daa9c4e7e81d 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c | |||
@@ -436,14 +436,18 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) | |||
436 | { | 436 | { |
437 | int i; | 437 | int i; |
438 | u8 *tail; | 438 | u8 *tail; |
439 | struct nlattr *top_start = (struct nlattr *)skb_tail_pointer(skb); | 439 | struct nlattr *top_start; |
440 | struct nlattr *list_start; | 440 | struct nlattr *list_start; |
441 | 441 | ||
442 | NLA_PUT(skb, tlv, 0, NULL); | 442 | top_start = nla_nest_start(skb, tlv); |
443 | if (top_start == NULL) | ||
444 | goto nla_put_failure; | ||
445 | |||
443 | NLA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr); | 446 | NLA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr); |
444 | 447 | ||
445 | list_start = (struct nlattr *)skb_tail_pointer(skb); | 448 | list_start = nla_nest_start(skb, TCA_EMATCH_TREE_LIST); |
446 | NLA_PUT(skb, TCA_EMATCH_TREE_LIST, 0, NULL); | 449 | if (list_start == NULL) |
450 | goto nla_put_failure; | ||
447 | 451 | ||
448 | tail = skb_tail_pointer(skb); | 452 | tail = skb_tail_pointer(skb); |
449 | for (i = 0; i < tree->hdr.nmatches; i++) { | 453 | for (i = 0; i < tree->hdr.nmatches; i++) { |
@@ -470,8 +474,8 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) | |||
470 | match_start->nla_len = tail - (u8 *)match_start; | 474 | match_start->nla_len = tail - (u8 *)match_start; |
471 | } | 475 | } |
472 | 476 | ||
473 | list_start->nla_len = tail - (u8 *)list_start; | 477 | nla_nest_end(skb, list_start); |
474 | top_start->nla_len = tail - (u8 *)top_start; | 478 | nla_nest_end(skb, top_start); |
475 | 479 | ||
476 | return 0; | 480 | return 0; |
477 | 481 | ||
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index aaa32a22726d..19c00074ba1f 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c | |||
@@ -605,8 +605,7 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl, | |||
605 | { | 605 | { |
606 | struct atm_qdisc_data *p = qdisc_priv(sch); | 606 | struct atm_qdisc_data *p = qdisc_priv(sch); |
607 | struct atm_flow_data *flow = (struct atm_flow_data *)cl; | 607 | struct atm_flow_data *flow = (struct atm_flow_data *)cl; |
608 | unsigned char *b = skb_tail_pointer(skb); | 608 | struct nlattr *nest; |
609 | struct nlattr *nla; | ||
610 | 609 | ||
611 | pr_debug("atm_tc_dump_class(sch %p,[qdisc %p],flow %p,skb %p,tcm %p)\n", | 610 | pr_debug("atm_tc_dump_class(sch %p,[qdisc %p],flow %p,skb %p,tcm %p)\n", |
612 | sch, p, flow, skb, tcm); | 611 | sch, p, flow, skb, tcm); |
@@ -614,8 +613,11 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl, | |||
614 | return -EINVAL; | 613 | return -EINVAL; |
615 | tcm->tcm_handle = flow->classid; | 614 | tcm->tcm_handle = flow->classid; |
616 | tcm->tcm_info = flow->q->handle; | 615 | tcm->tcm_info = flow->q->handle; |
617 | nla = (struct nlattr *)b; | 616 | |
618 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 617 | nest = nla_nest_start(skb, TCA_OPTIONS); |
618 | if (nest == NULL) | ||
619 | goto nla_put_failure; | ||
620 | |||
619 | NLA_PUT(skb, TCA_ATM_HDR, flow->hdr_len, flow->hdr); | 621 | NLA_PUT(skb, TCA_ATM_HDR, flow->hdr_len, flow->hdr); |
620 | if (flow->vcc) { | 622 | if (flow->vcc) { |
621 | struct sockaddr_atmpvc pvc; | 623 | struct sockaddr_atmpvc pvc; |
@@ -636,11 +638,12 @@ static int atm_tc_dump_class(struct Qdisc *sch, unsigned long cl, | |||
636 | 638 | ||
637 | NLA_PUT(skb, TCA_ATM_EXCESS, sizeof(zero), &zero); | 639 | NLA_PUT(skb, TCA_ATM_EXCESS, sizeof(zero), &zero); |
638 | } | 640 | } |
639 | nla->nla_len = skb_tail_pointer(skb) - b; | 641 | |
642 | nla_nest_end(skb, nest); | ||
640 | return skb->len; | 643 | return skb->len; |
641 | 644 | ||
642 | nla_put_failure: | 645 | nla_put_failure: |
643 | nlmsg_trim(skb, b); | 646 | nla_nest_cancel(skb, nest); |
644 | return -1; | 647 | return -1; |
645 | } | 648 | } |
646 | static int | 649 | static int |
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 585f8a6ec7ec..da0f6c0152de 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c | |||
@@ -1565,18 +1565,18 @@ static int cbq_dump_attr(struct sk_buff *skb, struct cbq_class *cl) | |||
1565 | static int cbq_dump(struct Qdisc *sch, struct sk_buff *skb) | 1565 | static int cbq_dump(struct Qdisc *sch, struct sk_buff *skb) |
1566 | { | 1566 | { |
1567 | struct cbq_sched_data *q = qdisc_priv(sch); | 1567 | struct cbq_sched_data *q = qdisc_priv(sch); |
1568 | unsigned char *b = skb_tail_pointer(skb); | 1568 | struct nlattr *nest; |
1569 | struct nlattr *nla; | ||
1570 | 1569 | ||
1571 | nla = (struct nlattr*)b; | 1570 | nest = nla_nest_start(skb, TCA_OPTIONS); |
1572 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 1571 | if (nest == NULL) |
1572 | goto nla_put_failure; | ||
1573 | if (cbq_dump_attr(skb, &q->link) < 0) | 1573 | if (cbq_dump_attr(skb, &q->link) < 0) |
1574 | goto nla_put_failure; | 1574 | goto nla_put_failure; |
1575 | nla->nla_len = skb_tail_pointer(skb) - b; | 1575 | nla_nest_end(skb, nest); |
1576 | return skb->len; | 1576 | return skb->len; |
1577 | 1577 | ||
1578 | nla_put_failure: | 1578 | nla_put_failure: |
1579 | nlmsg_trim(skb, b); | 1579 | nla_nest_cancel(skb, nest); |
1580 | return -1; | 1580 | return -1; |
1581 | } | 1581 | } |
1582 | 1582 | ||
@@ -1594,8 +1594,7 @@ cbq_dump_class(struct Qdisc *sch, unsigned long arg, | |||
1594 | struct sk_buff *skb, struct tcmsg *tcm) | 1594 | struct sk_buff *skb, struct tcmsg *tcm) |
1595 | { | 1595 | { |
1596 | struct cbq_class *cl = (struct cbq_class*)arg; | 1596 | struct cbq_class *cl = (struct cbq_class*)arg; |
1597 | unsigned char *b = skb_tail_pointer(skb); | 1597 | struct nlattr *nest; |
1598 | struct nlattr *nla; | ||
1599 | 1598 | ||
1600 | if (cl->tparent) | 1599 | if (cl->tparent) |
1601 | tcm->tcm_parent = cl->tparent->classid; | 1600 | tcm->tcm_parent = cl->tparent->classid; |
@@ -1604,15 +1603,16 @@ cbq_dump_class(struct Qdisc *sch, unsigned long arg, | |||
1604 | tcm->tcm_handle = cl->classid; | 1603 | tcm->tcm_handle = cl->classid; |
1605 | tcm->tcm_info = cl->q->handle; | 1604 | tcm->tcm_info = cl->q->handle; |
1606 | 1605 | ||
1607 | nla = (struct nlattr*)b; | 1606 | nest = nla_nest_start(skb, TCA_OPTIONS); |
1608 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 1607 | if (nest == NULL) |
1608 | goto nla_put_failure; | ||
1609 | if (cbq_dump_attr(skb, cl) < 0) | 1609 | if (cbq_dump_attr(skb, cl) < 0) |
1610 | goto nla_put_failure; | 1610 | goto nla_put_failure; |
1611 | nla->nla_len = skb_tail_pointer(skb) - b; | 1611 | nla_nest_end(skb, nest); |
1612 | return skb->len; | 1612 | return skb->len; |
1613 | 1613 | ||
1614 | nla_put_failure: | 1614 | nla_put_failure: |
1615 | nlmsg_trim(skb, b); | 1615 | nla_nest_cancel(skb, nest); |
1616 | return -1; | 1616 | return -1; |
1617 | } | 1617 | } |
1618 | 1618 | ||
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index fcb4826158d6..10a2f35a27a8 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c | |||
@@ -1343,22 +1343,23 @@ hfsc_dump_class(struct Qdisc *sch, unsigned long arg, struct sk_buff *skb, | |||
1343 | struct tcmsg *tcm) | 1343 | struct tcmsg *tcm) |
1344 | { | 1344 | { |
1345 | struct hfsc_class *cl = (struct hfsc_class *)arg; | 1345 | struct hfsc_class *cl = (struct hfsc_class *)arg; |
1346 | unsigned char *b = skb_tail_pointer(skb); | 1346 | struct nlattr *nest; |
1347 | struct nlattr *nla = (struct nlattr *)b; | ||
1348 | 1347 | ||
1349 | tcm->tcm_parent = cl->cl_parent ? cl->cl_parent->classid : TC_H_ROOT; | 1348 | tcm->tcm_parent = cl->cl_parent ? cl->cl_parent->classid : TC_H_ROOT; |
1350 | tcm->tcm_handle = cl->classid; | 1349 | tcm->tcm_handle = cl->classid; |
1351 | if (cl->level == 0) | 1350 | if (cl->level == 0) |
1352 | tcm->tcm_info = cl->qdisc->handle; | 1351 | tcm->tcm_info = cl->qdisc->handle; |
1353 | 1352 | ||
1354 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 1353 | nest = nla_nest_start(skb, TCA_OPTIONS); |
1354 | if (nest == NULL) | ||
1355 | goto nla_put_failure; | ||
1355 | if (hfsc_dump_curves(skb, cl) < 0) | 1356 | if (hfsc_dump_curves(skb, cl) < 0) |
1356 | goto nla_put_failure; | 1357 | goto nla_put_failure; |
1357 | nla->nla_len = skb_tail_pointer(skb) - b; | 1358 | nla_nest_end(skb, nest); |
1358 | return skb->len; | 1359 | return skb->len; |
1359 | 1360 | ||
1360 | nla_put_failure: | 1361 | nla_put_failure: |
1361 | nlmsg_trim(skb, b); | 1362 | nla_nest_cancel(skb, nest); |
1362 | return -1; | 1363 | return -1; |
1363 | } | 1364 | } |
1364 | 1365 | ||
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 512df9a0a242..69fac320f8bc 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -1043,25 +1043,29 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt) | |||
1043 | static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) | 1043 | static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) |
1044 | { | 1044 | { |
1045 | struct htb_sched *q = qdisc_priv(sch); | 1045 | struct htb_sched *q = qdisc_priv(sch); |
1046 | unsigned char *b = skb_tail_pointer(skb); | 1046 | struct nlattr *nest; |
1047 | struct nlattr *nla; | ||
1048 | struct tc_htb_glob gopt; | 1047 | struct tc_htb_glob gopt; |
1048 | |||
1049 | spin_lock_bh(&sch->dev->queue_lock); | 1049 | spin_lock_bh(&sch->dev->queue_lock); |
1050 | gopt.direct_pkts = q->direct_pkts; | ||
1051 | 1050 | ||
1051 | gopt.direct_pkts = q->direct_pkts; | ||
1052 | gopt.version = HTB_VER; | 1052 | gopt.version = HTB_VER; |
1053 | gopt.rate2quantum = q->rate2quantum; | 1053 | gopt.rate2quantum = q->rate2quantum; |
1054 | gopt.defcls = q->defcls; | 1054 | gopt.defcls = q->defcls; |
1055 | gopt.debug = 0; | 1055 | gopt.debug = 0; |
1056 | nla = (struct nlattr *)b; | 1056 | |
1057 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 1057 | nest = nla_nest_start(skb, TCA_OPTIONS); |
1058 | if (nest == NULL) | ||
1059 | goto nla_put_failure; | ||
1058 | NLA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt); | 1060 | NLA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt); |
1059 | nla->nla_len = skb_tail_pointer(skb) - b; | 1061 | nla_nest_end(skb, nest); |
1062 | |||
1060 | spin_unlock_bh(&sch->dev->queue_lock); | 1063 | spin_unlock_bh(&sch->dev->queue_lock); |
1061 | return skb->len; | 1064 | return skb->len; |
1065 | |||
1062 | nla_put_failure: | 1066 | nla_put_failure: |
1063 | spin_unlock_bh(&sch->dev->queue_lock); | 1067 | spin_unlock_bh(&sch->dev->queue_lock); |
1064 | nlmsg_trim(skb, skb_tail_pointer(skb)); | 1068 | nla_nest_cancel(skb, nest); |
1065 | return -1; | 1069 | return -1; |
1066 | } | 1070 | } |
1067 | 1071 | ||
@@ -1069,8 +1073,7 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, | |||
1069 | struct sk_buff *skb, struct tcmsg *tcm) | 1073 | struct sk_buff *skb, struct tcmsg *tcm) |
1070 | { | 1074 | { |
1071 | struct htb_class *cl = (struct htb_class *)arg; | 1075 | struct htb_class *cl = (struct htb_class *)arg; |
1072 | unsigned char *b = skb_tail_pointer(skb); | 1076 | struct nlattr *nest; |
1073 | struct nlattr *nla; | ||
1074 | struct tc_htb_opt opt; | 1077 | struct tc_htb_opt opt; |
1075 | 1078 | ||
1076 | spin_lock_bh(&sch->dev->queue_lock); | 1079 | spin_lock_bh(&sch->dev->queue_lock); |
@@ -1079,8 +1082,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, | |||
1079 | if (!cl->level && cl->un.leaf.q) | 1082 | if (!cl->level && cl->un.leaf.q) |
1080 | tcm->tcm_info = cl->un.leaf.q->handle; | 1083 | tcm->tcm_info = cl->un.leaf.q->handle; |
1081 | 1084 | ||
1082 | nla = (struct nlattr *)b; | 1085 | nest = nla_nest_start(skb, TCA_OPTIONS); |
1083 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 1086 | if (nest == NULL) |
1087 | goto nla_put_failure; | ||
1084 | 1088 | ||
1085 | memset(&opt, 0, sizeof(opt)); | 1089 | memset(&opt, 0, sizeof(opt)); |
1086 | 1090 | ||
@@ -1092,12 +1096,14 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, | |||
1092 | opt.prio = cl->un.leaf.prio; | 1096 | opt.prio = cl->un.leaf.prio; |
1093 | opt.level = cl->level; | 1097 | opt.level = cl->level; |
1094 | NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); | 1098 | NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); |
1095 | nla->nla_len = skb_tail_pointer(skb) - b; | 1099 | |
1100 | nla_nest_end(skb, nest); | ||
1096 | spin_unlock_bh(&sch->dev->queue_lock); | 1101 | spin_unlock_bh(&sch->dev->queue_lock); |
1097 | return skb->len; | 1102 | return skb->len; |
1103 | |||
1098 | nla_put_failure: | 1104 | nla_put_failure: |
1099 | spin_unlock_bh(&sch->dev->queue_lock); | 1105 | spin_unlock_bh(&sch->dev->queue_lock); |
1100 | nlmsg_trim(skb, b); | 1106 | nla_nest_cancel(skb, nest); |
1101 | return -1; | 1107 | return -1; |
1102 | } | 1108 | } |
1103 | 1109 | ||
diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c index f6decbb56645..3f72d528273c 100644 --- a/net/sched/sch_ingress.c +++ b/net/sched/sch_ingress.c | |||
@@ -183,16 +183,16 @@ static void ingress_destroy(struct Qdisc *sch) | |||
183 | 183 | ||
184 | static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) | 184 | static int ingress_dump(struct Qdisc *sch, struct sk_buff *skb) |
185 | { | 185 | { |
186 | unsigned char *b = skb_tail_pointer(skb); | 186 | struct nlattr *nest; |
187 | struct nlattr *nla; | ||
188 | 187 | ||
189 | nla = (struct nlattr *)b; | 188 | nest = nla_nest_start(skb, TCA_OPTIONS); |
190 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 189 | if (nest == NULL) |
191 | nla->nla_len = skb_tail_pointer(skb) - b; | 190 | goto nla_put_failure; |
191 | nla_nest_end(skb, nest); | ||
192 | return skb->len; | 192 | return skb->len; |
193 | 193 | ||
194 | nla_put_failure: | 194 | nla_put_failure: |
195 | nlmsg_trim(skb, b); | 195 | nla_nest_cancel(skb, nest); |
196 | return -1; | 196 | return -1; |
197 | } | 197 | } |
198 | 198 | ||
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index f9b1543e3d76..b7a185dc3def 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c | |||
@@ -375,12 +375,12 @@ static void tbf_destroy(struct Qdisc *sch) | |||
375 | static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb) | 375 | static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb) |
376 | { | 376 | { |
377 | struct tbf_sched_data *q = qdisc_priv(sch); | 377 | struct tbf_sched_data *q = qdisc_priv(sch); |
378 | unsigned char *b = skb_tail_pointer(skb); | 378 | struct nlattr *nest; |
379 | struct nlattr *nla; | ||
380 | struct tc_tbf_qopt opt; | 379 | struct tc_tbf_qopt opt; |
381 | 380 | ||
382 | nla = (struct nlattr*)b; | 381 | nest = nla_nest_start(skb, TCA_OPTIONS); |
383 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); | 382 | if (nest == NULL) |
383 | goto nla_put_failure; | ||
384 | 384 | ||
385 | opt.limit = q->limit; | 385 | opt.limit = q->limit; |
386 | opt.rate = q->R_tab->rate; | 386 | opt.rate = q->R_tab->rate; |
@@ -391,12 +391,12 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
391 | opt.mtu = q->mtu; | 391 | opt.mtu = q->mtu; |
392 | opt.buffer = q->buffer; | 392 | opt.buffer = q->buffer; |
393 | NLA_PUT(skb, TCA_TBF_PARMS, sizeof(opt), &opt); | 393 | NLA_PUT(skb, TCA_TBF_PARMS, sizeof(opt), &opt); |
394 | nla->nla_len = skb_tail_pointer(skb) - b; | ||
395 | 394 | ||
395 | nla_nest_end(skb, nest); | ||
396 | return skb->len; | 396 | return skb->len; |
397 | 397 | ||
398 | nla_put_failure: | 398 | nla_put_failure: |
399 | nlmsg_trim(skb, b); | 399 | nla_nest_cancel(skb, nest); |
400 | return -1; | 400 | return -1; |
401 | } | 401 | } |
402 | 402 | ||