diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-23 01:11:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:11:11 -0500 |
commit | add93b610a4e66d36d0cf0b2596c3d3bcfdaee39 (patch) | |
tree | 073873879eb3b87981ee015f0f1ca48da8f1c696 | |
parent | 1e90474c377e92db7262a8968a45c1dd980ca9e5 (diff) |
[NET_SCHED]: Convert classifiers from rtnetlink to new netlink API
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/pkt_cls.h | 10 | ||||
-rw-r--r-- | include/net/sch_generic.h | 2 | ||||
-rw-r--r-- | net/sched/cls_api.c | 65 | ||||
-rw-r--r-- | net/sched/cls_basic.c | 40 | ||||
-rw-r--r-- | net/sched/cls_fw.c | 54 | ||||
-rw-r--r-- | net/sched/cls_route.c | 70 | ||||
-rw-r--r-- | net/sched/cls_rsvp.h | 48 | ||||
-rw-r--r-- | net/sched/cls_tcindex.c | 66 | ||||
-rw-r--r-- | net/sched/cls_u32.c | 78 | ||||
-rw-r--r-- | net/sched/em_meta.c | 56 | ||||
-rw-r--r-- | net/sched/em_text.c | 9 | ||||
-rw-r--r-- | net/sched/ematch.c | 74 |
12 files changed, 290 insertions, 282 deletions
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 2eaf20480024..8716eb757d51 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h | |||
@@ -129,8 +129,8 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts, | |||
129 | return 0; | 129 | return 0; |
130 | } | 130 | } |
131 | 131 | ||
132 | extern int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, | 132 | extern int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb, |
133 | struct rtattr *rate_tlv, struct tcf_exts *exts, | 133 | struct nlattr *rate_tlv, struct tcf_exts *exts, |
134 | struct tcf_ext_map *map); | 134 | struct tcf_ext_map *map); |
135 | extern void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts); | 135 | extern void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts); |
136 | extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst, | 136 | extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst, |
@@ -247,7 +247,7 @@ struct tcf_ematch_ops | |||
247 | 247 | ||
248 | extern int tcf_em_register(struct tcf_ematch_ops *); | 248 | extern int tcf_em_register(struct tcf_ematch_ops *); |
249 | extern int tcf_em_unregister(struct tcf_ematch_ops *); | 249 | extern int tcf_em_unregister(struct tcf_ematch_ops *); |
250 | extern int tcf_em_tree_validate(struct tcf_proto *, struct rtattr *, | 250 | extern int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *, |
251 | struct tcf_ematch_tree *); | 251 | struct tcf_ematch_tree *); |
252 | extern void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *); | 252 | extern void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *); |
253 | extern int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int); | 253 | extern int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int); |
@@ -338,9 +338,9 @@ static inline int tcf_valid_offset(const struct sk_buff *skb, | |||
338 | #include <net/net_namespace.h> | 338 | #include <net/net_namespace.h> |
339 | 339 | ||
340 | static inline int | 340 | static inline int |
341 | tcf_change_indev(struct tcf_proto *tp, char *indev, struct rtattr *indev_tlv) | 341 | tcf_change_indev(struct tcf_proto *tp, char *indev, struct nlattr *indev_tlv) |
342 | { | 342 | { |
343 | if (rtattr_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) | 343 | if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) |
344 | return -EINVAL; | 344 | return -EINVAL; |
345 | return 0; | 345 | return 0; |
346 | } | 346 | } |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 8cacdff24594..ab502ec1c61c 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -126,7 +126,7 @@ struct tcf_proto_ops | |||
126 | unsigned long (*get)(struct tcf_proto*, u32 handle); | 126 | unsigned long (*get)(struct tcf_proto*, u32 handle); |
127 | void (*put)(struct tcf_proto*, unsigned long); | 127 | void (*put)(struct tcf_proto*, unsigned long); |
128 | int (*change)(struct tcf_proto*, unsigned long, | 128 | int (*change)(struct tcf_proto*, unsigned long, |
129 | u32 handle, struct rtattr **, | 129 | u32 handle, struct nlattr **, |
130 | unsigned long *); | 130 | unsigned long *); |
131 | int (*delete)(struct tcf_proto*, unsigned long); | 131 | int (*delete)(struct tcf_proto*, unsigned long); |
132 | void (*walk)(struct tcf_proto*, struct tcf_walker *arg); | 132 | void (*walk)(struct tcf_proto*, struct tcf_walker *arg); |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 9eeb3c6c82f4..87be2b2fc29a 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -38,14 +38,14 @@ static DEFINE_RWLOCK(cls_mod_lock); | |||
38 | 38 | ||
39 | /* Find classifier type by string name */ | 39 | /* Find classifier type by string name */ |
40 | 40 | ||
41 | static struct tcf_proto_ops *tcf_proto_lookup_ops(struct rtattr *kind) | 41 | static struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind) |
42 | { | 42 | { |
43 | struct tcf_proto_ops *t = NULL; | 43 | struct tcf_proto_ops *t = NULL; |
44 | 44 | ||
45 | if (kind) { | 45 | if (kind) { |
46 | read_lock(&cls_mod_lock); | 46 | read_lock(&cls_mod_lock); |
47 | for (t = tcf_proto_base; t; t = t->next) { | 47 | for (t = tcf_proto_base; t; t = t->next) { |
48 | if (rtattr_strcmp(kind, t->kind) == 0) { | 48 | if (nla_strcmp(kind, t->kind) == 0) { |
49 | if (!try_module_get(t->owner)) | 49 | if (!try_module_get(t->owner)) |
50 | t = NULL; | 50 | t = NULL; |
51 | break; | 51 | break; |
@@ -118,7 +118,7 @@ static inline u32 tcf_auto_prio(struct tcf_proto *tp) | |||
118 | static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | 118 | static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg) |
119 | { | 119 | { |
120 | struct net *net = skb->sk->sk_net; | 120 | struct net *net = skb->sk->sk_net; |
121 | struct rtattr **tca; | 121 | struct nlattr *tca[TCA_MAX + 1]; |
122 | struct tcmsg *t; | 122 | struct tcmsg *t; |
123 | u32 protocol; | 123 | u32 protocol; |
124 | u32 prio; | 124 | u32 prio; |
@@ -138,7 +138,6 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
138 | return -EINVAL; | 138 | return -EINVAL; |
139 | 139 | ||
140 | replay: | 140 | replay: |
141 | tca = arg; | ||
142 | t = NLMSG_DATA(n); | 141 | t = NLMSG_DATA(n); |
143 | protocol = TC_H_MIN(t->tcm_info); | 142 | protocol = TC_H_MIN(t->tcm_info); |
144 | prio = TC_H_MAJ(t->tcm_info); | 143 | prio = TC_H_MAJ(t->tcm_info); |
@@ -160,6 +159,10 @@ replay: | |||
160 | if (dev == NULL) | 159 | if (dev == NULL) |
161 | return -ENODEV; | 160 | return -ENODEV; |
162 | 161 | ||
162 | err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL); | ||
163 | if (err < 0) | ||
164 | return err; | ||
165 | |||
163 | /* Find qdisc */ | 166 | /* Find qdisc */ |
164 | if (!parent) { | 167 | if (!parent) { |
165 | q = dev->qdisc_sleeping; | 168 | q = dev->qdisc_sleeping; |
@@ -202,7 +205,7 @@ replay: | |||
202 | if (tp == NULL) { | 205 | if (tp == NULL) { |
203 | /* Proto-tcf does not exist, create new one */ | 206 | /* Proto-tcf does not exist, create new one */ |
204 | 207 | ||
205 | if (tca[TCA_KIND-1] == NULL || !protocol) | 208 | if (tca[TCA_KIND] == NULL || !protocol) |
206 | goto errout; | 209 | goto errout; |
207 | 210 | ||
208 | err = -ENOENT; | 211 | err = -ENOENT; |
@@ -217,14 +220,14 @@ replay: | |||
217 | if (tp == NULL) | 220 | if (tp == NULL) |
218 | goto errout; | 221 | goto errout; |
219 | err = -EINVAL; | 222 | err = -EINVAL; |
220 | tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND-1]); | 223 | tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND]); |
221 | if (tp_ops == NULL) { | 224 | if (tp_ops == NULL) { |
222 | #ifdef CONFIG_KMOD | 225 | #ifdef CONFIG_KMOD |
223 | struct rtattr *kind = tca[TCA_KIND-1]; | 226 | struct nlattr *kind = tca[TCA_KIND]; |
224 | char name[IFNAMSIZ]; | 227 | char name[IFNAMSIZ]; |
225 | 228 | ||
226 | if (kind != NULL && | 229 | if (kind != NULL && |
227 | rtattr_strlcpy(name, kind, IFNAMSIZ) < IFNAMSIZ) { | 230 | nla_strlcpy(name, kind, IFNAMSIZ) < IFNAMSIZ) { |
228 | rtnl_unlock(); | 231 | rtnl_unlock(); |
229 | request_module("cls_%s", name); | 232 | request_module("cls_%s", name); |
230 | rtnl_lock(); | 233 | rtnl_lock(); |
@@ -263,7 +266,7 @@ replay: | |||
263 | *back = tp; | 266 | *back = tp; |
264 | qdisc_unlock_tree(dev); | 267 | qdisc_unlock_tree(dev); |
265 | 268 | ||
266 | } else if (tca[TCA_KIND-1] && rtattr_strcmp(tca[TCA_KIND-1], tp->ops->kind)) | 269 | } else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) |
267 | goto errout; | 270 | goto errout; |
268 | 271 | ||
269 | fh = tp->ops->get(tp, t->tcm_handle); | 272 | fh = tp->ops->get(tp, t->tcm_handle); |
@@ -333,18 +336,18 @@ static int tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, | |||
333 | tcm->tcm_ifindex = tp->q->dev->ifindex; | 336 | tcm->tcm_ifindex = tp->q->dev->ifindex; |
334 | tcm->tcm_parent = tp->classid; | 337 | tcm->tcm_parent = tp->classid; |
335 | tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol); | 338 | tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol); |
336 | RTA_PUT(skb, TCA_KIND, IFNAMSIZ, tp->ops->kind); | 339 | NLA_PUT(skb, TCA_KIND, IFNAMSIZ, tp->ops->kind); |
337 | tcm->tcm_handle = fh; | 340 | tcm->tcm_handle = fh; |
338 | if (RTM_DELTFILTER != event) { | 341 | if (RTM_DELTFILTER != event) { |
339 | tcm->tcm_handle = 0; | 342 | tcm->tcm_handle = 0; |
340 | if (tp->ops->dump && tp->ops->dump(tp, fh, skb, tcm) < 0) | 343 | if (tp->ops->dump && tp->ops->dump(tp, fh, skb, tcm) < 0) |
341 | goto rtattr_failure; | 344 | goto nla_put_failure; |
342 | } | 345 | } |
343 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 346 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
344 | return skb->len; | 347 | return skb->len; |
345 | 348 | ||
346 | nlmsg_failure: | 349 | nlmsg_failure: |
347 | rtattr_failure: | 350 | nla_put_failure: |
348 | nlmsg_trim(skb, b); | 351 | nlmsg_trim(skb, b); |
349 | return -1; | 352 | return -1; |
350 | } | 353 | } |
@@ -476,8 +479,8 @@ void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts) | |||
476 | } | 479 | } |
477 | EXPORT_SYMBOL(tcf_exts_destroy); | 480 | EXPORT_SYMBOL(tcf_exts_destroy); |
478 | 481 | ||
479 | int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, | 482 | int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb, |
480 | struct rtattr *rate_tlv, struct tcf_exts *exts, | 483 | struct nlattr *rate_tlv, struct tcf_exts *exts, |
481 | struct tcf_ext_map *map) | 484 | struct tcf_ext_map *map) |
482 | { | 485 | { |
483 | memset(exts, 0, sizeof(*exts)); | 486 | memset(exts, 0, sizeof(*exts)); |
@@ -487,8 +490,9 @@ int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, | |||
487 | int err; | 490 | int err; |
488 | struct tc_action *act; | 491 | struct tc_action *act; |
489 | 492 | ||
490 | if (map->police && tb[map->police-1]) { | 493 | if (map->police && tb[map->police]) { |
491 | act = tcf_action_init_1(tb[map->police-1], rate_tlv, | 494 | act = tcf_action_init_1((struct rtattr *)tb[map->police], |
495 | (struct rtattr *)rate_tlv, | ||
492 | "police", TCA_ACT_NOREPLACE, | 496 | "police", TCA_ACT_NOREPLACE, |
493 | TCA_ACT_BIND, &err); | 497 | TCA_ACT_BIND, &err); |
494 | if (act == NULL) | 498 | if (act == NULL) |
@@ -496,8 +500,9 @@ int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, | |||
496 | 500 | ||
497 | act->type = TCA_OLD_COMPAT; | 501 | act->type = TCA_OLD_COMPAT; |
498 | exts->action = act; | 502 | exts->action = act; |
499 | } else if (map->action && tb[map->action-1]) { | 503 | } else if (map->action && tb[map->action]) { |
500 | act = tcf_action_init(tb[map->action-1], rate_tlv, NULL, | 504 | act = tcf_action_init((struct rtattr *)tb[map->action], |
505 | (struct rtattr *)rate_tlv, NULL, | ||
501 | TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err); | 506 | TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err); |
502 | if (act == NULL) | 507 | if (act == NULL) |
503 | return err; | 508 | return err; |
@@ -506,8 +511,8 @@ int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, | |||
506 | } | 511 | } |
507 | } | 512 | } |
508 | #else | 513 | #else |
509 | if ((map->action && tb[map->action-1]) || | 514 | if ((map->action && tb[map->action]) || |
510 | (map->police && tb[map->police-1])) | 515 | (map->police && tb[map->police])) |
511 | return -EOPNOTSUPP; | 516 | return -EOPNOTSUPP; |
512 | #endif | 517 | #endif |
513 | 518 | ||
@@ -541,23 +546,23 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts, | |||
541 | * to work with both old and new modes of entering | 546 | * to work with both old and new modes of entering |
542 | * tc data even if iproute2 was newer - jhs | 547 | * tc data even if iproute2 was newer - jhs |
543 | */ | 548 | */ |
544 | struct rtattr *p_rta = (struct rtattr *)skb_tail_pointer(skb); | 549 | struct nlattr *p_rta = (struct nlattr *)skb_tail_pointer(skb); |
545 | 550 | ||
546 | if (exts->action->type != TCA_OLD_COMPAT) { | 551 | if (exts->action->type != TCA_OLD_COMPAT) { |
547 | RTA_PUT(skb, map->action, 0, NULL); | 552 | NLA_PUT(skb, map->action, 0, NULL); |
548 | if (tcf_action_dump(skb, exts->action, 0, 0) < 0) | 553 | if (tcf_action_dump(skb, exts->action, 0, 0) < 0) |
549 | goto rtattr_failure; | 554 | goto nla_put_failure; |
550 | p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta; | 555 | p_rta->nla_len = skb_tail_pointer(skb) - (u8 *)p_rta; |
551 | } else if (map->police) { | 556 | } else if (map->police) { |
552 | RTA_PUT(skb, map->police, 0, NULL); | 557 | NLA_PUT(skb, map->police, 0, NULL); |
553 | if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0) | 558 | if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0) |
554 | goto rtattr_failure; | 559 | goto nla_put_failure; |
555 | p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta; | 560 | p_rta->nla_len = skb_tail_pointer(skb) - (u8 *)p_rta; |
556 | } | 561 | } |
557 | } | 562 | } |
558 | #endif | 563 | #endif |
559 | return 0; | 564 | return 0; |
560 | rtattr_failure: __attribute__ ((unused)) | 565 | nla_put_failure: __attribute__ ((unused)) |
561 | return -1; | 566 | return -1; |
562 | } | 567 | } |
563 | EXPORT_SYMBOL(tcf_exts_dump); | 568 | EXPORT_SYMBOL(tcf_exts_dump); |
@@ -569,10 +574,10 @@ int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts, | |||
569 | #ifdef CONFIG_NET_CLS_ACT | 574 | #ifdef CONFIG_NET_CLS_ACT |
570 | if (exts->action) | 575 | if (exts->action) |
571 | if (tcf_action_copy_stats(skb, exts->action, 1) < 0) | 576 | if (tcf_action_copy_stats(skb, exts->action, 1) < 0) |
572 | goto rtattr_failure; | 577 | goto nla_put_failure; |
573 | #endif | 578 | #endif |
574 | return 0; | 579 | return 0; |
575 | rtattr_failure: __attribute__ ((unused)) | 580 | nla_put_failure: __attribute__ ((unused)) |
576 | return -1; | 581 | return -1; |
577 | } | 582 | } |
578 | EXPORT_SYMBOL(tcf_exts_dump_stats); | 583 | EXPORT_SYMBOL(tcf_exts_dump_stats); |
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c index b31f9f971987..3953da33956f 100644 --- a/net/sched/cls_basic.c +++ b/net/sched/cls_basic.c | |||
@@ -130,27 +130,27 @@ static int basic_delete(struct tcf_proto *tp, unsigned long arg) | |||
130 | } | 130 | } |
131 | 131 | ||
132 | static inline int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f, | 132 | static inline int basic_set_parms(struct tcf_proto *tp, struct basic_filter *f, |
133 | unsigned long base, struct rtattr **tb, | 133 | unsigned long base, struct nlattr **tb, |
134 | struct rtattr *est) | 134 | struct nlattr *est) |
135 | { | 135 | { |
136 | int err = -EINVAL; | 136 | int err = -EINVAL; |
137 | struct tcf_exts e; | 137 | struct tcf_exts e; |
138 | struct tcf_ematch_tree t; | 138 | struct tcf_ematch_tree t; |
139 | 139 | ||
140 | if (tb[TCA_BASIC_CLASSID-1]) | 140 | if (tb[TCA_BASIC_CLASSID]) |
141 | if (RTA_PAYLOAD(tb[TCA_BASIC_CLASSID-1]) < sizeof(u32)) | 141 | if (nla_len(tb[TCA_BASIC_CLASSID]) < sizeof(u32)) |
142 | return err; | 142 | return err; |
143 | 143 | ||
144 | err = tcf_exts_validate(tp, tb, est, &e, &basic_ext_map); | 144 | err = tcf_exts_validate(tp, tb, est, &e, &basic_ext_map); |
145 | if (err < 0) | 145 | if (err < 0) |
146 | return err; | 146 | return err; |
147 | 147 | ||
148 | err = tcf_em_tree_validate(tp, tb[TCA_BASIC_EMATCHES-1], &t); | 148 | err = tcf_em_tree_validate(tp, tb[TCA_BASIC_EMATCHES], &t); |
149 | if (err < 0) | 149 | if (err < 0) |
150 | goto errout; | 150 | goto errout; |
151 | 151 | ||
152 | if (tb[TCA_BASIC_CLASSID-1]) { | 152 | if (tb[TCA_BASIC_CLASSID]) { |
153 | f->res.classid = *(u32*)RTA_DATA(tb[TCA_BASIC_CLASSID-1]); | 153 | f->res.classid = *(u32*)nla_data(tb[TCA_BASIC_CLASSID]); |
154 | tcf_bind_filter(tp, &f->res, base); | 154 | tcf_bind_filter(tp, &f->res, base); |
155 | } | 155 | } |
156 | 156 | ||
@@ -164,23 +164,23 @@ errout: | |||
164 | } | 164 | } |
165 | 165 | ||
166 | static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle, | 166 | static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle, |
167 | struct rtattr **tca, unsigned long *arg) | 167 | struct nlattr **tca, unsigned long *arg) |
168 | { | 168 | { |
169 | int err = -EINVAL; | 169 | int err = -EINVAL; |
170 | struct basic_head *head = (struct basic_head *) tp->root; | 170 | struct basic_head *head = (struct basic_head *) tp->root; |
171 | struct rtattr *tb[TCA_BASIC_MAX]; | 171 | struct nlattr *tb[TCA_BASIC_MAX + 1]; |
172 | struct basic_filter *f = (struct basic_filter *) *arg; | 172 | struct basic_filter *f = (struct basic_filter *) *arg; |
173 | 173 | ||
174 | if (tca[TCA_OPTIONS-1] == NULL) | 174 | if (tca[TCA_OPTIONS] == NULL) |
175 | return -EINVAL; | 175 | return -EINVAL; |
176 | 176 | ||
177 | if (rtattr_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS-1]) < 0) | 177 | if (nla_parse_nested(tb, TCA_BASIC_MAX, tca[TCA_OPTIONS], NULL) < 0) |
178 | return -EINVAL; | 178 | return -EINVAL; |
179 | 179 | ||
180 | if (f != NULL) { | 180 | if (f != NULL) { |
181 | if (handle && f->handle != handle) | 181 | if (handle && f->handle != handle) |
182 | return -EINVAL; | 182 | return -EINVAL; |
183 | return basic_set_parms(tp, f, base, tb, tca[TCA_RATE-1]); | 183 | return basic_set_parms(tp, f, base, tb, tca[TCA_RATE]); |
184 | } | 184 | } |
185 | 185 | ||
186 | err = -ENOBUFS; | 186 | err = -ENOBUFS; |
@@ -206,7 +206,7 @@ static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
206 | f->handle = head->hgenerator; | 206 | f->handle = head->hgenerator; |
207 | } | 207 | } |
208 | 208 | ||
209 | err = basic_set_parms(tp, f, base, tb, tca[TCA_RATE-1]); | 209 | err = basic_set_parms(tp, f, base, tb, tca[TCA_RATE]); |
210 | if (err < 0) | 210 | if (err < 0) |
211 | goto errout; | 211 | goto errout; |
212 | 212 | ||
@@ -246,27 +246,27 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh, | |||
246 | { | 246 | { |
247 | struct basic_filter *f = (struct basic_filter *) fh; | 247 | struct basic_filter *f = (struct basic_filter *) fh; |
248 | unsigned char *b = skb_tail_pointer(skb); | 248 | unsigned char *b = skb_tail_pointer(skb); |
249 | struct rtattr *rta; | 249 | struct nlattr *nla; |
250 | 250 | ||
251 | if (f == NULL) | 251 | if (f == NULL) |
252 | return skb->len; | 252 | return skb->len; |
253 | 253 | ||
254 | t->tcm_handle = f->handle; | 254 | t->tcm_handle = f->handle; |
255 | 255 | ||
256 | rta = (struct rtattr *) b; | 256 | nla = (struct nlattr *) b; |
257 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 257 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
258 | 258 | ||
259 | if (f->res.classid) | 259 | if (f->res.classid) |
260 | RTA_PUT(skb, TCA_BASIC_CLASSID, sizeof(u32), &f->res.classid); | 260 | NLA_PUT(skb, TCA_BASIC_CLASSID, sizeof(u32), &f->res.classid); |
261 | 261 | ||
262 | if (tcf_exts_dump(skb, &f->exts, &basic_ext_map) < 0 || | 262 | if (tcf_exts_dump(skb, &f->exts, &basic_ext_map) < 0 || |
263 | tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0) | 263 | tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0) |
264 | goto rtattr_failure; | 264 | goto nla_put_failure; |
265 | 265 | ||
266 | rta->rta_len = skb_tail_pointer(skb) - b; | 266 | nla->nla_len = skb_tail_pointer(skb) - b; |
267 | return skb->len; | 267 | return skb->len; |
268 | 268 | ||
269 | rtattr_failure: | 269 | nla_put_failure: |
270 | nlmsg_trim(skb, b); | 270 | nlmsg_trim(skb, b); |
271 | return -1; | 271 | return -1; |
272 | } | 272 | } |
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index b45038770e79..db6e90a37846 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c | |||
@@ -188,37 +188,37 @@ out: | |||
188 | 188 | ||
189 | static int | 189 | static int |
190 | fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f, | 190 | fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f, |
191 | struct rtattr **tb, struct rtattr **tca, unsigned long base) | 191 | struct nlattr **tb, struct nlattr **tca, unsigned long base) |
192 | { | 192 | { |
193 | struct fw_head *head = (struct fw_head *)tp->root; | 193 | struct fw_head *head = (struct fw_head *)tp->root; |
194 | struct tcf_exts e; | 194 | struct tcf_exts e; |
195 | u32 mask; | 195 | u32 mask; |
196 | int err; | 196 | int err; |
197 | 197 | ||
198 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &fw_ext_map); | 198 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE], &e, &fw_ext_map); |
199 | if (err < 0) | 199 | if (err < 0) |
200 | return err; | 200 | return err; |
201 | 201 | ||
202 | err = -EINVAL; | 202 | err = -EINVAL; |
203 | if (tb[TCA_FW_CLASSID-1]) { | 203 | if (tb[TCA_FW_CLASSID]) { |
204 | if (RTA_PAYLOAD(tb[TCA_FW_CLASSID-1]) != sizeof(u32)) | 204 | if (nla_len(tb[TCA_FW_CLASSID]) != sizeof(u32)) |
205 | goto errout; | 205 | goto errout; |
206 | f->res.classid = *(u32*)RTA_DATA(tb[TCA_FW_CLASSID-1]); | 206 | f->res.classid = *(u32*)nla_data(tb[TCA_FW_CLASSID]); |
207 | tcf_bind_filter(tp, &f->res, base); | 207 | tcf_bind_filter(tp, &f->res, base); |
208 | } | 208 | } |
209 | 209 | ||
210 | #ifdef CONFIG_NET_CLS_IND | 210 | #ifdef CONFIG_NET_CLS_IND |
211 | if (tb[TCA_FW_INDEV-1]) { | 211 | if (tb[TCA_FW_INDEV]) { |
212 | err = tcf_change_indev(tp, f->indev, tb[TCA_FW_INDEV-1]); | 212 | err = tcf_change_indev(tp, f->indev, tb[TCA_FW_INDEV]); |
213 | if (err < 0) | 213 | if (err < 0) |
214 | goto errout; | 214 | goto errout; |
215 | } | 215 | } |
216 | #endif /* CONFIG_NET_CLS_IND */ | 216 | #endif /* CONFIG_NET_CLS_IND */ |
217 | 217 | ||
218 | if (tb[TCA_FW_MASK-1]) { | 218 | if (tb[TCA_FW_MASK]) { |
219 | if (RTA_PAYLOAD(tb[TCA_FW_MASK-1]) != sizeof(u32)) | 219 | if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32)) |
220 | goto errout; | 220 | goto errout; |
221 | mask = *(u32*)RTA_DATA(tb[TCA_FW_MASK-1]); | 221 | mask = *(u32*)nla_data(tb[TCA_FW_MASK]); |
222 | if (mask != head->mask) | 222 | if (mask != head->mask) |
223 | goto errout; | 223 | goto errout; |
224 | } else if (head->mask != 0xFFFFFFFF) | 224 | } else if (head->mask != 0xFFFFFFFF) |
@@ -234,19 +234,19 @@ errout: | |||
234 | 234 | ||
235 | static int fw_change(struct tcf_proto *tp, unsigned long base, | 235 | static int fw_change(struct tcf_proto *tp, unsigned long base, |
236 | u32 handle, | 236 | u32 handle, |
237 | struct rtattr **tca, | 237 | struct nlattr **tca, |
238 | unsigned long *arg) | 238 | unsigned long *arg) |
239 | { | 239 | { |
240 | struct fw_head *head = (struct fw_head*)tp->root; | 240 | struct fw_head *head = (struct fw_head*)tp->root; |
241 | struct fw_filter *f = (struct fw_filter *) *arg; | 241 | struct fw_filter *f = (struct fw_filter *) *arg; |
242 | struct rtattr *opt = tca[TCA_OPTIONS-1]; | 242 | struct nlattr *opt = tca[TCA_OPTIONS]; |
243 | struct rtattr *tb[TCA_FW_MAX]; | 243 | struct nlattr *tb[TCA_FW_MAX + 1]; |
244 | int err; | 244 | int err; |
245 | 245 | ||
246 | if (!opt) | 246 | if (!opt) |
247 | return handle ? -EINVAL : 0; | 247 | return handle ? -EINVAL : 0; |
248 | 248 | ||
249 | if (rtattr_parse_nested(tb, TCA_FW_MAX, opt) < 0) | 249 | if (nla_parse_nested(tb, TCA_FW_MAX, opt, NULL) < 0) |
250 | return -EINVAL; | 250 | return -EINVAL; |
251 | 251 | ||
252 | if (f != NULL) { | 252 | if (f != NULL) { |
@@ -260,10 +260,10 @@ static int fw_change(struct tcf_proto *tp, unsigned long base, | |||
260 | 260 | ||
261 | if (head == NULL) { | 261 | if (head == NULL) { |
262 | u32 mask = 0xFFFFFFFF; | 262 | u32 mask = 0xFFFFFFFF; |
263 | if (tb[TCA_FW_MASK-1]) { | 263 | if (tb[TCA_FW_MASK]) { |
264 | if (RTA_PAYLOAD(tb[TCA_FW_MASK-1]) != sizeof(u32)) | 264 | if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32)) |
265 | return -EINVAL; | 265 | return -EINVAL; |
266 | mask = *(u32*)RTA_DATA(tb[TCA_FW_MASK-1]); | 266 | mask = *(u32*)nla_data(tb[TCA_FW_MASK]); |
267 | } | 267 | } |
268 | 268 | ||
269 | head = kzalloc(sizeof(struct fw_head), GFP_KERNEL); | 269 | head = kzalloc(sizeof(struct fw_head), GFP_KERNEL); |
@@ -333,7 +333,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh, | |||
333 | struct fw_head *head = (struct fw_head *)tp->root; | 333 | struct fw_head *head = (struct fw_head *)tp->root; |
334 | struct fw_filter *f = (struct fw_filter*)fh; | 334 | struct fw_filter *f = (struct fw_filter*)fh; |
335 | unsigned char *b = skb_tail_pointer(skb); | 335 | unsigned char *b = skb_tail_pointer(skb); |
336 | struct rtattr *rta; | 336 | struct nlattr *nla; |
337 | 337 | ||
338 | if (f == NULL) | 338 | if (f == NULL) |
339 | return skb->len; | 339 | return skb->len; |
@@ -343,29 +343,29 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh, | |||
343 | if (!f->res.classid && !tcf_exts_is_available(&f->exts)) | 343 | if (!f->res.classid && !tcf_exts_is_available(&f->exts)) |
344 | return skb->len; | 344 | return skb->len; |
345 | 345 | ||
346 | rta = (struct rtattr*)b; | 346 | nla = (struct nlattr*)b; |
347 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 347 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
348 | 348 | ||
349 | if (f->res.classid) | 349 | if (f->res.classid) |
350 | RTA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid); | 350 | NLA_PUT(skb, TCA_FW_CLASSID, 4, &f->res.classid); |
351 | #ifdef CONFIG_NET_CLS_IND | 351 | #ifdef CONFIG_NET_CLS_IND |
352 | if (strlen(f->indev)) | 352 | if (strlen(f->indev)) |
353 | RTA_PUT(skb, TCA_FW_INDEV, IFNAMSIZ, f->indev); | 353 | NLA_PUT(skb, TCA_FW_INDEV, IFNAMSIZ, f->indev); |
354 | #endif /* CONFIG_NET_CLS_IND */ | 354 | #endif /* CONFIG_NET_CLS_IND */ |
355 | if (head->mask != 0xFFFFFFFF) | 355 | if (head->mask != 0xFFFFFFFF) |
356 | RTA_PUT(skb, TCA_FW_MASK, 4, &head->mask); | 356 | NLA_PUT(skb, TCA_FW_MASK, 4, &head->mask); |
357 | 357 | ||
358 | if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0) | 358 | if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0) |
359 | goto rtattr_failure; | 359 | goto nla_put_failure; |
360 | 360 | ||
361 | rta->rta_len = skb_tail_pointer(skb) - b; | 361 | nla->nla_len = skb_tail_pointer(skb) - b; |
362 | 362 | ||
363 | if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0) | 363 | if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0) |
364 | goto rtattr_failure; | 364 | goto nla_put_failure; |
365 | 365 | ||
366 | return skb->len; | 366 | return skb->len; |
367 | 367 | ||
368 | rtattr_failure: | 368 | nla_put_failure: |
369 | nlmsg_trim(skb, b); | 369 | nlmsg_trim(skb, b); |
370 | return -1; | 370 | return -1; |
371 | } | 371 | } |
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index e70edd0f7bc8..b1aae84cbadc 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c | |||
@@ -325,7 +325,7 @@ static int route4_delete(struct tcf_proto *tp, unsigned long arg) | |||
325 | 325 | ||
326 | static int route4_set_parms(struct tcf_proto *tp, unsigned long base, | 326 | static int route4_set_parms(struct tcf_proto *tp, unsigned long base, |
327 | struct route4_filter *f, u32 handle, struct route4_head *head, | 327 | struct route4_filter *f, u32 handle, struct route4_head *head, |
328 | struct rtattr **tb, struct rtattr *est, int new) | 328 | struct nlattr **tb, struct nlattr *est, int new) |
329 | { | 329 | { |
330 | int err; | 330 | int err; |
331 | u32 id = 0, to = 0, nhandle = 0x8000; | 331 | u32 id = 0, to = 0, nhandle = 0x8000; |
@@ -339,34 +339,34 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base, | |||
339 | return err; | 339 | return err; |
340 | 340 | ||
341 | err = -EINVAL; | 341 | err = -EINVAL; |
342 | if (tb[TCA_ROUTE4_CLASSID-1]) | 342 | if (tb[TCA_ROUTE4_CLASSID]) |
343 | if (RTA_PAYLOAD(tb[TCA_ROUTE4_CLASSID-1]) < sizeof(u32)) | 343 | if (nla_len(tb[TCA_ROUTE4_CLASSID]) < sizeof(u32)) |
344 | goto errout; | 344 | goto errout; |
345 | 345 | ||
346 | if (tb[TCA_ROUTE4_TO-1]) { | 346 | if (tb[TCA_ROUTE4_TO]) { |
347 | if (new && handle & 0x8000) | 347 | if (new && handle & 0x8000) |
348 | goto errout; | 348 | goto errout; |
349 | if (RTA_PAYLOAD(tb[TCA_ROUTE4_TO-1]) < sizeof(u32)) | 349 | if (nla_len(tb[TCA_ROUTE4_TO]) < sizeof(u32)) |
350 | goto errout; | 350 | goto errout; |
351 | to = *(u32*)RTA_DATA(tb[TCA_ROUTE4_TO-1]); | 351 | to = *(u32*)nla_data(tb[TCA_ROUTE4_TO]); |
352 | if (to > 0xFF) | 352 | if (to > 0xFF) |
353 | goto errout; | 353 | goto errout; |
354 | nhandle = to; | 354 | nhandle = to; |
355 | } | 355 | } |
356 | 356 | ||
357 | if (tb[TCA_ROUTE4_FROM-1]) { | 357 | if (tb[TCA_ROUTE4_FROM]) { |
358 | if (tb[TCA_ROUTE4_IIF-1]) | 358 | if (tb[TCA_ROUTE4_IIF]) |
359 | goto errout; | 359 | goto errout; |
360 | if (RTA_PAYLOAD(tb[TCA_ROUTE4_FROM-1]) < sizeof(u32)) | 360 | if (nla_len(tb[TCA_ROUTE4_FROM]) < sizeof(u32)) |
361 | goto errout; | 361 | goto errout; |
362 | id = *(u32*)RTA_DATA(tb[TCA_ROUTE4_FROM-1]); | 362 | id = *(u32*)nla_data(tb[TCA_ROUTE4_FROM]); |
363 | if (id > 0xFF) | 363 | if (id > 0xFF) |
364 | goto errout; | 364 | goto errout; |
365 | nhandle |= id << 16; | 365 | nhandle |= id << 16; |
366 | } else if (tb[TCA_ROUTE4_IIF-1]) { | 366 | } else if (tb[TCA_ROUTE4_IIF]) { |
367 | if (RTA_PAYLOAD(tb[TCA_ROUTE4_IIF-1]) < sizeof(u32)) | 367 | if (nla_len(tb[TCA_ROUTE4_IIF]) < sizeof(u32)) |
368 | goto errout; | 368 | goto errout; |
369 | id = *(u32*)RTA_DATA(tb[TCA_ROUTE4_IIF-1]); | 369 | id = *(u32*)nla_data(tb[TCA_ROUTE4_IIF]); |
370 | if (id > 0x7FFF) | 370 | if (id > 0x7FFF) |
371 | goto errout; | 371 | goto errout; |
372 | nhandle |= (id | 0x8000) << 16; | 372 | nhandle |= (id | 0x8000) << 16; |
@@ -398,20 +398,20 @@ static int route4_set_parms(struct tcf_proto *tp, unsigned long base, | |||
398 | } | 398 | } |
399 | 399 | ||
400 | tcf_tree_lock(tp); | 400 | tcf_tree_lock(tp); |
401 | if (tb[TCA_ROUTE4_TO-1]) | 401 | if (tb[TCA_ROUTE4_TO]) |
402 | f->id = to; | 402 | f->id = to; |
403 | 403 | ||
404 | if (tb[TCA_ROUTE4_FROM-1]) | 404 | if (tb[TCA_ROUTE4_FROM]) |
405 | f->id = to | id<<16; | 405 | f->id = to | id<<16; |
406 | else if (tb[TCA_ROUTE4_IIF-1]) | 406 | else if (tb[TCA_ROUTE4_IIF]) |
407 | f->iif = id; | 407 | f->iif = id; |
408 | 408 | ||
409 | f->handle = nhandle; | 409 | f->handle = nhandle; |
410 | f->bkt = b; | 410 | f->bkt = b; |
411 | tcf_tree_unlock(tp); | 411 | tcf_tree_unlock(tp); |
412 | 412 | ||
413 | if (tb[TCA_ROUTE4_CLASSID-1]) { | 413 | if (tb[TCA_ROUTE4_CLASSID]) { |
414 | f->res.classid = *(u32*)RTA_DATA(tb[TCA_ROUTE4_CLASSID-1]); | 414 | f->res.classid = *(u32*)nla_data(tb[TCA_ROUTE4_CLASSID]); |
415 | tcf_bind_filter(tp, &f->res, base); | 415 | tcf_bind_filter(tp, &f->res, base); |
416 | } | 416 | } |
417 | 417 | ||
@@ -425,14 +425,14 @@ errout: | |||
425 | 425 | ||
426 | static int route4_change(struct tcf_proto *tp, unsigned long base, | 426 | static int route4_change(struct tcf_proto *tp, unsigned long base, |
427 | u32 handle, | 427 | u32 handle, |
428 | struct rtattr **tca, | 428 | struct nlattr **tca, |
429 | unsigned long *arg) | 429 | unsigned long *arg) |
430 | { | 430 | { |
431 | struct route4_head *head = tp->root; | 431 | struct route4_head *head = tp->root; |
432 | struct route4_filter *f, *f1, **fp; | 432 | struct route4_filter *f, *f1, **fp; |
433 | struct route4_bucket *b; | 433 | struct route4_bucket *b; |
434 | struct rtattr *opt = tca[TCA_OPTIONS-1]; | 434 | struct nlattr *opt = tca[TCA_OPTIONS]; |
435 | struct rtattr *tb[TCA_ROUTE4_MAX]; | 435 | struct nlattr *tb[TCA_ROUTE4_MAX + 1]; |
436 | unsigned int h, th; | 436 | unsigned int h, th; |
437 | u32 old_handle = 0; | 437 | u32 old_handle = 0; |
438 | int err; | 438 | int err; |
@@ -440,7 +440,7 @@ static int route4_change(struct tcf_proto *tp, unsigned long base, | |||
440 | if (opt == NULL) | 440 | if (opt == NULL) |
441 | return handle ? -EINVAL : 0; | 441 | return handle ? -EINVAL : 0; |
442 | 442 | ||
443 | if (rtattr_parse_nested(tb, TCA_ROUTE4_MAX, opt) < 0) | 443 | if (nla_parse_nested(tb, TCA_ROUTE4_MAX, opt, NULL) < 0) |
444 | return -EINVAL; | 444 | return -EINVAL; |
445 | 445 | ||
446 | if ((f = (struct route4_filter*)*arg) != NULL) { | 446 | if ((f = (struct route4_filter*)*arg) != NULL) { |
@@ -451,7 +451,7 @@ static int route4_change(struct tcf_proto *tp, unsigned long base, | |||
451 | old_handle = f->handle; | 451 | old_handle = f->handle; |
452 | 452 | ||
453 | err = route4_set_parms(tp, base, f, handle, head, tb, | 453 | err = route4_set_parms(tp, base, f, handle, head, tb, |
454 | tca[TCA_RATE-1], 0); | 454 | tca[TCA_RATE], 0); |
455 | if (err < 0) | 455 | if (err < 0) |
456 | return err; | 456 | return err; |
457 | 457 | ||
@@ -474,7 +474,7 @@ static int route4_change(struct tcf_proto *tp, unsigned long base, | |||
474 | goto errout; | 474 | goto errout; |
475 | 475 | ||
476 | err = route4_set_parms(tp, base, f, handle, head, tb, | 476 | err = route4_set_parms(tp, base, f, handle, head, tb, |
477 | tca[TCA_RATE-1], 1); | 477 | tca[TCA_RATE], 1); |
478 | if (err < 0) | 478 | if (err < 0) |
479 | goto errout; | 479 | goto errout; |
480 | 480 | ||
@@ -550,7 +550,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, | |||
550 | { | 550 | { |
551 | struct route4_filter *f = (struct route4_filter*)fh; | 551 | struct route4_filter *f = (struct route4_filter*)fh; |
552 | unsigned char *b = skb_tail_pointer(skb); | 552 | unsigned char *b = skb_tail_pointer(skb); |
553 | struct rtattr *rta; | 553 | struct nlattr *nla; |
554 | u32 id; | 554 | u32 id; |
555 | 555 | ||
556 | if (f == NULL) | 556 | if (f == NULL) |
@@ -558,34 +558,34 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, | |||
558 | 558 | ||
559 | t->tcm_handle = f->handle; | 559 | t->tcm_handle = f->handle; |
560 | 560 | ||
561 | rta = (struct rtattr*)b; | 561 | nla = (struct nlattr*)b; |
562 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 562 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
563 | 563 | ||
564 | if (!(f->handle&0x8000)) { | 564 | if (!(f->handle&0x8000)) { |
565 | id = f->id&0xFF; | 565 | id = f->id&0xFF; |
566 | RTA_PUT(skb, TCA_ROUTE4_TO, sizeof(id), &id); | 566 | NLA_PUT(skb, TCA_ROUTE4_TO, sizeof(id), &id); |
567 | } | 567 | } |
568 | if (f->handle&0x80000000) { | 568 | if (f->handle&0x80000000) { |
569 | if ((f->handle>>16) != 0xFFFF) | 569 | if ((f->handle>>16) != 0xFFFF) |
570 | RTA_PUT(skb, TCA_ROUTE4_IIF, sizeof(f->iif), &f->iif); | 570 | NLA_PUT(skb, TCA_ROUTE4_IIF, sizeof(f->iif), &f->iif); |
571 | } else { | 571 | } else { |
572 | id = f->id>>16; | 572 | id = f->id>>16; |
573 | RTA_PUT(skb, TCA_ROUTE4_FROM, sizeof(id), &id); | 573 | NLA_PUT(skb, TCA_ROUTE4_FROM, sizeof(id), &id); |
574 | } | 574 | } |
575 | if (f->res.classid) | 575 | if (f->res.classid) |
576 | RTA_PUT(skb, TCA_ROUTE4_CLASSID, 4, &f->res.classid); | 576 | NLA_PUT(skb, TCA_ROUTE4_CLASSID, 4, &f->res.classid); |
577 | 577 | ||
578 | if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0) | 578 | if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0) |
579 | goto rtattr_failure; | 579 | goto nla_put_failure; |
580 | 580 | ||
581 | rta->rta_len = skb_tail_pointer(skb) - b; | 581 | nla->nla_len = skb_tail_pointer(skb) - b; |
582 | 582 | ||
583 | if (tcf_exts_dump_stats(skb, &f->exts, &route_ext_map) < 0) | 583 | if (tcf_exts_dump_stats(skb, &f->exts, &route_ext_map) < 0) |
584 | goto rtattr_failure; | 584 | goto nla_put_failure; |
585 | 585 | ||
586 | return skb->len; | 586 | return skb->len; |
587 | 587 | ||
588 | rtattr_failure: | 588 | nla_put_failure: |
589 | nlmsg_trim(skb, b); | 589 | nlmsg_trim(skb, b); |
590 | return -1; | 590 | return -1; |
591 | } | 591 | } |
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h index 22f9ede70e8f..2364c79d0837 100644 --- a/net/sched/cls_rsvp.h +++ b/net/sched/cls_rsvp.h | |||
@@ -399,15 +399,15 @@ static u32 gen_tunnel(struct rsvp_head *data) | |||
399 | 399 | ||
400 | static int rsvp_change(struct tcf_proto *tp, unsigned long base, | 400 | static int rsvp_change(struct tcf_proto *tp, unsigned long base, |
401 | u32 handle, | 401 | u32 handle, |
402 | struct rtattr **tca, | 402 | struct nlattr **tca, |
403 | unsigned long *arg) | 403 | unsigned long *arg) |
404 | { | 404 | { |
405 | struct rsvp_head *data = tp->root; | 405 | struct rsvp_head *data = tp->root; |
406 | struct rsvp_filter *f, **fp; | 406 | struct rsvp_filter *f, **fp; |
407 | struct rsvp_session *s, **sp; | 407 | struct rsvp_session *s, **sp; |
408 | struct tc_rsvp_pinfo *pinfo = NULL; | 408 | struct tc_rsvp_pinfo *pinfo = NULL; |
409 | struct rtattr *opt = tca[TCA_OPTIONS-1]; | 409 | struct nlattr *opt = tca[TCA_OPTIONS-1]; |
410 | struct rtattr *tb[TCA_RSVP_MAX]; | 410 | struct nlattr *tb[TCA_RSVP_MAX + 1]; |
411 | struct tcf_exts e; | 411 | struct tcf_exts e; |
412 | unsigned h1, h2; | 412 | unsigned h1, h2; |
413 | __be32 *dst; | 413 | __be32 *dst; |
@@ -416,7 +416,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, | |||
416 | if (opt == NULL) | 416 | if (opt == NULL) |
417 | return handle ? -EINVAL : 0; | 417 | return handle ? -EINVAL : 0; |
418 | 418 | ||
419 | if (rtattr_parse_nested(tb, TCA_RSVP_MAX, opt) < 0) | 419 | if (nla_parse_nested(tb, TCA_RSVP_MAX, opt, NULL) < 0) |
420 | return -EINVAL; | 420 | return -EINVAL; |
421 | 421 | ||
422 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &rsvp_ext_map); | 422 | err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &rsvp_ext_map); |
@@ -429,7 +429,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, | |||
429 | if (f->handle != handle && handle) | 429 | if (f->handle != handle && handle) |
430 | goto errout2; | 430 | goto errout2; |
431 | if (tb[TCA_RSVP_CLASSID-1]) { | 431 | if (tb[TCA_RSVP_CLASSID-1]) { |
432 | f->res.classid = *(u32*)RTA_DATA(tb[TCA_RSVP_CLASSID-1]); | 432 | f->res.classid = *(u32*)nla_data(tb[TCA_RSVP_CLASSID-1]); |
433 | tcf_bind_filter(tp, &f->res, base); | 433 | tcf_bind_filter(tp, &f->res, base); |
434 | } | 434 | } |
435 | 435 | ||
@@ -452,30 +452,30 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base, | |||
452 | h2 = 16; | 452 | h2 = 16; |
453 | if (tb[TCA_RSVP_SRC-1]) { | 453 | if (tb[TCA_RSVP_SRC-1]) { |
454 | err = -EINVAL; | 454 | err = -EINVAL; |
455 | if (RTA_PAYLOAD(tb[TCA_RSVP_SRC-1]) != sizeof(f->src)) | 455 | if (nla_len(tb[TCA_RSVP_SRC-1]) != sizeof(f->src)) |
456 | goto errout; | 456 | goto errout; |
457 | memcpy(f->src, RTA_DATA(tb[TCA_RSVP_SRC-1]), sizeof(f->src)); | 457 | memcpy(f->src, nla_data(tb[TCA_RSVP_SRC-1]), sizeof(f->src)); |
458 | h2 = hash_src(f->src); | 458 | h2 = hash_src(f->src); |
459 | } | 459 | } |
460 | if (tb[TCA_RSVP_PINFO-1]) { | 460 | if (tb[TCA_RSVP_PINFO-1]) { |
461 | err = -EINVAL; | 461 | err = -EINVAL; |
462 | if (RTA_PAYLOAD(tb[TCA_RSVP_PINFO-1]) < sizeof(struct tc_rsvp_pinfo)) | 462 | if (nla_len(tb[TCA_RSVP_PINFO-1]) < sizeof(struct tc_rsvp_pinfo)) |
463 | goto errout; | 463 | goto errout; |
464 | pinfo = RTA_DATA(tb[TCA_RSVP_PINFO-1]); | 464 | pinfo = nla_data(tb[TCA_RSVP_PINFO-1]); |
465 | f->spi = pinfo->spi; | 465 | f->spi = pinfo->spi; |
466 | f->tunnelhdr = pinfo->tunnelhdr; | 466 | f->tunnelhdr = pinfo->tunnelhdr; |
467 | } | 467 | } |
468 | if (tb[TCA_RSVP_CLASSID-1]) { | 468 | if (tb[TCA_RSVP_CLASSID-1]) { |
469 | err = -EINVAL; | 469 | err = -EINVAL; |
470 | if (RTA_PAYLOAD(tb[TCA_RSVP_CLASSID-1]) != 4) | 470 | if (nla_len(tb[TCA_RSVP_CLASSID-1]) != 4) |
471 | goto errout; | 471 | goto errout; |
472 | f->res.classid = *(u32*)RTA_DATA(tb[TCA_RSVP_CLASSID-1]); | 472 | f->res.classid = *(u32*)nla_data(tb[TCA_RSVP_CLASSID-1]); |
473 | } | 473 | } |
474 | 474 | ||
475 | err = -EINVAL; | 475 | err = -EINVAL; |
476 | if (RTA_PAYLOAD(tb[TCA_RSVP_DST-1]) != sizeof(f->src)) | 476 | if (nla_len(tb[TCA_RSVP_DST-1]) != sizeof(f->src)) |
477 | goto errout; | 477 | goto errout; |
478 | dst = RTA_DATA(tb[TCA_RSVP_DST-1]); | 478 | dst = nla_data(tb[TCA_RSVP_DST-1]); |
479 | h1 = hash_dst(dst, pinfo ? pinfo->protocol : 0, pinfo ? pinfo->tunnelid : 0); | 479 | h1 = hash_dst(dst, pinfo ? pinfo->protocol : 0, pinfo ? pinfo->tunnelid : 0); |
480 | 480 | ||
481 | err = -ENOMEM; | 481 | err = -ENOMEM; |
@@ -594,7 +594,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, | |||
594 | struct rsvp_filter *f = (struct rsvp_filter*)fh; | 594 | struct rsvp_filter *f = (struct rsvp_filter*)fh; |
595 | struct rsvp_session *s; | 595 | struct rsvp_session *s; |
596 | unsigned char *b = skb_tail_pointer(skb); | 596 | unsigned char *b = skb_tail_pointer(skb); |
597 | struct rtattr *rta; | 597 | struct nlattr *nla; |
598 | struct tc_rsvp_pinfo pinfo; | 598 | struct tc_rsvp_pinfo pinfo; |
599 | 599 | ||
600 | if (f == NULL) | 600 | if (f == NULL) |
@@ -604,32 +604,32 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, | |||
604 | t->tcm_handle = f->handle; | 604 | t->tcm_handle = f->handle; |
605 | 605 | ||
606 | 606 | ||
607 | rta = (struct rtattr*)b; | 607 | nla = (struct nlattr*)b; |
608 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 608 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
609 | 609 | ||
610 | RTA_PUT(skb, TCA_RSVP_DST, sizeof(s->dst), &s->dst); | 610 | NLA_PUT(skb, TCA_RSVP_DST, sizeof(s->dst), &s->dst); |
611 | pinfo.dpi = s->dpi; | 611 | pinfo.dpi = s->dpi; |
612 | pinfo.spi = f->spi; | 612 | pinfo.spi = f->spi; |
613 | pinfo.protocol = s->protocol; | 613 | pinfo.protocol = s->protocol; |
614 | pinfo.tunnelid = s->tunnelid; | 614 | pinfo.tunnelid = s->tunnelid; |
615 | pinfo.tunnelhdr = f->tunnelhdr; | 615 | pinfo.tunnelhdr = f->tunnelhdr; |
616 | pinfo.pad = 0; | 616 | pinfo.pad = 0; |
617 | RTA_PUT(skb, TCA_RSVP_PINFO, sizeof(pinfo), &pinfo); | 617 | NLA_PUT(skb, TCA_RSVP_PINFO, sizeof(pinfo), &pinfo); |
618 | if (f->res.classid) | 618 | if (f->res.classid) |
619 | RTA_PUT(skb, TCA_RSVP_CLASSID, 4, &f->res.classid); | 619 | NLA_PUT(skb, TCA_RSVP_CLASSID, 4, &f->res.classid); |
620 | if (((f->handle>>8)&0xFF) != 16) | 620 | if (((f->handle>>8)&0xFF) != 16) |
621 | RTA_PUT(skb, TCA_RSVP_SRC, sizeof(f->src), f->src); | 621 | NLA_PUT(skb, TCA_RSVP_SRC, sizeof(f->src), f->src); |
622 | 622 | ||
623 | if (tcf_exts_dump(skb, &f->exts, &rsvp_ext_map) < 0) | 623 | if (tcf_exts_dump(skb, &f->exts, &rsvp_ext_map) < 0) |
624 | goto rtattr_failure; | 624 | goto nla_put_failure; |
625 | 625 | ||
626 | rta->rta_len = skb_tail_pointer(skb) - b; | 626 | nla->nla_len = skb_tail_pointer(skb) - b; |
627 | 627 | ||
628 | if (tcf_exts_dump_stats(skb, &f->exts, &rsvp_ext_map) < 0) | 628 | if (tcf_exts_dump_stats(skb, &f->exts, &rsvp_ext_map) < 0) |
629 | goto rtattr_failure; | 629 | goto nla_put_failure; |
630 | return skb->len; | 630 | return skb->len; |
631 | 631 | ||
632 | rtattr_failure: | 632 | nla_put_failure: |
633 | nlmsg_trim(skb, b); | 633 | nlmsg_trim(skb, b); |
634 | return -1; | 634 | return -1; |
635 | } | 635 | } |
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index e36977b17fa6..ed8023944fe5 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c | |||
@@ -196,7 +196,7 @@ valid_perfect_hash(struct tcindex_data *p) | |||
196 | static int | 196 | static int |
197 | tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | 197 | tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, |
198 | struct tcindex_data *p, struct tcindex_filter_result *r, | 198 | struct tcindex_data *p, struct tcindex_filter_result *r, |
199 | struct rtattr **tb, struct rtattr *est) | 199 | struct nlattr **tb, struct nlattr *est) |
200 | { | 200 | { |
201 | int err, balloc = 0; | 201 | int err, balloc = 0; |
202 | struct tcindex_filter_result new_filter_result, *old_r = r; | 202 | struct tcindex_filter_result new_filter_result, *old_r = r; |
@@ -218,22 +218,22 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
218 | memset(&cr, 0, sizeof(cr)); | 218 | memset(&cr, 0, sizeof(cr)); |
219 | 219 | ||
220 | err = -EINVAL; | 220 | err = -EINVAL; |
221 | if (tb[TCA_TCINDEX_HASH-1]) { | 221 | if (tb[TCA_TCINDEX_HASH]) { |
222 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_HASH-1]) < sizeof(u32)) | 222 | if (nla_len(tb[TCA_TCINDEX_HASH]) < sizeof(u32)) |
223 | goto errout; | 223 | goto errout; |
224 | cp.hash = *(u32 *) RTA_DATA(tb[TCA_TCINDEX_HASH-1]); | 224 | cp.hash = *(u32 *) nla_data(tb[TCA_TCINDEX_HASH]); |
225 | } | 225 | } |
226 | 226 | ||
227 | if (tb[TCA_TCINDEX_MASK-1]) { | 227 | if (tb[TCA_TCINDEX_MASK]) { |
228 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_MASK-1]) < sizeof(u16)) | 228 | if (nla_len(tb[TCA_TCINDEX_MASK]) < sizeof(u16)) |
229 | goto errout; | 229 | goto errout; |
230 | cp.mask = *(u16 *) RTA_DATA(tb[TCA_TCINDEX_MASK-1]); | 230 | cp.mask = *(u16 *) nla_data(tb[TCA_TCINDEX_MASK]); |
231 | } | 231 | } |
232 | 232 | ||
233 | if (tb[TCA_TCINDEX_SHIFT-1]) { | 233 | if (tb[TCA_TCINDEX_SHIFT]) { |
234 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_SHIFT-1]) < sizeof(int)) | 234 | if (nla_len(tb[TCA_TCINDEX_SHIFT]) < sizeof(int)) |
235 | goto errout; | 235 | goto errout; |
236 | cp.shift = *(int *) RTA_DATA(tb[TCA_TCINDEX_SHIFT-1]); | 236 | cp.shift = *(int *) nla_data(tb[TCA_TCINDEX_SHIFT]); |
237 | } | 237 | } |
238 | 238 | ||
239 | err = -EBUSY; | 239 | err = -EBUSY; |
@@ -248,11 +248,11 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
248 | goto errout; | 248 | goto errout; |
249 | 249 | ||
250 | err = -EINVAL; | 250 | err = -EINVAL; |
251 | if (tb[TCA_TCINDEX_FALL_THROUGH-1]) { | 251 | if (tb[TCA_TCINDEX_FALL_THROUGH]) { |
252 | if (RTA_PAYLOAD(tb[TCA_TCINDEX_FALL_THROUGH-1]) < sizeof(u32)) | 252 | if (nla_len(tb[TCA_TCINDEX_FALL_THROUGH]) < sizeof(u32)) |
253 | goto errout; | 253 | goto errout; |
254 | cp.fall_through = | 254 | cp.fall_through = |
255 | *(u32 *) RTA_DATA(tb[TCA_TCINDEX_FALL_THROUGH-1]); | 255 | *(u32 *) nla_data(tb[TCA_TCINDEX_FALL_THROUGH]); |
256 | } | 256 | } |
257 | 257 | ||
258 | if (!cp.hash) { | 258 | if (!cp.hash) { |
@@ -304,8 +304,8 @@ tcindex_set_parms(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
304 | goto errout_alloc; | 304 | goto errout_alloc; |
305 | } | 305 | } |
306 | 306 | ||
307 | if (tb[TCA_TCINDEX_CLASSID-1]) { | 307 | if (tb[TCA_TCINDEX_CLASSID]) { |
308 | cr.res.classid = *(u32 *) RTA_DATA(tb[TCA_TCINDEX_CLASSID-1]); | 308 | cr.res.classid = *(u32 *) nla_data(tb[TCA_TCINDEX_CLASSID]); |
309 | tcf_bind_filter(tp, &cr.res, base); | 309 | tcf_bind_filter(tp, &cr.res, base); |
310 | } | 310 | } |
311 | 311 | ||
@@ -344,10 +344,10 @@ errout: | |||
344 | 344 | ||
345 | static int | 345 | static int |
346 | tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, | 346 | tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, |
347 | struct rtattr **tca, unsigned long *arg) | 347 | struct nlattr **tca, unsigned long *arg) |
348 | { | 348 | { |
349 | struct rtattr *opt = tca[TCA_OPTIONS-1]; | 349 | struct nlattr *opt = tca[TCA_OPTIONS]; |
350 | struct rtattr *tb[TCA_TCINDEX_MAX]; | 350 | struct nlattr *tb[TCA_TCINDEX_MAX + 1]; |
351 | struct tcindex_data *p = PRIV(tp); | 351 | struct tcindex_data *p = PRIV(tp); |
352 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg; | 352 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) *arg; |
353 | 353 | ||
@@ -358,10 +358,10 @@ tcindex_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
358 | if (!opt) | 358 | if (!opt) |
359 | return 0; | 359 | return 0; |
360 | 360 | ||
361 | if (rtattr_parse_nested(tb, TCA_TCINDEX_MAX, opt) < 0) | 361 | if (nla_parse_nested(tb, TCA_TCINDEX_MAX, opt, NULL) < 0) |
362 | return -EINVAL; | 362 | return -EINVAL; |
363 | 363 | ||
364 | return tcindex_set_parms(tp, base, handle, p, r, tb, tca[TCA_RATE-1]); | 364 | return tcindex_set_parms(tp, base, handle, p, r, tb, tca[TCA_RATE]); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
@@ -435,21 +435,21 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, | |||
435 | struct tcindex_data *p = PRIV(tp); | 435 | struct tcindex_data *p = PRIV(tp); |
436 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; | 436 | struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; |
437 | unsigned char *b = skb_tail_pointer(skb); | 437 | unsigned char *b = skb_tail_pointer(skb); |
438 | struct rtattr *rta; | 438 | struct nlattr *nla; |
439 | 439 | ||
440 | pr_debug("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n", | 440 | pr_debug("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n", |
441 | tp, fh, skb, t, p, r, b); | 441 | tp, fh, skb, t, p, r, b); |
442 | pr_debug("p->perfect %p p->h %p\n", p->perfect, p->h); | 442 | pr_debug("p->perfect %p p->h %p\n", p->perfect, p->h); |
443 | rta = (struct rtattr *) b; | 443 | nla = (struct nlattr *) b; |
444 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 444 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
445 | if (!fh) { | 445 | if (!fh) { |
446 | t->tcm_handle = ~0; /* whatever ... */ | 446 | t->tcm_handle = ~0; /* whatever ... */ |
447 | RTA_PUT(skb, TCA_TCINDEX_HASH, sizeof(p->hash), &p->hash); | 447 | NLA_PUT(skb, TCA_TCINDEX_HASH, sizeof(p->hash), &p->hash); |
448 | RTA_PUT(skb, TCA_TCINDEX_MASK, sizeof(p->mask), &p->mask); | 448 | NLA_PUT(skb, TCA_TCINDEX_MASK, sizeof(p->mask), &p->mask); |
449 | RTA_PUT(skb, TCA_TCINDEX_SHIFT, sizeof(p->shift), &p->shift); | 449 | NLA_PUT(skb, TCA_TCINDEX_SHIFT, sizeof(p->shift), &p->shift); |
450 | RTA_PUT(skb, TCA_TCINDEX_FALL_THROUGH, sizeof(p->fall_through), | 450 | NLA_PUT(skb, TCA_TCINDEX_FALL_THROUGH, sizeof(p->fall_through), |
451 | &p->fall_through); | 451 | &p->fall_through); |
452 | rta->rta_len = skb_tail_pointer(skb) - b; | 452 | nla->nla_len = skb_tail_pointer(skb) - b; |
453 | } else { | 453 | } else { |
454 | if (p->perfect) { | 454 | if (p->perfect) { |
455 | t->tcm_handle = r-p->perfect; | 455 | t->tcm_handle = r-p->perfect; |
@@ -468,19 +468,19 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, | |||
468 | } | 468 | } |
469 | pr_debug("handle = %d\n", t->tcm_handle); | 469 | pr_debug("handle = %d\n", t->tcm_handle); |
470 | if (r->res.class) | 470 | if (r->res.class) |
471 | RTA_PUT(skb, TCA_TCINDEX_CLASSID, 4, &r->res.classid); | 471 | NLA_PUT(skb, TCA_TCINDEX_CLASSID, 4, &r->res.classid); |
472 | 472 | ||
473 | if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) | 473 | if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) |
474 | goto rtattr_failure; | 474 | goto nla_put_failure; |
475 | rta->rta_len = skb_tail_pointer(skb) - b; | 475 | nla->nla_len = skb_tail_pointer(skb) - b; |
476 | 476 | ||
477 | if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0) | 477 | if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0) |
478 | goto rtattr_failure; | 478 | goto nla_put_failure; |
479 | } | 479 | } |
480 | 480 | ||
481 | return skb->len; | 481 | return skb->len; |
482 | 482 | ||
483 | rtattr_failure: | 483 | nla_put_failure: |
484 | nlmsg_trim(skb, b); | 484 | nlmsg_trim(skb, b); |
485 | return -1; | 485 | return -1; |
486 | } | 486 | } |
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 7bf3cd4e7318..aaf5049f951c 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -462,8 +462,8 @@ static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle) | |||
462 | 462 | ||
463 | static int u32_set_parms(struct tcf_proto *tp, unsigned long base, | 463 | static int u32_set_parms(struct tcf_proto *tp, unsigned long base, |
464 | struct tc_u_hnode *ht, | 464 | struct tc_u_hnode *ht, |
465 | struct tc_u_knode *n, struct rtattr **tb, | 465 | struct tc_u_knode *n, struct nlattr **tb, |
466 | struct rtattr *est) | 466 | struct nlattr *est) |
467 | { | 467 | { |
468 | int err; | 468 | int err; |
469 | struct tcf_exts e; | 469 | struct tcf_exts e; |
@@ -473,8 +473,8 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base, | |||
473 | return err; | 473 | return err; |
474 | 474 | ||
475 | err = -EINVAL; | 475 | err = -EINVAL; |
476 | if (tb[TCA_U32_LINK-1]) { | 476 | if (tb[TCA_U32_LINK]) { |
477 | u32 handle = *(u32*)RTA_DATA(tb[TCA_U32_LINK-1]); | 477 | u32 handle = *(u32*)nla_data(tb[TCA_U32_LINK]); |
478 | struct tc_u_hnode *ht_down = NULL; | 478 | struct tc_u_hnode *ht_down = NULL; |
479 | 479 | ||
480 | if (TC_U32_KEY(handle)) | 480 | if (TC_U32_KEY(handle)) |
@@ -495,14 +495,14 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base, | |||
495 | if (ht_down) | 495 | if (ht_down) |
496 | ht_down->refcnt--; | 496 | ht_down->refcnt--; |
497 | } | 497 | } |
498 | if (tb[TCA_U32_CLASSID-1]) { | 498 | if (tb[TCA_U32_CLASSID]) { |
499 | n->res.classid = *(u32*)RTA_DATA(tb[TCA_U32_CLASSID-1]); | 499 | n->res.classid = *(u32*)nla_data(tb[TCA_U32_CLASSID]); |
500 | tcf_bind_filter(tp, &n->res, base); | 500 | tcf_bind_filter(tp, &n->res, base); |
501 | } | 501 | } |
502 | 502 | ||
503 | #ifdef CONFIG_NET_CLS_IND | 503 | #ifdef CONFIG_NET_CLS_IND |
504 | if (tb[TCA_U32_INDEV-1]) { | 504 | if (tb[TCA_U32_INDEV]) { |
505 | err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV-1]); | 505 | err = tcf_change_indev(tp, n->indev, tb[TCA_U32_INDEV]); |
506 | if (err < 0) | 506 | if (err < 0) |
507 | goto errout; | 507 | goto errout; |
508 | } | 508 | } |
@@ -516,33 +516,33 @@ errout: | |||
516 | } | 516 | } |
517 | 517 | ||
518 | static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | 518 | static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, |
519 | struct rtattr **tca, | 519 | struct nlattr **tca, |
520 | unsigned long *arg) | 520 | unsigned long *arg) |
521 | { | 521 | { |
522 | struct tc_u_common *tp_c = tp->data; | 522 | struct tc_u_common *tp_c = tp->data; |
523 | struct tc_u_hnode *ht; | 523 | struct tc_u_hnode *ht; |
524 | struct tc_u_knode *n; | 524 | struct tc_u_knode *n; |
525 | struct tc_u32_sel *s; | 525 | struct tc_u32_sel *s; |
526 | struct rtattr *opt = tca[TCA_OPTIONS-1]; | 526 | struct nlattr *opt = tca[TCA_OPTIONS]; |
527 | struct rtattr *tb[TCA_U32_MAX]; | 527 | struct nlattr *tb[TCA_U32_MAX + 1]; |
528 | u32 htid; | 528 | u32 htid; |
529 | int err; | 529 | int err; |
530 | 530 | ||
531 | if (opt == NULL) | 531 | if (opt == NULL) |
532 | return handle ? -EINVAL : 0; | 532 | return handle ? -EINVAL : 0; |
533 | 533 | ||
534 | if (rtattr_parse_nested(tb, TCA_U32_MAX, opt) < 0) | 534 | if (nla_parse_nested(tb, TCA_U32_MAX, opt, NULL) < 0) |
535 | return -EINVAL; | 535 | return -EINVAL; |
536 | 536 | ||
537 | if ((n = (struct tc_u_knode*)*arg) != NULL) { | 537 | if ((n = (struct tc_u_knode*)*arg) != NULL) { |
538 | if (TC_U32_KEY(n->handle) == 0) | 538 | if (TC_U32_KEY(n->handle) == 0) |
539 | return -EINVAL; | 539 | return -EINVAL; |
540 | 540 | ||
541 | return u32_set_parms(tp, base, n->ht_up, n, tb, tca[TCA_RATE-1]); | 541 | return u32_set_parms(tp, base, n->ht_up, n, tb, tca[TCA_RATE]); |
542 | } | 542 | } |
543 | 543 | ||
544 | if (tb[TCA_U32_DIVISOR-1]) { | 544 | if (tb[TCA_U32_DIVISOR]) { |
545 | unsigned divisor = *(unsigned*)RTA_DATA(tb[TCA_U32_DIVISOR-1]); | 545 | unsigned divisor = *(unsigned*)nla_data(tb[TCA_U32_DIVISOR]); |
546 | 546 | ||
547 | if (--divisor > 0x100) | 547 | if (--divisor > 0x100) |
548 | return -EINVAL; | 548 | return -EINVAL; |
@@ -567,8 +567,8 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
567 | return 0; | 567 | return 0; |
568 | } | 568 | } |
569 | 569 | ||
570 | if (tb[TCA_U32_HASH-1]) { | 570 | if (tb[TCA_U32_HASH]) { |
571 | htid = *(unsigned*)RTA_DATA(tb[TCA_U32_HASH-1]); | 571 | htid = *(unsigned*)nla_data(tb[TCA_U32_HASH]); |
572 | if (TC_U32_HTID(htid) == TC_U32_ROOT) { | 572 | if (TC_U32_HTID(htid) == TC_U32_ROOT) { |
573 | ht = tp->root; | 573 | ht = tp->root; |
574 | htid = ht->handle; | 574 | htid = ht->handle; |
@@ -592,11 +592,11 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
592 | } else | 592 | } else |
593 | handle = gen_new_kid(ht, htid); | 593 | handle = gen_new_kid(ht, htid); |
594 | 594 | ||
595 | if (tb[TCA_U32_SEL-1] == NULL || | 595 | if (tb[TCA_U32_SEL] == NULL || |
596 | RTA_PAYLOAD(tb[TCA_U32_SEL-1]) < sizeof(struct tc_u32_sel)) | 596 | nla_len(tb[TCA_U32_SEL]) < sizeof(struct tc_u32_sel)) |
597 | return -EINVAL; | 597 | return -EINVAL; |
598 | 598 | ||
599 | s = RTA_DATA(tb[TCA_U32_SEL-1]); | 599 | s = nla_data(tb[TCA_U32_SEL]); |
600 | 600 | ||
601 | n = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL); | 601 | n = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL); |
602 | if (n == NULL) | 602 | if (n == NULL) |
@@ -616,23 +616,23 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, | |||
616 | n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; | 616 | n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; |
617 | 617 | ||
618 | #ifdef CONFIG_CLS_U32_MARK | 618 | #ifdef CONFIG_CLS_U32_MARK |
619 | if (tb[TCA_U32_MARK-1]) { | 619 | if (tb[TCA_U32_MARK]) { |
620 | struct tc_u32_mark *mark; | 620 | struct tc_u32_mark *mark; |
621 | 621 | ||
622 | if (RTA_PAYLOAD(tb[TCA_U32_MARK-1]) < sizeof(struct tc_u32_mark)) { | 622 | if (nla_len(tb[TCA_U32_MARK]) < sizeof(struct tc_u32_mark)) { |
623 | #ifdef CONFIG_CLS_U32_PERF | 623 | #ifdef CONFIG_CLS_U32_PERF |
624 | kfree(n->pf); | 624 | kfree(n->pf); |
625 | #endif | 625 | #endif |
626 | kfree(n); | 626 | kfree(n); |
627 | return -EINVAL; | 627 | return -EINVAL; |
628 | } | 628 | } |
629 | mark = RTA_DATA(tb[TCA_U32_MARK-1]); | 629 | mark = nla_data(tb[TCA_U32_MARK]); |
630 | memcpy(&n->mark, mark, sizeof(struct tc_u32_mark)); | 630 | memcpy(&n->mark, mark, sizeof(struct tc_u32_mark)); |
631 | n->mark.success = 0; | 631 | n->mark.success = 0; |
632 | } | 632 | } |
633 | #endif | 633 | #endif |
634 | 634 | ||
635 | err = u32_set_parms(tp, base, ht, n, tb, tca[TCA_RATE-1]); | 635 | err = u32_set_parms(tp, base, ht, n, tb, tca[TCA_RATE]); |
636 | if (err == 0) { | 636 | if (err == 0) { |
637 | struct tc_u_knode **ins; | 637 | struct tc_u_knode **ins; |
638 | for (ins = &ht->ht[TC_U32_HASH(handle)]; *ins; ins = &(*ins)->next) | 638 | for (ins = &ht->ht[TC_U32_HASH(handle)]; *ins; ins = &(*ins)->next) |
@@ -694,59 +694,59 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, | |||
694 | { | 694 | { |
695 | struct tc_u_knode *n = (struct tc_u_knode*)fh; | 695 | struct tc_u_knode *n = (struct tc_u_knode*)fh; |
696 | unsigned char *b = skb_tail_pointer(skb); | 696 | unsigned char *b = skb_tail_pointer(skb); |
697 | struct rtattr *rta; | 697 | struct nlattr *nla; |
698 | 698 | ||
699 | if (n == NULL) | 699 | if (n == NULL) |
700 | return skb->len; | 700 | return skb->len; |
701 | 701 | ||
702 | t->tcm_handle = n->handle; | 702 | t->tcm_handle = n->handle; |
703 | 703 | ||
704 | rta = (struct rtattr*)b; | 704 | nla = (struct nlattr*)b; |
705 | RTA_PUT(skb, TCA_OPTIONS, 0, NULL); | 705 | NLA_PUT(skb, TCA_OPTIONS, 0, NULL); |
706 | 706 | ||
707 | if (TC_U32_KEY(n->handle) == 0) { | 707 | if (TC_U32_KEY(n->handle) == 0) { |
708 | struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; | 708 | struct tc_u_hnode *ht = (struct tc_u_hnode*)fh; |
709 | u32 divisor = ht->divisor+1; | 709 | u32 divisor = ht->divisor+1; |
710 | RTA_PUT(skb, TCA_U32_DIVISOR, 4, &divisor); | 710 | NLA_PUT(skb, TCA_U32_DIVISOR, 4, &divisor); |
711 | } else { | 711 | } else { |
712 | RTA_PUT(skb, TCA_U32_SEL, | 712 | NLA_PUT(skb, TCA_U32_SEL, |
713 | sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), | 713 | sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), |
714 | &n->sel); | 714 | &n->sel); |
715 | if (n->ht_up) { | 715 | if (n->ht_up) { |
716 | u32 htid = n->handle & 0xFFFFF000; | 716 | u32 htid = n->handle & 0xFFFFF000; |
717 | RTA_PUT(skb, TCA_U32_HASH, 4, &htid); | 717 | NLA_PUT(skb, TCA_U32_HASH, 4, &htid); |
718 | } | 718 | } |
719 | if (n->res.classid) | 719 | if (n->res.classid) |
720 | RTA_PUT(skb, TCA_U32_CLASSID, 4, &n->res.classid); | 720 | NLA_PUT(skb, TCA_U32_CLASSID, 4, &n->res.classid); |
721 | if (n->ht_down) | 721 | if (n->ht_down) |
722 | RTA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle); | 722 | NLA_PUT(skb, TCA_U32_LINK, 4, &n->ht_down->handle); |
723 | 723 | ||
724 | #ifdef CONFIG_CLS_U32_MARK | 724 | #ifdef CONFIG_CLS_U32_MARK |
725 | if (n->mark.val || n->mark.mask) | 725 | if (n->mark.val || n->mark.mask) |
726 | RTA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark); | 726 | NLA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark); |
727 | #endif | 727 | #endif |
728 | 728 | ||
729 | if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) | 729 | if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) |
730 | goto rtattr_failure; | 730 | goto nla_put_failure; |
731 | 731 | ||
732 | #ifdef CONFIG_NET_CLS_IND | 732 | #ifdef CONFIG_NET_CLS_IND |
733 | if(strlen(n->indev)) | 733 | if(strlen(n->indev)) |
734 | RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev); | 734 | NLA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev); |
735 | #endif | 735 | #endif |
736 | #ifdef CONFIG_CLS_U32_PERF | 736 | #ifdef CONFIG_CLS_U32_PERF |
737 | RTA_PUT(skb, TCA_U32_PCNT, | 737 | NLA_PUT(skb, TCA_U32_PCNT, |
738 | sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64), | 738 | sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64), |
739 | n->pf); | 739 | n->pf); |
740 | #endif | 740 | #endif |
741 | } | 741 | } |
742 | 742 | ||
743 | rta->rta_len = skb_tail_pointer(skb) - b; | 743 | nla->nla_len = skb_tail_pointer(skb) - b; |
744 | if (TC_U32_KEY(n->handle)) | 744 | if (TC_U32_KEY(n->handle)) |
745 | if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) | 745 | if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) |
746 | goto rtattr_failure; | 746 | goto nla_put_failure; |
747 | return skb->len; | 747 | return skb->len; |
748 | 748 | ||
749 | rtattr_failure: | 749 | nla_put_failure: |
750 | nlmsg_trim(skb, b); | 750 | nlmsg_trim(skb, b); |
751 | return -1; | 751 | return -1; |
752 | } | 752 | } |
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index ceda8890ab0e..92b6863e928d 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
@@ -542,11 +542,11 @@ static int meta_var_compare(struct meta_obj *a, struct meta_obj *b) | |||
542 | return r; | 542 | return r; |
543 | } | 543 | } |
544 | 544 | ||
545 | static int meta_var_change(struct meta_value *dst, struct rtattr *rta) | 545 | static int meta_var_change(struct meta_value *dst, struct nlattr *nla) |
546 | { | 546 | { |
547 | int len = RTA_PAYLOAD(rta); | 547 | int len = nla_len(nla); |
548 | 548 | ||
549 | dst->val = (unsigned long)kmemdup(RTA_DATA(rta), len, GFP_KERNEL); | 549 | dst->val = (unsigned long)kmemdup(nla_data(nla), len, GFP_KERNEL); |
550 | if (dst->val == 0UL) | 550 | if (dst->val == 0UL) |
551 | return -ENOMEM; | 551 | return -ENOMEM; |
552 | dst->len = len; | 552 | dst->len = len; |
@@ -570,10 +570,10 @@ static void meta_var_apply_extras(struct meta_value *v, | |||
570 | static int meta_var_dump(struct sk_buff *skb, struct meta_value *v, int tlv) | 570 | static int meta_var_dump(struct sk_buff *skb, struct meta_value *v, int tlv) |
571 | { | 571 | { |
572 | if (v->val && v->len) | 572 | if (v->val && v->len) |
573 | RTA_PUT(skb, tlv, v->len, (void *) v->val); | 573 | NLA_PUT(skb, tlv, v->len, (void *) v->val); |
574 | return 0; | 574 | return 0; |
575 | 575 | ||
576 | rtattr_failure: | 576 | nla_put_failure: |
577 | return -1; | 577 | return -1; |
578 | } | 578 | } |
579 | 579 | ||
@@ -594,13 +594,13 @@ static int meta_int_compare(struct meta_obj *a, struct meta_obj *b) | |||
594 | return 1; | 594 | return 1; |
595 | } | 595 | } |
596 | 596 | ||
597 | static int meta_int_change(struct meta_value *dst, struct rtattr *rta) | 597 | static int meta_int_change(struct meta_value *dst, struct nlattr *nla) |
598 | { | 598 | { |
599 | if (RTA_PAYLOAD(rta) >= sizeof(unsigned long)) { | 599 | if (nla_len(nla) >= sizeof(unsigned long)) { |
600 | dst->val = *(unsigned long *) RTA_DATA(rta); | 600 | dst->val = *(unsigned long *) nla_data(nla); |
601 | dst->len = sizeof(unsigned long); | 601 | dst->len = sizeof(unsigned long); |
602 | } else if (RTA_PAYLOAD(rta) == sizeof(u32)) { | 602 | } else if (nla_len(nla) == sizeof(u32)) { |
603 | dst->val = *(u32 *) RTA_DATA(rta); | 603 | dst->val = *(u32 *) nla_data(nla); |
604 | dst->len = sizeof(u32); | 604 | dst->len = sizeof(u32); |
605 | } else | 605 | } else |
606 | return -EINVAL; | 606 | return -EINVAL; |
@@ -621,15 +621,15 @@ static void meta_int_apply_extras(struct meta_value *v, | |||
621 | static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv) | 621 | static int meta_int_dump(struct sk_buff *skb, struct meta_value *v, int tlv) |
622 | { | 622 | { |
623 | if (v->len == sizeof(unsigned long)) | 623 | if (v->len == sizeof(unsigned long)) |
624 | RTA_PUT(skb, tlv, sizeof(unsigned long), &v->val); | 624 | NLA_PUT(skb, tlv, sizeof(unsigned long), &v->val); |
625 | else if (v->len == sizeof(u32)) { | 625 | else if (v->len == sizeof(u32)) { |
626 | u32 d = v->val; | 626 | u32 d = v->val; |
627 | RTA_PUT(skb, tlv, sizeof(d), &d); | 627 | NLA_PUT(skb, tlv, sizeof(d), &d); |
628 | } | 628 | } |
629 | 629 | ||
630 | return 0; | 630 | return 0; |
631 | 631 | ||
632 | rtattr_failure: | 632 | nla_put_failure: |
633 | return -1; | 633 | return -1; |
634 | } | 634 | } |
635 | 635 | ||
@@ -641,7 +641,7 @@ struct meta_type_ops | |||
641 | { | 641 | { |
642 | void (*destroy)(struct meta_value *); | 642 | void (*destroy)(struct meta_value *); |
643 | int (*compare)(struct meta_obj *, struct meta_obj *); | 643 | int (*compare)(struct meta_obj *, struct meta_obj *); |
644 | int (*change)(struct meta_value *, struct rtattr *); | 644 | int (*change)(struct meta_value *, struct nlattr *); |
645 | void (*apply_extras)(struct meta_value *, struct meta_obj *); | 645 | void (*apply_extras)(struct meta_value *, struct meta_obj *); |
646 | int (*dump)(struct sk_buff *, struct meta_value *, int); | 646 | int (*dump)(struct sk_buff *, struct meta_value *, int); |
647 | }; | 647 | }; |
@@ -729,13 +729,13 @@ static inline void meta_delete(struct meta_match *meta) | |||
729 | kfree(meta); | 729 | kfree(meta); |
730 | } | 730 | } |
731 | 731 | ||
732 | static inline int meta_change_data(struct meta_value *dst, struct rtattr *rta) | 732 | static inline int meta_change_data(struct meta_value *dst, struct nlattr *nla) |
733 | { | 733 | { |
734 | if (rta) { | 734 | if (nla) { |
735 | if (RTA_PAYLOAD(rta) == 0) | 735 | if (nla_len(nla) == 0) |
736 | return -EINVAL; | 736 | return -EINVAL; |
737 | 737 | ||
738 | return meta_type_ops(dst)->change(dst, rta); | 738 | return meta_type_ops(dst)->change(dst, nla); |
739 | } | 739 | } |
740 | 740 | ||
741 | return 0; | 741 | return 0; |
@@ -750,17 +750,17 @@ static int em_meta_change(struct tcf_proto *tp, void *data, int len, | |||
750 | struct tcf_ematch *m) | 750 | struct tcf_ematch *m) |
751 | { | 751 | { |
752 | int err = -EINVAL; | 752 | int err = -EINVAL; |
753 | struct rtattr *tb[TCA_EM_META_MAX]; | 753 | struct nlattr *tb[TCA_EM_META_MAX + 1]; |
754 | struct tcf_meta_hdr *hdr; | 754 | struct tcf_meta_hdr *hdr; |
755 | struct meta_match *meta = NULL; | 755 | struct meta_match *meta = NULL; |
756 | 756 | ||
757 | if (rtattr_parse(tb, TCA_EM_META_MAX, data, len) < 0) | 757 | if (nla_parse(tb, TCA_EM_META_MAX, data, len, NULL) < 0) |
758 | goto errout; | 758 | goto errout; |
759 | 759 | ||
760 | if (tb[TCA_EM_META_HDR-1] == NULL || | 760 | if (tb[TCA_EM_META_HDR] == NULL || |
761 | RTA_PAYLOAD(tb[TCA_EM_META_HDR-1]) < sizeof(*hdr)) | 761 | nla_len(tb[TCA_EM_META_HDR]) < sizeof(*hdr)) |
762 | goto errout; | 762 | goto errout; |
763 | hdr = RTA_DATA(tb[TCA_EM_META_HDR-1]); | 763 | hdr = nla_data(tb[TCA_EM_META_HDR]); |
764 | 764 | ||
765 | if (TCF_META_TYPE(hdr->left.kind) != TCF_META_TYPE(hdr->right.kind) || | 765 | if (TCF_META_TYPE(hdr->left.kind) != TCF_META_TYPE(hdr->right.kind) || |
766 | TCF_META_TYPE(hdr->left.kind) > TCF_META_TYPE_MAX || | 766 | TCF_META_TYPE(hdr->left.kind) > TCF_META_TYPE_MAX || |
@@ -781,8 +781,8 @@ static int em_meta_change(struct tcf_proto *tp, void *data, int len, | |||
781 | goto errout; | 781 | goto errout; |
782 | } | 782 | } |
783 | 783 | ||
784 | if (meta_change_data(&meta->lvalue, tb[TCA_EM_META_LVALUE-1]) < 0 || | 784 | if (meta_change_data(&meta->lvalue, tb[TCA_EM_META_LVALUE]) < 0 || |
785 | meta_change_data(&meta->rvalue, tb[TCA_EM_META_RVALUE-1]) < 0) | 785 | meta_change_data(&meta->rvalue, tb[TCA_EM_META_RVALUE]) < 0) |
786 | goto errout; | 786 | goto errout; |
787 | 787 | ||
788 | m->datalen = sizeof(*meta); | 788 | m->datalen = sizeof(*meta); |
@@ -811,16 +811,16 @@ static int em_meta_dump(struct sk_buff *skb, struct tcf_ematch *em) | |||
811 | memcpy(&hdr.left, &meta->lvalue.hdr, sizeof(hdr.left)); | 811 | memcpy(&hdr.left, &meta->lvalue.hdr, sizeof(hdr.left)); |
812 | memcpy(&hdr.right, &meta->rvalue.hdr, sizeof(hdr.right)); | 812 | memcpy(&hdr.right, &meta->rvalue.hdr, sizeof(hdr.right)); |
813 | 813 | ||
814 | RTA_PUT(skb, TCA_EM_META_HDR, sizeof(hdr), &hdr); | 814 | NLA_PUT(skb, TCA_EM_META_HDR, sizeof(hdr), &hdr); |
815 | 815 | ||
816 | ops = meta_type_ops(&meta->lvalue); | 816 | ops = meta_type_ops(&meta->lvalue); |
817 | if (ops->dump(skb, &meta->lvalue, TCA_EM_META_LVALUE) < 0 || | 817 | if (ops->dump(skb, &meta->lvalue, TCA_EM_META_LVALUE) < 0 || |
818 | ops->dump(skb, &meta->rvalue, TCA_EM_META_RVALUE) < 0) | 818 | ops->dump(skb, &meta->rvalue, TCA_EM_META_RVALUE) < 0) |
819 | goto rtattr_failure; | 819 | goto nla_put_failure; |
820 | 820 | ||
821 | return 0; | 821 | return 0; |
822 | 822 | ||
823 | rtattr_failure: | 823 | nla_put_failure: |
824 | return -1; | 824 | return -1; |
825 | } | 825 | } |
826 | 826 | ||
diff --git a/net/sched/em_text.c b/net/sched/em_text.c index d5cd86efb7d0..853c5ead87fd 100644 --- a/net/sched/em_text.c +++ b/net/sched/em_text.c | |||
@@ -118,11 +118,14 @@ static int em_text_dump(struct sk_buff *skb, struct tcf_ematch *m) | |||
118 | conf.pattern_len = textsearch_get_pattern_len(tm->config); | 118 | conf.pattern_len = textsearch_get_pattern_len(tm->config); |
119 | conf.pad = 0; | 119 | conf.pad = 0; |
120 | 120 | ||
121 | RTA_PUT_NOHDR(skb, sizeof(conf), &conf); | 121 | if (nla_put_nohdr(skb, sizeof(conf), &conf) < 0) |
122 | RTA_APPEND(skb, conf.pattern_len, textsearch_get_pattern(tm->config)); | 122 | goto nla_put_failure; |
123 | if (nla_append(skb, conf.pattern_len, | ||
124 | textsearch_get_pattern(tm->config)) < 0) | ||
125 | goto nla_put_failure; | ||
123 | return 0; | 126 | return 0; |
124 | 127 | ||
125 | rtattr_failure: | 128 | nla_put_failure: |
126 | return -1; | 129 | return -1; |
127 | } | 130 | } |
128 | 131 | ||
diff --git a/net/sched/ematch.c b/net/sched/ematch.c index 27941cfc0ab5..72d9b2735245 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c | |||
@@ -183,11 +183,11 @@ static inline struct tcf_ematch * tcf_em_get_match(struct tcf_ematch_tree *tree, | |||
183 | 183 | ||
184 | static int tcf_em_validate(struct tcf_proto *tp, | 184 | static int tcf_em_validate(struct tcf_proto *tp, |
185 | struct tcf_ematch_tree_hdr *tree_hdr, | 185 | struct tcf_ematch_tree_hdr *tree_hdr, |
186 | struct tcf_ematch *em, struct rtattr *rta, int idx) | 186 | struct tcf_ematch *em, struct nlattr *nla, int idx) |
187 | { | 187 | { |
188 | int err = -EINVAL; | 188 | int err = -EINVAL; |
189 | struct tcf_ematch_hdr *em_hdr = RTA_DATA(rta); | 189 | struct tcf_ematch_hdr *em_hdr = nla_data(nla); |
190 | int data_len = RTA_PAYLOAD(rta) - sizeof(*em_hdr); | 190 | int data_len = nla_len(nla) - sizeof(*em_hdr); |
191 | void *data = (void *) em_hdr + sizeof(*em_hdr); | 191 | void *data = (void *) em_hdr + sizeof(*em_hdr); |
192 | 192 | ||
193 | if (!TCF_EM_REL_VALID(em_hdr->flags)) | 193 | if (!TCF_EM_REL_VALID(em_hdr->flags)) |
@@ -286,11 +286,11 @@ errout: | |||
286 | * tcf_em_tree_validate - validate ematch config TLV and build ematch tree | 286 | * tcf_em_tree_validate - validate ematch config TLV and build ematch tree |
287 | * | 287 | * |
288 | * @tp: classifier kind handle | 288 | * @tp: classifier kind handle |
289 | * @rta: ematch tree configuration TLV | 289 | * @nla: ematch tree configuration TLV |
290 | * @tree: destination ematch tree variable to store the resulting | 290 | * @tree: destination ematch tree variable to store the resulting |
291 | * ematch tree. | 291 | * ematch tree. |
292 | * | 292 | * |
293 | * This function validates the given configuration TLV @rta and builds an | 293 | * This function validates the given configuration TLV @nla and builds an |
294 | * ematch tree in @tree. The resulting tree must later be copied into | 294 | * ematch tree in @tree. The resulting tree must later be copied into |
295 | * the private classifier data using tcf_em_tree_change(). You MUST NOT | 295 | * the private classifier data using tcf_em_tree_change(). You MUST NOT |
296 | * provide the ematch tree variable of the private classifier data directly, | 296 | * provide the ematch tree variable of the private classifier data directly, |
@@ -298,45 +298,45 @@ errout: | |||
298 | * | 298 | * |
299 | * Returns a negative error code if the configuration TLV contains errors. | 299 | * Returns a negative error code if the configuration TLV contains errors. |
300 | */ | 300 | */ |
301 | int tcf_em_tree_validate(struct tcf_proto *tp, struct rtattr *rta, | 301 | int tcf_em_tree_validate(struct tcf_proto *tp, struct nlattr *nla, |
302 | struct tcf_ematch_tree *tree) | 302 | struct tcf_ematch_tree *tree) |
303 | { | 303 | { |
304 | int idx, list_len, matches_len, err = -EINVAL; | 304 | int idx, list_len, matches_len, err = -EINVAL; |
305 | struct rtattr *tb[TCA_EMATCH_TREE_MAX]; | 305 | struct nlattr *tb[TCA_EMATCH_TREE_MAX + 1]; |
306 | struct rtattr *rt_match, *rt_hdr, *rt_list; | 306 | struct nlattr *rt_match, *rt_hdr, *rt_list; |
307 | struct tcf_ematch_tree_hdr *tree_hdr; | 307 | struct tcf_ematch_tree_hdr *tree_hdr; |
308 | struct tcf_ematch *em; | 308 | struct tcf_ematch *em; |
309 | 309 | ||
310 | if (!rta) { | 310 | if (!nla) { |
311 | memset(tree, 0, sizeof(*tree)); | 311 | memset(tree, 0, sizeof(*tree)); |
312 | return 0; | 312 | return 0; |
313 | } | 313 | } |
314 | 314 | ||
315 | if (rtattr_parse_nested(tb, TCA_EMATCH_TREE_MAX, rta) < 0) | 315 | if (nla_parse_nested(tb, TCA_EMATCH_TREE_MAX, nla, NULL) < 0) |
316 | goto errout; | 316 | goto errout; |
317 | 317 | ||
318 | rt_hdr = tb[TCA_EMATCH_TREE_HDR-1]; | 318 | rt_hdr = tb[TCA_EMATCH_TREE_HDR]; |
319 | rt_list = tb[TCA_EMATCH_TREE_LIST-1]; | 319 | rt_list = tb[TCA_EMATCH_TREE_LIST]; |
320 | 320 | ||
321 | if (rt_hdr == NULL || rt_list == NULL) | 321 | if (rt_hdr == NULL || rt_list == NULL) |
322 | goto errout; | 322 | goto errout; |
323 | 323 | ||
324 | if (RTA_PAYLOAD(rt_hdr) < sizeof(*tree_hdr) || | 324 | if (nla_len(rt_hdr) < sizeof(*tree_hdr) || |
325 | RTA_PAYLOAD(rt_list) < sizeof(*rt_match)) | 325 | nla_len(rt_list) < sizeof(*rt_match)) |
326 | goto errout; | 326 | goto errout; |
327 | 327 | ||
328 | tree_hdr = RTA_DATA(rt_hdr); | 328 | tree_hdr = nla_data(rt_hdr); |
329 | memcpy(&tree->hdr, tree_hdr, sizeof(*tree_hdr)); | 329 | memcpy(&tree->hdr, tree_hdr, sizeof(*tree_hdr)); |
330 | 330 | ||
331 | rt_match = RTA_DATA(rt_list); | 331 | rt_match = nla_data(rt_list); |
332 | list_len = RTA_PAYLOAD(rt_list); | 332 | list_len = nla_len(rt_list); |
333 | matches_len = tree_hdr->nmatches * sizeof(*em); | 333 | matches_len = tree_hdr->nmatches * sizeof(*em); |
334 | 334 | ||
335 | tree->matches = kzalloc(matches_len, GFP_KERNEL); | 335 | tree->matches = kzalloc(matches_len, GFP_KERNEL); |
336 | if (tree->matches == NULL) | 336 | if (tree->matches == NULL) |
337 | goto errout; | 337 | goto errout; |
338 | 338 | ||
339 | /* We do not use rtattr_parse_nested here because the maximum | 339 | /* We do not use nla_parse_nested here because the maximum |
340 | * number of attributes is unknown. This saves us the allocation | 340 | * number of attributes is unknown. This saves us the allocation |
341 | * for a tb buffer which would serve no purpose at all. | 341 | * for a tb buffer which would serve no purpose at all. |
342 | * | 342 | * |
@@ -344,16 +344,16 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct rtattr *rta, | |||
344 | * provided, their type must be incremental from 1 to n. Even | 344 | * provided, their type must be incremental from 1 to n. Even |
345 | * if it does not serve any real purpose, a failure of sticking | 345 | * if it does not serve any real purpose, a failure of sticking |
346 | * to this policy will result in parsing failure. */ | 346 | * to this policy will result in parsing failure. */ |
347 | for (idx = 0; RTA_OK(rt_match, list_len); idx++) { | 347 | for (idx = 0; nla_ok(rt_match, list_len); idx++) { |
348 | err = -EINVAL; | 348 | err = -EINVAL; |
349 | 349 | ||
350 | if (rt_match->rta_type != (idx + 1)) | 350 | if (rt_match->nla_type != (idx + 1)) |
351 | goto errout_abort; | 351 | goto errout_abort; |
352 | 352 | ||
353 | if (idx >= tree_hdr->nmatches) | 353 | if (idx >= tree_hdr->nmatches) |
354 | goto errout_abort; | 354 | goto errout_abort; |
355 | 355 | ||
356 | if (RTA_PAYLOAD(rt_match) < sizeof(struct tcf_ematch_hdr)) | 356 | if (nla_len(rt_match) < sizeof(struct tcf_ematch_hdr)) |
357 | goto errout_abort; | 357 | goto errout_abort; |
358 | 358 | ||
359 | em = tcf_em_get_match(tree, idx); | 359 | em = tcf_em_get_match(tree, idx); |
@@ -362,7 +362,7 @@ int tcf_em_tree_validate(struct tcf_proto *tp, struct rtattr *rta, | |||
362 | if (err < 0) | 362 | if (err < 0) |
363 | goto errout_abort; | 363 | goto errout_abort; |
364 | 364 | ||
365 | rt_match = RTA_NEXT(rt_match, list_len); | 365 | rt_match = nla_next(rt_match, &list_len); |
366 | } | 366 | } |
367 | 367 | ||
368 | /* Check if the number of matches provided by userspace actually | 368 | /* Check if the number of matches provided by userspace actually |
@@ -434,18 +434,18 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) | |||
434 | { | 434 | { |
435 | int i; | 435 | int i; |
436 | u8 *tail; | 436 | u8 *tail; |
437 | struct rtattr *top_start = (struct rtattr *)skb_tail_pointer(skb); | 437 | struct nlattr *top_start = (struct nlattr *)skb_tail_pointer(skb); |
438 | struct rtattr *list_start; | 438 | struct nlattr *list_start; |
439 | 439 | ||
440 | RTA_PUT(skb, tlv, 0, NULL); | 440 | NLA_PUT(skb, tlv, 0, NULL); |
441 | RTA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr); | 441 | NLA_PUT(skb, TCA_EMATCH_TREE_HDR, sizeof(tree->hdr), &tree->hdr); |
442 | 442 | ||
443 | list_start = (struct rtattr *)skb_tail_pointer(skb); | 443 | list_start = (struct nlattr *)skb_tail_pointer(skb); |
444 | RTA_PUT(skb, TCA_EMATCH_TREE_LIST, 0, NULL); | 444 | NLA_PUT(skb, TCA_EMATCH_TREE_LIST, 0, NULL); |
445 | 445 | ||
446 | tail = skb_tail_pointer(skb); | 446 | tail = skb_tail_pointer(skb); |
447 | for (i = 0; i < tree->hdr.nmatches; i++) { | 447 | for (i = 0; i < tree->hdr.nmatches; i++) { |
448 | struct rtattr *match_start = (struct rtattr *)tail; | 448 | struct nlattr *match_start = (struct nlattr *)tail; |
449 | struct tcf_ematch *em = tcf_em_get_match(tree, i); | 449 | struct tcf_ematch *em = tcf_em_get_match(tree, i); |
450 | struct tcf_ematch_hdr em_hdr = { | 450 | struct tcf_ematch_hdr em_hdr = { |
451 | .kind = em->ops ? em->ops->kind : TCF_EM_CONTAINER, | 451 | .kind = em->ops ? em->ops->kind : TCF_EM_CONTAINER, |
@@ -453,27 +453,27 @@ int tcf_em_tree_dump(struct sk_buff *skb, struct tcf_ematch_tree *tree, int tlv) | |||
453 | .flags = em->flags | 453 | .flags = em->flags |
454 | }; | 454 | }; |
455 | 455 | ||
456 | RTA_PUT(skb, i+1, sizeof(em_hdr), &em_hdr); | 456 | NLA_PUT(skb, i+1, sizeof(em_hdr), &em_hdr); |
457 | 457 | ||
458 | if (em->ops && em->ops->dump) { | 458 | if (em->ops && em->ops->dump) { |
459 | if (em->ops->dump(skb, em) < 0) | 459 | if (em->ops->dump(skb, em) < 0) |
460 | goto rtattr_failure; | 460 | goto nla_put_failure; |
461 | } else if (tcf_em_is_container(em) || tcf_em_is_simple(em)) { | 461 | } else if (tcf_em_is_container(em) || tcf_em_is_simple(em)) { |
462 | u32 u = em->data; | 462 | u32 u = em->data; |
463 | RTA_PUT_NOHDR(skb, sizeof(u), &u); | 463 | nla_put_nohdr(skb, sizeof(u), &u); |
464 | } else if (em->datalen > 0) | 464 | } else if (em->datalen > 0) |
465 | RTA_PUT_NOHDR(skb, em->datalen, (void *) em->data); | 465 | nla_put_nohdr(skb, em->datalen, (void *) em->data); |
466 | 466 | ||
467 | tail = skb_tail_pointer(skb); | 467 | tail = skb_tail_pointer(skb); |
468 | match_start->rta_len = tail - (u8 *)match_start; | 468 | match_start->nla_len = tail - (u8 *)match_start; |
469 | } | 469 | } |
470 | 470 | ||
471 | list_start->rta_len = tail - (u8 *)list_start; | 471 | list_start->nla_len = tail - (u8 *)list_start; |
472 | top_start->rta_len = tail - (u8 *)top_start; | 472 | top_start->nla_len = tail - (u8 *)top_start; |
473 | 473 | ||
474 | return 0; | 474 | return 0; |
475 | 475 | ||
476 | rtattr_failure: | 476 | nla_put_failure: |
477 | return -1; | 477 | return -1; |
478 | } | 478 | } |
479 | EXPORT_SYMBOL(tcf_em_tree_dump); | 479 | EXPORT_SYMBOL(tcf_em_tree_dump); |