diff options
Diffstat (limited to 'net/sched/act_police.c')
-rw-r--r-- | net/sched/act_police.c | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 616f465f407e..d20403890877 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c | |||
@@ -10,25 +10,15 @@ | |||
10 | * J Hadi Salim (action changes) | 10 | * J Hadi Salim (action changes) |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <asm/uaccess.h> | ||
14 | #include <asm/system.h> | ||
15 | #include <linux/bitops.h> | ||
16 | #include <linux/module.h> | 13 | #include <linux/module.h> |
17 | #include <linux/types.h> | 14 | #include <linux/types.h> |
18 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
19 | #include <linux/string.h> | 16 | #include <linux/string.h> |
20 | #include <linux/mm.h> | ||
21 | #include <linux/socket.h> | ||
22 | #include <linux/sockios.h> | ||
23 | #include <linux/in.h> | ||
24 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
25 | #include <linux/interrupt.h> | ||
26 | #include <linux/netdevice.h> | ||
27 | #include <linux/skbuff.h> | 18 | #include <linux/skbuff.h> |
28 | #include <linux/module.h> | 19 | #include <linux/module.h> |
29 | #include <linux/rtnetlink.h> | 20 | #include <linux/rtnetlink.h> |
30 | #include <linux/init.h> | 21 | #include <linux/init.h> |
31 | #include <net/sock.h> | ||
32 | #include <net/act_api.h> | 22 | #include <net/act_api.h> |
33 | #include <net/netlink.h> | 23 | #include <net/netlink.h> |
34 | 24 | ||
@@ -118,10 +108,8 @@ void tcf_police_destroy(struct tcf_police *p) | |||
118 | write_lock_bh(&police_lock); | 108 | write_lock_bh(&police_lock); |
119 | *p1p = p->tcf_next; | 109 | *p1p = p->tcf_next; |
120 | write_unlock_bh(&police_lock); | 110 | write_unlock_bh(&police_lock); |
121 | #ifdef CONFIG_NET_ESTIMATOR | ||
122 | gen_kill_estimator(&p->tcf_bstats, | 111 | gen_kill_estimator(&p->tcf_bstats, |
123 | &p->tcf_rate_est); | 112 | &p->tcf_rate_est); |
124 | #endif | ||
125 | if (p->tcfp_R_tab) | 113 | if (p->tcfp_R_tab) |
126 | qdisc_put_rtab(p->tcfp_R_tab); | 114 | qdisc_put_rtab(p->tcfp_R_tab); |
127 | if (p->tcfp_P_tab) | 115 | if (p->tcfp_P_tab) |
@@ -185,7 +173,6 @@ static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est, | |||
185 | ret = ACT_P_CREATED; | 173 | ret = ACT_P_CREATED; |
186 | police->tcf_refcnt = 1; | 174 | police->tcf_refcnt = 1; |
187 | spin_lock_init(&police->tcf_lock); | 175 | spin_lock_init(&police->tcf_lock); |
188 | police->tcf_stats_lock = &police->tcf_lock; | ||
189 | if (bind) | 176 | if (bind) |
190 | police->tcf_bindcnt = 1; | 177 | police->tcf_bindcnt = 1; |
191 | override: | 178 | override: |
@@ -227,15 +214,13 @@ override: | |||
227 | police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); | 214 | police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); |
228 | police->tcf_action = parm->action; | 215 | police->tcf_action = parm->action; |
229 | 216 | ||
230 | #ifdef CONFIG_NET_ESTIMATOR | ||
231 | if (tb[TCA_POLICE_AVRATE-1]) | 217 | if (tb[TCA_POLICE_AVRATE-1]) |
232 | police->tcfp_ewma_rate = | 218 | police->tcfp_ewma_rate = |
233 | *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]); | 219 | *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]); |
234 | if (est) | 220 | if (est) |
235 | gen_replace_estimator(&police->tcf_bstats, | 221 | gen_replace_estimator(&police->tcf_bstats, |
236 | &police->tcf_rate_est, | 222 | &police->tcf_rate_est, |
237 | police->tcf_stats_lock, est); | 223 | &police->tcf_lock, est); |
238 | #endif | ||
239 | 224 | ||
240 | spin_unlock_bh(&police->tcf_lock); | 225 | spin_unlock_bh(&police->tcf_lock); |
241 | if (ret != ACT_P_CREATED) | 226 | if (ret != ACT_P_CREATED) |
@@ -281,14 +266,12 @@ static int tcf_act_police(struct sk_buff *skb, struct tc_action *a, | |||
281 | police->tcf_bstats.bytes += skb->len; | 266 | police->tcf_bstats.bytes += skb->len; |
282 | police->tcf_bstats.packets++; | 267 | police->tcf_bstats.packets++; |
283 | 268 | ||
284 | #ifdef CONFIG_NET_ESTIMATOR | ||
285 | if (police->tcfp_ewma_rate && | 269 | if (police->tcfp_ewma_rate && |
286 | police->tcf_rate_est.bps >= police->tcfp_ewma_rate) { | 270 | police->tcf_rate_est.bps >= police->tcfp_ewma_rate) { |
287 | police->tcf_qstats.overlimits++; | 271 | police->tcf_qstats.overlimits++; |
288 | spin_unlock(&police->tcf_lock); | 272 | spin_unlock(&police->tcf_lock); |
289 | return police->tcf_action; | 273 | return police->tcf_action; |
290 | } | 274 | } |
291 | #endif | ||
292 | 275 | ||
293 | if (skb->len <= police->tcfp_mtu) { | 276 | if (skb->len <= police->tcfp_mtu) { |
294 | if (police->tcfp_R_tab == NULL) { | 277 | if (police->tcfp_R_tab == NULL) { |
@@ -348,10 +331,8 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) | |||
348 | if (police->tcfp_result) | 331 | if (police->tcfp_result) |
349 | RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int), | 332 | RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int), |
350 | &police->tcfp_result); | 333 | &police->tcfp_result); |
351 | #ifdef CONFIG_NET_ESTIMATOR | ||
352 | if (police->tcfp_ewma_rate) | 334 | if (police->tcfp_ewma_rate) |
353 | RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate); | 335 | RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate); |
354 | #endif | ||
355 | return skb->len; | 336 | return skb->len; |
356 | 337 | ||
357 | rtattr_failure: | 338 | rtattr_failure: |
@@ -458,7 +439,6 @@ struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est) | |||
458 | 439 | ||
459 | police->tcf_refcnt = 1; | 440 | police->tcf_refcnt = 1; |
460 | spin_lock_init(&police->tcf_lock); | 441 | spin_lock_init(&police->tcf_lock); |
461 | police->tcf_stats_lock = &police->tcf_lock; | ||
462 | if (parm->rate.rate) { | 442 | if (parm->rate.rate) { |
463 | police->tcfp_R_tab = | 443 | police->tcfp_R_tab = |
464 | qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE-1]); | 444 | qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE-1]); |
@@ -477,14 +457,12 @@ struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est) | |||
477 | goto failure; | 457 | goto failure; |
478 | police->tcfp_result = *(u32*)RTA_DATA(tb[TCA_POLICE_RESULT-1]); | 458 | police->tcfp_result = *(u32*)RTA_DATA(tb[TCA_POLICE_RESULT-1]); |
479 | } | 459 | } |
480 | #ifdef CONFIG_NET_ESTIMATOR | ||
481 | if (tb[TCA_POLICE_AVRATE-1]) { | 460 | if (tb[TCA_POLICE_AVRATE-1]) { |
482 | if (RTA_PAYLOAD(tb[TCA_POLICE_AVRATE-1]) != sizeof(u32)) | 461 | if (RTA_PAYLOAD(tb[TCA_POLICE_AVRATE-1]) != sizeof(u32)) |
483 | goto failure; | 462 | goto failure; |
484 | police->tcfp_ewma_rate = | 463 | police->tcfp_ewma_rate = |
485 | *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]); | 464 | *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]); |
486 | } | 465 | } |
487 | #endif | ||
488 | police->tcfp_toks = police->tcfp_burst = parm->burst; | 466 | police->tcfp_toks = police->tcfp_burst = parm->burst; |
489 | police->tcfp_mtu = parm->mtu; | 467 | police->tcfp_mtu = parm->mtu; |
490 | if (police->tcfp_mtu == 0) { | 468 | if (police->tcfp_mtu == 0) { |
@@ -498,11 +476,9 @@ struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est) | |||
498 | police->tcf_index = parm->index ? parm->index : | 476 | police->tcf_index = parm->index ? parm->index : |
499 | tcf_police_new_index(); | 477 | tcf_police_new_index(); |
500 | police->tcf_action = parm->action; | 478 | police->tcf_action = parm->action; |
501 | #ifdef CONFIG_NET_ESTIMATOR | ||
502 | if (est) | 479 | if (est) |
503 | gen_new_estimator(&police->tcf_bstats, &police->tcf_rate_est, | 480 | gen_new_estimator(&police->tcf_bstats, &police->tcf_rate_est, |
504 | police->tcf_stats_lock, est); | 481 | &police->tcf_lock, est); |
505 | #endif | ||
506 | h = tcf_hash(police->tcf_index, POL_TAB_MASK); | 482 | h = tcf_hash(police->tcf_index, POL_TAB_MASK); |
507 | write_lock_bh(&police_lock); | 483 | write_lock_bh(&police_lock); |
508 | police->tcf_next = tcf_police_ht[h]; | 484 | police->tcf_next = tcf_police_ht[h]; |
@@ -528,14 +504,12 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *police) | |||
528 | police->tcf_bstats.bytes += skb->len; | 504 | police->tcf_bstats.bytes += skb->len; |
529 | police->tcf_bstats.packets++; | 505 | police->tcf_bstats.packets++; |
530 | 506 | ||
531 | #ifdef CONFIG_NET_ESTIMATOR | ||
532 | if (police->tcfp_ewma_rate && | 507 | if (police->tcfp_ewma_rate && |
533 | police->tcf_rate_est.bps >= police->tcfp_ewma_rate) { | 508 | police->tcf_rate_est.bps >= police->tcfp_ewma_rate) { |
534 | police->tcf_qstats.overlimits++; | 509 | police->tcf_qstats.overlimits++; |
535 | spin_unlock(&police->tcf_lock); | 510 | spin_unlock(&police->tcf_lock); |
536 | return police->tcf_action; | 511 | return police->tcf_action; |
537 | } | 512 | } |
538 | #endif | ||
539 | if (skb->len <= police->tcfp_mtu) { | 513 | if (skb->len <= police->tcfp_mtu) { |
540 | if (police->tcfp_R_tab == NULL) { | 514 | if (police->tcfp_R_tab == NULL) { |
541 | spin_unlock(&police->tcf_lock); | 515 | spin_unlock(&police->tcf_lock); |
@@ -591,10 +565,8 @@ int tcf_police_dump(struct sk_buff *skb, struct tcf_police *police) | |||
591 | if (police->tcfp_result) | 565 | if (police->tcfp_result) |
592 | RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int), | 566 | RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int), |
593 | &police->tcfp_result); | 567 | &police->tcfp_result); |
594 | #ifdef CONFIG_NET_ESTIMATOR | ||
595 | if (police->tcfp_ewma_rate) | 568 | if (police->tcfp_ewma_rate) |
596 | RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate); | 569 | RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate); |
597 | #endif | ||
598 | return skb->len; | 570 | return skb->len; |
599 | 571 | ||
600 | rtattr_failure: | 572 | rtattr_failure: |
@@ -607,14 +579,12 @@ int tcf_police_dump_stats(struct sk_buff *skb, struct tcf_police *police) | |||
607 | struct gnet_dump d; | 579 | struct gnet_dump d; |
608 | 580 | ||
609 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, | 581 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, |
610 | TCA_XSTATS, police->tcf_stats_lock, | 582 | TCA_XSTATS, &police->tcf_lock, |
611 | &d) < 0) | 583 | &d) < 0) |
612 | goto errout; | 584 | goto errout; |
613 | 585 | ||
614 | if (gnet_stats_copy_basic(&d, &police->tcf_bstats) < 0 || | 586 | if (gnet_stats_copy_basic(&d, &police->tcf_bstats) < 0 || |
615 | #ifdef CONFIG_NET_ESTIMATOR | ||
616 | gnet_stats_copy_rate_est(&d, &police->tcf_rate_est) < 0 || | 587 | gnet_stats_copy_rate_est(&d, &police->tcf_rate_est) < 0 || |
617 | #endif | ||
618 | gnet_stats_copy_queue(&d, &police->tcf_qstats) < 0) | 588 | gnet_stats_copy_queue(&d, &police->tcf_qstats) < 0) |
619 | goto errout; | 589 | goto errout; |
620 | 590 | ||