diff options
Diffstat (limited to 'net/sched/sch_netem.c')
-rw-r--r-- | net/sched/sch_netem.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index c5ea40c9eb2..13c4821e42b 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -82,6 +82,12 @@ struct netem_skb_cb { | |||
82 | psched_time_t time_to_send; | 82 | psched_time_t time_to_send; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb) | ||
86 | { | ||
87 | BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct netem_skb_cb)); | ||
88 | return (struct netem_skb_cb *)skb->cb; | ||
89 | } | ||
90 | |||
85 | /* init_crandom - initialize correlated random number generator | 91 | /* init_crandom - initialize correlated random number generator |
86 | * Use entropy source for initial seed. | 92 | * Use entropy source for initial seed. |
87 | */ | 93 | */ |
@@ -184,7 +190,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
184 | u32 dupsave = q->duplicate; /* prevent duplicating a dup... */ | 190 | u32 dupsave = q->duplicate; /* prevent duplicating a dup... */ |
185 | q->duplicate = 0; | 191 | q->duplicate = 0; |
186 | 192 | ||
187 | rootq->enqueue(skb2, rootq); | 193 | qdisc_enqueue_root(skb2, rootq); |
188 | q->duplicate = dupsave; | 194 | q->duplicate = dupsave; |
189 | } | 195 | } |
190 | 196 | ||
@@ -205,7 +211,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
205 | skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); | 211 | skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); |
206 | } | 212 | } |
207 | 213 | ||
208 | cb = (struct netem_skb_cb *)skb->cb; | 214 | cb = netem_skb_cb(skb); |
209 | if (q->gap == 0 /* not doing reordering */ | 215 | if (q->gap == 0 /* not doing reordering */ |
210 | || q->counter < q->gap /* inside last reordering gap */ | 216 | || q->counter < q->gap /* inside last reordering gap */ |
211 | || q->reorder < get_crandom(&q->reorder_cor)) { | 217 | || q->reorder < get_crandom(&q->reorder_cor)) { |
@@ -218,7 +224,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
218 | now = psched_get_time(); | 224 | now = psched_get_time(); |
219 | cb->time_to_send = now + delay; | 225 | cb->time_to_send = now + delay; |
220 | ++q->counter; | 226 | ++q->counter; |
221 | ret = q->qdisc->enqueue(skb, q->qdisc); | 227 | ret = qdisc_enqueue(skb, q->qdisc); |
222 | } else { | 228 | } else { |
223 | /* | 229 | /* |
224 | * Do re-ordering by putting one out of N packets at the front | 230 | * Do re-ordering by putting one out of N packets at the front |
@@ -277,8 +283,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch) | |||
277 | 283 | ||
278 | skb = q->qdisc->dequeue(q->qdisc); | 284 | skb = q->qdisc->dequeue(q->qdisc); |
279 | if (skb) { | 285 | if (skb) { |
280 | const struct netem_skb_cb *cb | 286 | const struct netem_skb_cb *cb = netem_skb_cb(skb); |
281 | = (const struct netem_skb_cb *)skb->cb; | ||
282 | psched_time_t now = psched_get_time(); | 287 | psched_time_t now = psched_get_time(); |
283 | 288 | ||
284 | /* if more time remaining? */ | 289 | /* if more time remaining? */ |
@@ -457,7 +462,7 @@ static int tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch) | |||
457 | { | 462 | { |
458 | struct fifo_sched_data *q = qdisc_priv(sch); | 463 | struct fifo_sched_data *q = qdisc_priv(sch); |
459 | struct sk_buff_head *list = &sch->q; | 464 | struct sk_buff_head *list = &sch->q; |
460 | psched_time_t tnext = ((struct netem_skb_cb *)nskb->cb)->time_to_send; | 465 | psched_time_t tnext = netem_skb_cb(nskb)->time_to_send; |
461 | struct sk_buff *skb; | 466 | struct sk_buff *skb; |
462 | 467 | ||
463 | if (likely(skb_queue_len(list) < q->limit)) { | 468 | if (likely(skb_queue_len(list) < q->limit)) { |
@@ -468,8 +473,7 @@ static int tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch) | |||
468 | } | 473 | } |
469 | 474 | ||
470 | skb_queue_reverse_walk(list, skb) { | 475 | skb_queue_reverse_walk(list, skb) { |
471 | const struct netem_skb_cb *cb | 476 | const struct netem_skb_cb *cb = netem_skb_cb(skb); |
472 | = (const struct netem_skb_cb *)skb->cb; | ||
473 | 477 | ||
474 | if (tnext >= cb->time_to_send) | 478 | if (tnext >= cb->time_to_send) |
475 | break; | 479 | break; |