aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2013-12-15 23:15:07 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-18 12:52:07 -0500
commit5da57f422d89c504a1d72dadd4e19d3dca8e974e (patch)
treee67d0f6b9f50c60707a26c58b0937e6fd6eef22d /net
parent33be627159913b094bb578e83e9a7fdc66c10208 (diff)
net_sched: cls: refactor out struct tcf_ext_map
These information can be saved in tcf_exts, and this will simplify the code. Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/sched/cls_api.c31
-rw-r--r--net/sched/cls_basic.c14
-rw-r--r--net/sched/cls_bpf.c14
-rw-r--r--net/sched/cls_cgroup.c15
-rw-r--r--net/sched/cls_flow.c14
-rw-r--r--net/sched/cls_fw.c14
-rw-r--r--net/sched/cls_route.c14
-rw-r--r--net/sched/cls_rsvp.h14
-rw-r--r--net/sched/cls_tcindex.c16
-rw-r--r--net/sched/cls_u32.c14
10 files changed, 59 insertions, 101 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 3c056d73d394..028c980ef87d 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -507,18 +507,15 @@ void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts)
507EXPORT_SYMBOL(tcf_exts_destroy); 507EXPORT_SYMBOL(tcf_exts_destroy);
508 508
509int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, 509int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
510 struct nlattr *rate_tlv, struct tcf_exts *exts, 510 struct nlattr *rate_tlv, struct tcf_exts *exts)
511 const struct tcf_ext_map *map)
512{ 511{
513 memset(exts, 0, sizeof(*exts));
514
515#ifdef CONFIG_NET_CLS_ACT 512#ifdef CONFIG_NET_CLS_ACT
516 { 513 {
517 struct tc_action *act; 514 struct tc_action *act;
518 515
519 INIT_LIST_HEAD(&exts->actions); 516 INIT_LIST_HEAD(&exts->actions);
520 if (map->police && tb[map->police]) { 517 if (exts->police && tb[exts->police]) {
521 act = tcf_action_init_1(net, tb[map->police], rate_tlv, 518 act = tcf_action_init_1(net, tb[exts->police], rate_tlv,
522 "police", TCA_ACT_NOREPLACE, 519 "police", TCA_ACT_NOREPLACE,
523 TCA_ACT_BIND); 520 TCA_ACT_BIND);
524 if (IS_ERR(act)) 521 if (IS_ERR(act))
@@ -526,9 +523,9 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
526 523
527 act->type = exts->type = TCA_OLD_COMPAT; 524 act->type = exts->type = TCA_OLD_COMPAT;
528 list_add(&act->list, &exts->actions); 525 list_add(&act->list, &exts->actions);
529 } else if (map->action && tb[map->action]) { 526 } else if (exts->action && tb[exts->action]) {
530 int err; 527 int err;
531 err = tcf_action_init(net, tb[map->action], rate_tlv, 528 err = tcf_action_init(net, tb[exts->action], rate_tlv,
532 NULL, TCA_ACT_NOREPLACE, 529 NULL, TCA_ACT_NOREPLACE,
533 TCA_ACT_BIND, &exts->actions); 530 TCA_ACT_BIND, &exts->actions);
534 if (err) 531 if (err)
@@ -536,8 +533,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
536 } 533 }
537 } 534 }
538#else 535#else
539 if ((map->action && tb[map->action]) || 536 if ((exts->action && tb[exts->action]) ||
540 (map->police && tb[map->police])) 537 (exts->police && tb[exts->police]))
541 return -EOPNOTSUPP; 538 return -EOPNOTSUPP;
542#endif 539#endif
543 540
@@ -564,11 +561,10 @@ EXPORT_SYMBOL(tcf_exts_change);
564#define tcf_exts_first_act(ext) \ 561#define tcf_exts_first_act(ext) \
565 list_first_entry(&(exts)->actions, struct tc_action, list) 562 list_first_entry(&(exts)->actions, struct tc_action, list)
566 563
567int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts, 564int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts)
568 const struct tcf_ext_map *map)
569{ 565{
570#ifdef CONFIG_NET_CLS_ACT 566#ifdef CONFIG_NET_CLS_ACT
571 if (map->action && !list_empty(&exts->actions)) { 567 if (exts->action && !list_empty(&exts->actions)) {
572 /* 568 /*
573 * again for backward compatible mode - we want 569 * again for backward compatible mode - we want
574 * to work with both old and new modes of entering 570 * to work with both old and new modes of entering
@@ -576,15 +572,15 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
576 */ 572 */
577 struct nlattr *nest; 573 struct nlattr *nest;
578 if (exts->type != TCA_OLD_COMPAT) { 574 if (exts->type != TCA_OLD_COMPAT) {
579 nest = nla_nest_start(skb, map->action); 575 nest = nla_nest_start(skb, exts->action);
580 if (nest == NULL) 576 if (nest == NULL)
581 goto nla_put_failure; 577 goto nla_put_failure;
582 if (tcf_action_dump(skb, &exts->actions, 0, 0) < 0) 578 if (tcf_action_dump(skb, &exts->actions, 0, 0) < 0)
583 goto nla_put_failure; 579 goto nla_put_failure;
584 nla_nest_end(skb, nest); 580 nla_nest_end(skb, nest);
585 } else if (map->police) { 581 } else if (exts->police) {
586 struct tc_action *act = tcf_exts_first_act(exts); 582 struct tc_action *act = tcf_exts_first_act(exts);
587 nest = nla_nest_start(skb, map->police); 583 nest = nla_nest_start(skb, exts->police);
588 if (nest == NULL) 584 if (nest == NULL)
589 goto nla_put_failure; 585 goto nla_put_failure;
590 if (tcf_action_dump_old(skb, act, 0, 0) < 0) 586 if (tcf_action_dump_old(skb, act, 0, 0) < 0)
@@ -600,8 +596,7 @@ nla_put_failure: __attribute__ ((unused))
600EXPORT_SYMBOL(tcf_exts_dump); 596EXPORT_SYMBOL(tcf_exts_dump);
601 597
602 598
603int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts, 599int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts)
604 const struct tcf_ext_map *map)
605{ 600{
606#ifdef CONFIG_NET_CLS_ACT 601#ifdef CONFIG_NET_CLS_ACT
607 struct tc_action *a = tcf_exts_first_act(exts); 602 struct tc_action *a = tcf_exts_first_act(exts);
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index 7b9b4602b5b7..b6552035d1f4 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -34,11 +34,6 @@ struct basic_filter {
34 struct list_head link; 34 struct list_head link;
35}; 35};
36 36
37static const struct tcf_ext_map basic_ext_map = {
38 .action = TCA_BASIC_ACT,
39 .police = TCA_BASIC_POLICE
40};
41
42static int basic_classify(struct sk_buff *skb, const struct tcf_proto *tp, 37static int basic_classify(struct sk_buff *skb, const struct tcf_proto *tp,
43 struct tcf_result *res) 38 struct tcf_result *res)
44{ 39{
@@ -141,7 +136,8 @@ static int basic_set_parms(struct net *net, struct tcf_proto *tp,
141 struct tcf_exts e; 136 struct tcf_exts e;
142 struct tcf_ematch_tree t; 137 struct tcf_ematch_tree t;
143 138
144 err = tcf_exts_validate(net, tp, tb, est, &e, &basic_ext_map); 139 tcf_exts_init(&e, TCA_BASIC_ACT, TCA_BASIC_POLICE);
140 err = tcf_exts_validate(net, tp, tb, est, &e);
145 if (err < 0) 141 if (err < 0)
146 return err; 142 return err;
147 143
@@ -191,7 +187,7 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
191 if (f == NULL) 187 if (f == NULL)
192 goto errout; 188 goto errout;
193 189
194 tcf_exts_init(&f->exts); 190 tcf_exts_init(&f->exts, TCA_BASIC_ACT, TCA_BASIC_POLICE);
195 err = -EINVAL; 191 err = -EINVAL;
196 if (handle) 192 if (handle)
197 f->handle = handle; 193 f->handle = handle;
@@ -264,13 +260,13 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh,
264 nla_put_u32(skb, TCA_BASIC_CLASSID, f->res.classid)) 260 nla_put_u32(skb, TCA_BASIC_CLASSID, f->res.classid))
265 goto nla_put_failure; 261 goto nla_put_failure;
266 262
267 if (tcf_exts_dump(skb, &f->exts, &basic_ext_map) < 0 || 263 if (tcf_exts_dump(skb, &f->exts) < 0 ||
268 tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0) 264 tcf_em_tree_dump(skb, &f->ematches, TCA_BASIC_EMATCHES) < 0)
269 goto nla_put_failure; 265 goto nla_put_failure;
270 266
271 nla_nest_end(skb, nest); 267 nla_nest_end(skb, nest);
272 268
273 if (tcf_exts_dump_stats(skb, &f->exts, &basic_ext_map) < 0) 269 if (tcf_exts_dump_stats(skb, &f->exts) < 0)
274 goto nla_put_failure; 270 goto nla_put_failure;
275 271
276 return skb->len; 272 return skb->len;
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 90fe275e580c..00a5a585e5f1 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -46,11 +46,6 @@ static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = {
46 .len = sizeof(struct sock_filter) * BPF_MAXINSNS }, 46 .len = sizeof(struct sock_filter) * BPF_MAXINSNS },
47}; 47};
48 48
49static const struct tcf_ext_map bpf_ext_map = {
50 .action = TCA_BPF_ACT,
51 .police = TCA_BPF_POLICE,
52};
53
54static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp, 49static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
55 struct tcf_result *res) 50 struct tcf_result *res)
56{ 51{
@@ -174,7 +169,8 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
174 if (!tb[TCA_BPF_OPS_LEN] || !tb[TCA_BPF_OPS] || !tb[TCA_BPF_CLASSID]) 169 if (!tb[TCA_BPF_OPS_LEN] || !tb[TCA_BPF_OPS] || !tb[TCA_BPF_CLASSID])
175 return -EINVAL; 170 return -EINVAL;
176 171
177 ret = tcf_exts_validate(net, tp, tb, est, &exts, &bpf_ext_map); 172 tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
173 ret = tcf_exts_validate(net, tp, tb, est, &exts);
178 if (ret < 0) 174 if (ret < 0)
179 return ret; 175 return ret;
180 176
@@ -271,7 +267,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
271 if (prog == NULL) 267 if (prog == NULL)
272 return -ENOBUFS; 268 return -ENOBUFS;
273 269
274 tcf_exts_init(&prog->exts); 270 tcf_exts_init(&prog->exts, TCA_BPF_ACT, TCA_BPF_POLICE);
275 if (handle == 0) 271 if (handle == 0)
276 prog->handle = cls_bpf_grab_new_handle(tp, head); 272 prog->handle = cls_bpf_grab_new_handle(tp, head);
277 else 273 else
@@ -326,12 +322,12 @@ static int cls_bpf_dump(struct tcf_proto *tp, unsigned long fh,
326 322
327 memcpy(nla_data(nla), prog->bpf_ops, nla_len(nla)); 323 memcpy(nla_data(nla), prog->bpf_ops, nla_len(nla));
328 324
329 if (tcf_exts_dump(skb, &prog->exts, &bpf_ext_map) < 0) 325 if (tcf_exts_dump(skb, &prog->exts) < 0)
330 goto nla_put_failure; 326 goto nla_put_failure;
331 327
332 nla_nest_end(skb, nest); 328 nla_nest_end(skb, nest);
333 329
334 if (tcf_exts_dump_stats(skb, &prog->exts, &bpf_ext_map) < 0) 330 if (tcf_exts_dump_stats(skb, &prog->exts) < 0)
335 goto nla_put_failure; 331 goto nla_put_failure;
336 332
337 return skb->len; 333 return skb->len;
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index e4fae032bcfb..f9d212583ea2 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -172,11 +172,6 @@ static int cls_cgroup_init(struct tcf_proto *tp)
172 return 0; 172 return 0;
173} 173}
174 174
175static const struct tcf_ext_map cgroup_ext_map = {
176 .action = TCA_CGROUP_ACT,
177 .police = TCA_CGROUP_POLICE,
178};
179
180static const struct nla_policy cgroup_policy[TCA_CGROUP_MAX + 1] = { 175static const struct nla_policy cgroup_policy[TCA_CGROUP_MAX + 1] = {
181 [TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED }, 176 [TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED },
182}; 177};
@@ -203,7 +198,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
203 if (head == NULL) 198 if (head == NULL)
204 return -ENOBUFS; 199 return -ENOBUFS;
205 200
206 tcf_exts_init(&head->exts); 201 tcf_exts_init(&head->exts, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
207 head->handle = handle; 202 head->handle = handle;
208 203
209 tcf_tree_lock(tp); 204 tcf_tree_lock(tp);
@@ -219,8 +214,8 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
219 if (err < 0) 214 if (err < 0)
220 return err; 215 return err;
221 216
222 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, 217 tcf_exts_init(&e, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
223 &cgroup_ext_map); 218 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e);
224 if (err < 0) 219 if (err < 0)
225 return err; 220 return err;
226 221
@@ -278,13 +273,13 @@ static int cls_cgroup_dump(struct tcf_proto *tp, unsigned long fh,
278 if (nest == NULL) 273 if (nest == NULL)
279 goto nla_put_failure; 274 goto nla_put_failure;
280 275
281 if (tcf_exts_dump(skb, &head->exts, &cgroup_ext_map) < 0 || 276 if (tcf_exts_dump(skb, &head->exts) < 0 ||
282 tcf_em_tree_dump(skb, &head->ematches, TCA_CGROUP_EMATCHES) < 0) 277 tcf_em_tree_dump(skb, &head->ematches, TCA_CGROUP_EMATCHES) < 0)
283 goto nla_put_failure; 278 goto nla_put_failure;
284 279
285 nla_nest_end(skb, nest); 280 nla_nest_end(skb, nest);
286 281
287 if (tcf_exts_dump_stats(skb, &head->exts, &cgroup_ext_map) < 0) 282 if (tcf_exts_dump_stats(skb, &head->exts) < 0)
288 goto nla_put_failure; 283 goto nla_put_failure;
289 284
290 return skb->len; 285 return skb->len;
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index f05904e3848f..dfd18a5c3e81 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -56,11 +56,6 @@ struct flow_filter {
56 u32 hashrnd; 56 u32 hashrnd;
57}; 57};
58 58
59static const struct tcf_ext_map flow_ext_map = {
60 .action = TCA_FLOW_ACT,
61 .police = TCA_FLOW_POLICE,
62};
63
64static inline u32 addr_fold(void *addr) 59static inline u32 addr_fold(void *addr)
65{ 60{
66 unsigned long a = (unsigned long)addr; 61 unsigned long a = (unsigned long)addr;
@@ -397,7 +392,8 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
397 return -EOPNOTSUPP; 392 return -EOPNOTSUPP;
398 } 393 }
399 394
400 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, &flow_ext_map); 395 tcf_exts_init(&e, TCA_FLOW_ACT, TCA_FLOW_POLICE);
396 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e);
401 if (err < 0) 397 if (err < 0)
402 return err; 398 return err;
403 399
@@ -455,7 +451,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
455 451
456 f->handle = handle; 452 f->handle = handle;
457 f->mask = ~0U; 453 f->mask = ~0U;
458 tcf_exts_init(&f->exts); 454 tcf_exts_init(&f->exts, TCA_FLOW_ACT, TCA_FLOW_POLICE);
459 455
460 get_random_bytes(&f->hashrnd, 4); 456 get_random_bytes(&f->hashrnd, 4);
461 f->perturb_timer.function = flow_perturbation; 457 f->perturb_timer.function = flow_perturbation;
@@ -609,7 +605,7 @@ static int flow_dump(struct tcf_proto *tp, unsigned long fh,
609 nla_put_u32(skb, TCA_FLOW_PERTURB, f->perturb_period / HZ)) 605 nla_put_u32(skb, TCA_FLOW_PERTURB, f->perturb_period / HZ))
610 goto nla_put_failure; 606 goto nla_put_failure;
611 607
612 if (tcf_exts_dump(skb, &f->exts, &flow_ext_map) < 0) 608 if (tcf_exts_dump(skb, &f->exts) < 0)
613 goto nla_put_failure; 609 goto nla_put_failure;
614#ifdef CONFIG_NET_EMATCH 610#ifdef CONFIG_NET_EMATCH
615 if (f->ematches.hdr.nmatches && 611 if (f->ematches.hdr.nmatches &&
@@ -618,7 +614,7 @@ static int flow_dump(struct tcf_proto *tp, unsigned long fh,
618#endif 614#endif
619 nla_nest_end(skb, nest); 615 nla_nest_end(skb, nest);
620 616
621 if (tcf_exts_dump_stats(skb, &f->exts, &flow_ext_map) < 0) 617 if (tcf_exts_dump_stats(skb, &f->exts) < 0)
622 goto nla_put_failure; 618 goto nla_put_failure;
623 619
624 return skb->len; 620 return skb->len;
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index d1cebad19410..3f9cece13807 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -46,11 +46,6 @@ struct fw_filter {
46 struct tcf_exts exts; 46 struct tcf_exts exts;
47}; 47};
48 48
49static const struct tcf_ext_map fw_ext_map = {
50 .action = TCA_FW_ACT,
51 .police = TCA_FW_POLICE
52};
53
54static inline int fw_hash(u32 handle) 49static inline int fw_hash(u32 handle)
55{ 50{
56 if (HTSIZE == 4096) 51 if (HTSIZE == 4096)
@@ -200,7 +195,8 @@ fw_change_attrs(struct net *net, struct tcf_proto *tp, struct fw_filter *f,
200 u32 mask; 195 u32 mask;
201 int err; 196 int err;
202 197
203 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, &fw_ext_map); 198 tcf_exts_init(&e, TCA_FW_ACT, TCA_FW_POLICE);
199 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e);
204 if (err < 0) 200 if (err < 0)
205 return err; 201 return err;
206 202
@@ -280,7 +276,7 @@ static int fw_change(struct net *net, struct sk_buff *in_skb,
280 if (f == NULL) 276 if (f == NULL)
281 return -ENOBUFS; 277 return -ENOBUFS;
282 278
283 tcf_exts_init(&f->exts); 279 tcf_exts_init(&f->exts, TCA_FW_ACT, TCA_FW_POLICE);
284 f->id = handle; 280 f->id = handle;
285 281
286 err = fw_change_attrs(net, tp, f, tb, tca, base); 282 err = fw_change_attrs(net, tp, f, tb, tca, base);
@@ -360,12 +356,12 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
360 nla_put_u32(skb, TCA_FW_MASK, head->mask)) 356 nla_put_u32(skb, TCA_FW_MASK, head->mask))
361 goto nla_put_failure; 357 goto nla_put_failure;
362 358
363 if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0) 359 if (tcf_exts_dump(skb, &f->exts) < 0)
364 goto nla_put_failure; 360 goto nla_put_failure;
365 361
366 nla_nest_end(skb, nest); 362 nla_nest_end(skb, nest);
367 363
368 if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0) 364 if (tcf_exts_dump_stats(skb, &f->exts) < 0)
369 goto nla_put_failure; 365 goto nla_put_failure;
370 366
371 return skb->len; 367 return skb->len;
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
index f1f1dfdf4eb3..2473953a5948 100644
--- a/net/sched/cls_route.c
+++ b/net/sched/cls_route.c
@@ -59,11 +59,6 @@ struct route4_filter {
59 59
60#define ROUTE4_FAILURE ((struct route4_filter *)(-1L)) 60#define ROUTE4_FAILURE ((struct route4_filter *)(-1L))
61 61
62static const struct tcf_ext_map route_ext_map = {
63 .police = TCA_ROUTE4_POLICE,
64 .action = TCA_ROUTE4_ACT
65};
66
67static inline int route4_fastmap_hash(u32 id, int iif) 62static inline int route4_fastmap_hash(u32 id, int iif)
68{ 63{
69 return id & 0xF; 64 return id & 0xF;
@@ -347,7 +342,8 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
347 struct route4_bucket *b; 342 struct route4_bucket *b;
348 struct tcf_exts e; 343 struct tcf_exts e;
349 344
350 err = tcf_exts_validate(net, tp, tb, est, &e, &route_ext_map); 345 tcf_exts_init(&e, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE);
346 err = tcf_exts_validate(net, tp, tb, est, &e);
351 if (err < 0) 347 if (err < 0)
352 return err; 348 return err;
353 349
@@ -481,7 +477,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
481 if (f == NULL) 477 if (f == NULL)
482 goto errout; 478 goto errout;
483 479
484 tcf_exts_init(&f->exts); 480 tcf_exts_init(&f->exts, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE);
485 err = route4_set_parms(net, tp, base, f, handle, head, tb, 481 err = route4_set_parms(net, tp, base, f, handle, head, tb,
486 tca[TCA_RATE], 1); 482 tca[TCA_RATE], 1);
487 if (err < 0) 483 if (err < 0)
@@ -590,12 +586,12 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
590 nla_put_u32(skb, TCA_ROUTE4_CLASSID, f->res.classid)) 586 nla_put_u32(skb, TCA_ROUTE4_CLASSID, f->res.classid))
591 goto nla_put_failure; 587 goto nla_put_failure;
592 588
593 if (tcf_exts_dump(skb, &f->exts, &route_ext_map) < 0) 589 if (tcf_exts_dump(skb, &f->exts) < 0)
594 goto nla_put_failure; 590 goto nla_put_failure;
595 591
596 nla_nest_end(skb, nest); 592 nla_nest_end(skb, nest);
597 593
598 if (tcf_exts_dump_stats(skb, &f->exts, &route_ext_map) < 0) 594 if (tcf_exts_dump_stats(skb, &f->exts) < 0)
599 goto nla_put_failure; 595 goto nla_put_failure;
600 596
601 return skb->len; 597 return skb->len;
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
index b1d3ce5c5ff8..4f25c2ac825b 100644
--- a/net/sched/cls_rsvp.h
+++ b/net/sched/cls_rsvp.h
@@ -116,11 +116,6 @@ static inline unsigned int hash_src(__be32 *src)
116 return h & 0xF; 116 return h & 0xF;
117} 117}
118 118
119static struct tcf_ext_map rsvp_ext_map = {
120 .police = TCA_RSVP_POLICE,
121 .action = TCA_RSVP_ACT
122};
123
124#define RSVP_APPLY_RESULT() \ 119#define RSVP_APPLY_RESULT() \
125{ \ 120{ \
126 int r = tcf_exts_exec(skb, &f->exts, res); \ 121 int r = tcf_exts_exec(skb, &f->exts, res); \
@@ -440,7 +435,8 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
440 if (err < 0) 435 if (err < 0)
441 return err; 436 return err;
442 437
443 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, &rsvp_ext_map); 438 tcf_exts_init(&e, TCA_RSVP_ACT, TCA_RSVP_POLICE);
439 err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e);
444 if (err < 0) 440 if (err < 0)
445 return err; 441 return err;
446 442
@@ -471,7 +467,7 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
471 if (f == NULL) 467 if (f == NULL)
472 goto errout2; 468 goto errout2;
473 469
474 tcf_exts_init(&f->exts); 470 tcf_exts_init(&f->exts, TCA_RSVP_ACT, TCA_RSVP_POLICE);
475 h2 = 16; 471 h2 = 16;
476 if (tb[TCA_RSVP_SRC]) { 472 if (tb[TCA_RSVP_SRC]) {
477 memcpy(f->src, nla_data(tb[TCA_RSVP_SRC]), sizeof(f->src)); 473 memcpy(f->src, nla_data(tb[TCA_RSVP_SRC]), sizeof(f->src));
@@ -634,12 +630,12 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh,
634 nla_put(skb, TCA_RSVP_SRC, sizeof(f->src), f->src)) 630 nla_put(skb, TCA_RSVP_SRC, sizeof(f->src), f->src))
635 goto nla_put_failure; 631 goto nla_put_failure;
636 632
637 if (tcf_exts_dump(skb, &f->exts, &rsvp_ext_map) < 0) 633 if (tcf_exts_dump(skb, &f->exts) < 0)
638 goto nla_put_failure; 634 goto nla_put_failure;
639 635
640 nla_nest_end(skb, nest); 636 nla_nest_end(skb, nest);
641 637
642 if (tcf_exts_dump_stats(skb, &f->exts, &rsvp_ext_map) < 0) 638 if (tcf_exts_dump_stats(skb, &f->exts) < 0)
643 goto nla_put_failure; 639 goto nla_put_failure;
644 return skb->len; 640 return skb->len;
645 641
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index c39bbfc0300a..ffad18791c93 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -50,11 +50,6 @@ struct tcindex_data {
50 int fall_through; /* 0: only classify if explicit match */ 50 int fall_through; /* 0: only classify if explicit match */
51}; 51};
52 52
53static const struct tcf_ext_map tcindex_ext_map = {
54 .police = TCA_TCINDEX_POLICE,
55 .action = TCA_TCINDEX_ACT
56};
57
58static inline int 53static inline int
59tcindex_filter_is_set(struct tcindex_filter_result *r) 54tcindex_filter_is_set(struct tcindex_filter_result *r)
60{ 55{
@@ -209,19 +204,20 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
209 struct tcindex_filter *f = NULL; /* make gcc behave */ 204 struct tcindex_filter *f = NULL; /* make gcc behave */
210 struct tcf_exts e; 205 struct tcf_exts e;
211 206
212 err = tcf_exts_validate(net, tp, tb, est, &e, &tcindex_ext_map); 207 tcf_exts_init(&e, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
208 err = tcf_exts_validate(net, tp, tb, est, &e);
213 if (err < 0) 209 if (err < 0)
214 return err; 210 return err;
215 211
216 memcpy(&cp, p, sizeof(cp)); 212 memcpy(&cp, p, sizeof(cp));
217 memset(&new_filter_result, 0, sizeof(new_filter_result)); 213 memset(&new_filter_result, 0, sizeof(new_filter_result));
218 tcf_exts_init(&new_filter_result.exts); 214 tcf_exts_init(&new_filter_result.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
219 215
220 if (old_r) 216 if (old_r)
221 memcpy(&cr, r, sizeof(cr)); 217 memcpy(&cr, r, sizeof(cr));
222 else { 218 else {
223 memset(&cr, 0, sizeof(cr)); 219 memset(&cr, 0, sizeof(cr));
224 tcf_exts_init(&cr.exts); 220 tcf_exts_init(&cr.exts, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
225 } 221 }
226 222
227 if (tb[TCA_TCINDEX_HASH]) 223 if (tb[TCA_TCINDEX_HASH])
@@ -471,11 +467,11 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
471 nla_put_u32(skb, TCA_TCINDEX_CLASSID, r->res.classid)) 467 nla_put_u32(skb, TCA_TCINDEX_CLASSID, r->res.classid))
472 goto nla_put_failure; 468 goto nla_put_failure;
473 469
474 if (tcf_exts_dump(skb, &r->exts, &tcindex_ext_map) < 0) 470 if (tcf_exts_dump(skb, &r->exts) < 0)
475 goto nla_put_failure; 471 goto nla_put_failure;
476 nla_nest_end(skb, nest); 472 nla_nest_end(skb, nest);
477 473
478 if (tcf_exts_dump_stats(skb, &r->exts, &tcindex_ext_map) < 0) 474 if (tcf_exts_dump_stats(skb, &r->exts) < 0)
479 goto nla_put_failure; 475 goto nla_put_failure;
480 } 476 }
481 477
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 492d9a6401ce..20f2fb79c747 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -79,11 +79,6 @@ struct tc_u_common {
79 u32 hgenerator; 79 u32 hgenerator;
80}; 80};
81 81
82static const struct tcf_ext_map u32_ext_map = {
83 .action = TCA_U32_ACT,
84 .police = TCA_U32_POLICE
85};
86
87static inline unsigned int u32_hash_fold(__be32 key, 82static inline unsigned int u32_hash_fold(__be32 key,
88 const struct tc_u32_sel *sel, 83 const struct tc_u32_sel *sel,
89 u8 fshift) 84 u8 fshift)
@@ -496,7 +491,8 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp,
496 int err; 491 int err;
497 struct tcf_exts e; 492 struct tcf_exts e;
498 493
499 err = tcf_exts_validate(net, tp, tb, est, &e, &u32_ext_map); 494 tcf_exts_init(&e, TCA_U32_ACT, TCA_U32_POLICE);
495 err = tcf_exts_validate(net, tp, tb, est, &e);
500 if (err < 0) 496 if (err < 0)
501 return err; 497 return err;
502 498
@@ -646,7 +642,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
646 n->ht_up = ht; 642 n->ht_up = ht;
647 n->handle = handle; 643 n->handle = handle;
648 n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; 644 n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0;
649 tcf_exts_init(&n->exts); 645 tcf_exts_init(&n->exts, TCA_U32_ACT, TCA_U32_POLICE);
650 646
651#ifdef CONFIG_CLS_U32_MARK 647#ifdef CONFIG_CLS_U32_MARK
652 if (tb[TCA_U32_MARK]) { 648 if (tb[TCA_U32_MARK]) {
@@ -760,7 +756,7 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
760 goto nla_put_failure; 756 goto nla_put_failure;
761#endif 757#endif
762 758
763 if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) 759 if (tcf_exts_dump(skb, &n->exts) < 0)
764 goto nla_put_failure; 760 goto nla_put_failure;
765 761
766#ifdef CONFIG_NET_CLS_IND 762#ifdef CONFIG_NET_CLS_IND
@@ -779,7 +775,7 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
779 nla_nest_end(skb, nest); 775 nla_nest_end(skb, nest);
780 776
781 if (TC_U32_KEY(n->handle)) 777 if (TC_U32_KEY(n->handle))
782 if (tcf_exts_dump_stats(skb, &n->exts, &u32_ext_map) < 0) 778 if (tcf_exts_dump_stats(skb, &n->exts) < 0)
783 goto nla_put_failure; 779 goto nla_put_failure;
784 return skb->len; 780 return skb->len;
785 781