netem: fix loss 4 state model
authorstephen hemminger <stephen@networkplumber.org>
Fri, 29 Nov 2013 19:03:35 +0000 (11:03 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Nov 2013 17:49:28 +0000 (12:49 -0500)
Patch from developers of the alternative loss models, downloaded from:
   http://netgroup.uniroma2.it/twiki/bin/view.cgi/Main/NetemCLG

 "In the case 1 of the switch statement in the if conditions we
   need to add clg->a4 to clg->a1, according to the model."

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_netem.c

index 6e91323f3dac8ce4c0e1eb57dbaa19ecc7a2a639..9685624f7bc779a942c822329a95aa0d656b79b9 100644 (file)
@@ -215,10 +215,10 @@ static bool loss_4state(struct netem_sched_data *q)
                if (rnd < clg->a4) {
                        clg->state = 4;
                        return true;
-               } else if (clg->a4 < rnd && rnd < clg->a1) {
+               } else if (clg->a4 < rnd && rnd < clg->a1 + clg->a4) {
                        clg->state = 3;
                        return true;
-               } else if (clg->a1 < rnd)
+               } else if (clg->a1 + clg->a4 < rnd)
                        clg->state = 1;
 
                break;