aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_police.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/act_police.c')
-rw-r--r--net/sched/act_police.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 10a5a5c36f76..616f465f407e 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <net/sock.h> 31#include <net/sock.h>
32#include <net/act_api.h> 32#include <net/act_api.h>
33#include <net/netlink.h>
33 34
34#define L2T(p,L) ((p)->tcfp_R_tab->data[(L)>>(p)->tcfp_R_tab->rate.cell_log]) 35#define L2T(p,L) ((p)->tcfp_R_tab->data[(L)>>(p)->tcfp_R_tab->rate.cell_log])
35#define L2T_P(p,L) ((p)->tcfp_P_tab->data[(L)>>(p)->tcfp_P_tab->rate.cell_log]) 36#define L2T_P(p,L) ((p)->tcfp_P_tab->data[(L)>>(p)->tcfp_P_tab->rate.cell_log])
@@ -80,7 +81,7 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
80 continue; 81 continue;
81 a->priv = p; 82 a->priv = p;
82 a->order = index; 83 a->order = index;
83 r = (struct rtattr*) skb->tail; 84 r = (struct rtattr *)skb_tail_pointer(skb);
84 RTA_PUT(skb, a->order, 0, NULL); 85 RTA_PUT(skb, a->order, 0, NULL);
85 if (type == RTM_DELACTION) 86 if (type == RTM_DELACTION)
86 err = tcf_action_dump_1(skb, a, 0, 1); 87 err = tcf_action_dump_1(skb, a, 0, 1);
@@ -88,10 +89,10 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
88 err = tcf_action_dump_1(skb, a, 0, 0); 89 err = tcf_action_dump_1(skb, a, 0, 0);
89 if (err < 0) { 90 if (err < 0) {
90 index--; 91 index--;
91 skb_trim(skb, (u8*)r - skb->data); 92 nlmsg_trim(skb, r);
92 goto done; 93 goto done;
93 } 94 }
94 r->rta_len = skb->tail - (u8*)r; 95 r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
95 n_i++; 96 n_i++;
96 } 97 }
97 } 98 }
@@ -102,7 +103,7 @@ done:
102 return n_i; 103 return n_i;
103 104
104rtattr_failure: 105rtattr_failure:
105 skb_trim(skb, (u8*)r - skb->data); 106 nlmsg_trim(skb, r);
106 goto done; 107 goto done;
107} 108}
108#endif 109#endif
@@ -240,7 +241,7 @@ override:
240 if (ret != ACT_P_CREATED) 241 if (ret != ACT_P_CREATED)
241 return ret; 242 return ret;
242 243
243 PSCHED_GET_TIME(police->tcfp_t_c); 244 police->tcfp_t_c = psched_get_time();
244 police->tcf_index = parm->index ? parm->index : 245 police->tcf_index = parm->index ? parm->index :
245 tcf_hash_new_index(&police_idx_gen, &police_hash_info); 246 tcf_hash_new_index(&police_idx_gen, &police_hash_info);
246 h = tcf_hash(police->tcf_index, POL_TAB_MASK); 247 h = tcf_hash(police->tcf_index, POL_TAB_MASK);
@@ -295,10 +296,9 @@ static int tcf_act_police(struct sk_buff *skb, struct tc_action *a,
295 return police->tcfp_result; 296 return police->tcfp_result;
296 } 297 }
297 298
298 PSCHED_GET_TIME(now); 299 now = psched_get_time();
299 300 toks = psched_tdiff_bounded(now, police->tcfp_t_c,
300 toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c, 301 police->tcfp_burst);
301 police->tcfp_burst);
302 if (police->tcfp_P_tab) { 302 if (police->tcfp_P_tab) {
303 ptoks = toks + police->tcfp_ptoks; 303 ptoks = toks + police->tcfp_ptoks;
304 if (ptoks > (long)L2T_P(police, police->tcfp_mtu)) 304 if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
@@ -326,7 +326,7 @@ static int tcf_act_police(struct sk_buff *skb, struct tc_action *a,
326static int 326static int
327tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref) 327tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
328{ 328{
329 unsigned char *b = skb->tail; 329 unsigned char *b = skb_tail_pointer(skb);
330 struct tcf_police *police = a->priv; 330 struct tcf_police *police = a->priv;
331 struct tc_police opt; 331 struct tc_police opt;
332 332
@@ -355,7 +355,7 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
355 return skb->len; 355 return skb->len;
356 356
357rtattr_failure: 357rtattr_failure:
358 skb_trim(skb, b - skb->data); 358 nlmsg_trim(skb, b);
359 return -1; 359 return -1;
360} 360}
361 361
@@ -494,7 +494,7 @@ struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est)
494 } 494 }
495 if (police->tcfp_P_tab) 495 if (police->tcfp_P_tab)
496 police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); 496 police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu);
497 PSCHED_GET_TIME(police->tcfp_t_c); 497 police->tcfp_t_c = psched_get_time();
498 police->tcf_index = parm->index ? parm->index : 498 police->tcf_index = parm->index ? parm->index :
499 tcf_police_new_index(); 499 tcf_police_new_index();
500 police->tcf_action = parm->action; 500 police->tcf_action = parm->action;
@@ -542,9 +542,9 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *police)
542 return police->tcfp_result; 542 return police->tcfp_result;
543 } 543 }
544 544
545 PSCHED_GET_TIME(now); 545 now = psched_get_time();
546 toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c, 546 toks = psched_tdiff_bounded(now, police->tcfp_t_c,
547 police->tcfp_burst); 547 police->tcfp_burst);
548 if (police->tcfp_P_tab) { 548 if (police->tcfp_P_tab) {
549 ptoks = toks + police->tcfp_ptoks; 549 ptoks = toks + police->tcfp_ptoks;
550 if (ptoks > (long)L2T_P(police, police->tcfp_mtu)) 550 if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
@@ -572,7 +572,7 @@ EXPORT_SYMBOL(tcf_police);
572 572
573int tcf_police_dump(struct sk_buff *skb, struct tcf_police *police) 573int tcf_police_dump(struct sk_buff *skb, struct tcf_police *police)
574{ 574{
575 unsigned char *b = skb->tail; 575 unsigned char *b = skb_tail_pointer(skb);
576 struct tc_police opt; 576 struct tc_police opt;
577 577
578 opt.index = police->tcf_index; 578 opt.index = police->tcf_index;
@@ -598,7 +598,7 @@ int tcf_police_dump(struct sk_buff *skb, struct tcf_police *police)
598 return skb->len; 598 return skb->len;
599 599
600rtattr_failure: 600rtattr_failure:
601 skb_trim(skb, b - skb->data); 601 nlmsg_trim(skb, b);
602 return -1; 602 return -1;
603} 603}
604 604