diff options
author | Aruna-Hewapathirane <aruna.hewapathirane@gmail.com> | 2014-01-11 07:15:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-14 18:15:25 -0500 |
commit | 63862b5bef7349dd1137e4c70702c67d77565785 (patch) | |
tree | ad50ec4a9d67fd025a29093dc5a4b493fe02e8a5 /net/sched/sch_netem.c | |
parent | 825edac4e78ded9e621c167a4f47a2392bd9e082 (diff) |
net: replace macros net_random and net_srandom with direct calls to prandom
This patch removes the net_random and net_srandom macros and replaces
them with direct calls to the prandom ones. As new commits only seem to
use prandom_u32 there is no use to keep them around.
This change makes it easier to grep for users of prandom_u32.
Signed-off-by: Aruna-Hewapathirane <aruna.hewapathirane@gmail.com>
Suggested-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_netem.c')
-rw-r--r-- | net/sched/sch_netem.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 090a4e3ecd0d..3019c10d6c56 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -169,7 +169,7 @@ static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb) | |||
169 | static void init_crandom(struct crndstate *state, unsigned long rho) | 169 | static void init_crandom(struct crndstate *state, unsigned long rho) |
170 | { | 170 | { |
171 | state->rho = rho; | 171 | state->rho = rho; |
172 | state->last = net_random(); | 172 | state->last = prandom_u32(); |
173 | } | 173 | } |
174 | 174 | ||
175 | /* get_crandom - correlated random number generator | 175 | /* get_crandom - correlated random number generator |
@@ -182,9 +182,9 @@ static u32 get_crandom(struct crndstate *state) | |||
182 | unsigned long answer; | 182 | unsigned long answer; |
183 | 183 | ||
184 | if (state->rho == 0) /* no correlation */ | 184 | if (state->rho == 0) /* no correlation */ |
185 | return net_random(); | 185 | return prandom_u32(); |
186 | 186 | ||
187 | value = net_random(); | 187 | value = prandom_u32(); |
188 | rho = (u64)state->rho + 1; | 188 | rho = (u64)state->rho + 1; |
189 | answer = (value * ((1ull<<32) - rho) + state->last * rho) >> 32; | 189 | answer = (value * ((1ull<<32) - rho) + state->last * rho) >> 32; |
190 | state->last = answer; | 190 | state->last = answer; |
@@ -198,7 +198,7 @@ static u32 get_crandom(struct crndstate *state) | |||
198 | static bool loss_4state(struct netem_sched_data *q) | 198 | static bool loss_4state(struct netem_sched_data *q) |
199 | { | 199 | { |
200 | struct clgstate *clg = &q->clg; | 200 | struct clgstate *clg = &q->clg; |
201 | u32 rnd = net_random(); | 201 | u32 rnd = prandom_u32(); |
202 | 202 | ||
203 | /* | 203 | /* |
204 | * Makes a comparison between rnd and the transition | 204 | * Makes a comparison between rnd and the transition |
@@ -264,15 +264,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q) | |||
264 | 264 | ||
265 | switch (clg->state) { | 265 | switch (clg->state) { |
266 | case 1: | 266 | case 1: |
267 | if (net_random() < clg->a1) | 267 | if (prandom_u32() < clg->a1) |
268 | clg->state = 2; | 268 | clg->state = 2; |
269 | if (net_random() < clg->a4) | 269 | if (prandom_u32() < clg->a4) |
270 | return true; | 270 | return true; |
271 | break; | 271 | break; |
272 | case 2: | 272 | case 2: |
273 | if (net_random() < clg->a2) | 273 | if (prandom_u32() < clg->a2) |
274 | clg->state = 1; | 274 | clg->state = 1; |
275 | if (net_random() > clg->a3) | 275 | if (prandom_u32() > clg->a3) |
276 | return true; | 276 | return true; |
277 | } | 277 | } |
278 | 278 | ||
@@ -457,7 +457,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
457 | skb_checksum_help(skb))) | 457 | skb_checksum_help(skb))) |
458 | return qdisc_drop(skb, sch); | 458 | return qdisc_drop(skb, sch); |
459 | 459 | ||
460 | skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); | 460 | skb->data[prandom_u32() % skb_headlen(skb)] ^= |
461 | 1<<(prandom_u32() % 8); | ||
461 | } | 462 | } |
462 | 463 | ||
463 | if (unlikely(skb_queue_len(&sch->q) >= sch->limit)) | 464 | if (unlikely(skb_queue_len(&sch->q) >= sch->limit)) |