Skip to content

Commit

Permalink
sch_netem: replace magic numbers with enumerate in GE model
Browse files Browse the repository at this point in the history
Replace some magic numbers which describe states of GE model
loss generator with enumerate.

Signed-off-by: Yang Yingliang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Yang Yingliang authored and davem330 committed Feb 14, 2014
1 parent 49545a7 commit c045a73
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions net/sched/sch_netem.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ struct netem_sched_data {
LOST_IN_BURST_PERIOD,
} _4_state_model;

enum {
GOOD_STATE = 1,
BAD_STATE,
} GE_state_model;

/* Correlated Loss Generation models */
struct clgstate {
/* state of the Markov chain */
Expand Down Expand Up @@ -272,15 +277,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q)
struct clgstate *clg = &q->clg;

switch (clg->state) {
case 1:
case GOOD_STATE:
if (prandom_u32() < clg->a1)
clg->state = 2;
clg->state = BAD_STATE;
if (prandom_u32() < clg->a4)
return true;
break;
case 2:
case BAD_STATE:
if (prandom_u32() < clg->a2)
clg->state = 1;
clg->state = GOOD_STATE;
if (prandom_u32() > clg->a3)
return true;
}
Expand Down

0 comments on commit c045a73

Please sign in to comment.