Skip to content

Commit c045a73

Browse files
Yang Yingliangdavem330
authored andcommitted
sch_netem: replace magic numbers with enumerate in GE model
Replace some magic numbers which describe states of GE model loss generator with enumerate. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 49545a7 commit c045a73

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

net/sched/sch_netem.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ struct netem_sched_data {
117117
LOST_IN_BURST_PERIOD,
118118
} _4_state_model;
119119

120+
enum {
121+
GOOD_STATE = 1,
122+
BAD_STATE,
123+
} GE_state_model;
124+
120125
/* Correlated Loss Generation models */
121126
struct clgstate {
122127
/* state of the Markov chain */
@@ -272,15 +277,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q)
272277
struct clgstate *clg = &q->clg;
273278

274279
switch (clg->state) {
275-
case 1:
280+
case GOOD_STATE:
276281
if (prandom_u32() < clg->a1)
277-
clg->state = 2;
282+
clg->state = BAD_STATE;
278283
if (prandom_u32() < clg->a4)
279284
return true;
280285
break;
281-
case 2:
286+
case BAD_STATE:
282287
if (prandom_u32() < clg->a2)
283-
clg->state = 1;
288+
clg->state = GOOD_STATE;
284289
if (prandom_u32() > clg->a3)
285290
return true;
286291
}

0 commit comments

Comments
 (0)