Skip to contentSkip to conversation

netem: missing break in ge loss generator

PATCH Applied Stephen Hemminger 2 participants 6 messages Nov 29, 2013 – Nov 30, 2013

Subsystems (4)
lore
Share & tools
lore

Stephen Hemminger

author maintainer
#0 lore raw

PATCH 1/3 netem: missing break in ge loss generator

There is a missing break statement in the Gilbert Elliot loss model generator which makes state machine behave incorrectly.

net/sched/sch_netem.c +1 -0
@@ -268,6 +268,7 @@ static bool loss_gilb_ell(struct netem_s
 			clg->state = 2;
 		if (net_random() < clg->a4)
 			return true;
+		break;
 	case 2:
 		if (net_random() < clg->a2)
 			clg->state = 1;
author maintainer
#1 lore raw

PATCH 2/3 netem: fix loss 4 state model

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."

net/sched/sch_netem.c +2 -2
@@ -215,10 +215,10 @@ static bool loss_4state(struct netem_sch
 		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;
maintainer Applied
#2 lore raw

Re: [PATCH net 2/3] netem: fix loss 4 state model

From: Stephen Hemminger <[email protected]>
Date: Fri, 29 Nov 2013 11:03:35 -0800

Quoted 7 lines

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."

Applied.

author maintainer
#3 lore raw

PATCH 3/3 netem: fix gemodel loss generator

In reply to Stephen Hemminger

Patch from developers of the alternative loss models, downloaded from:
http://netgroup.uniroma2.it/twiki/bin/view.cgi/Main/NetemCLG

"in case 2, of the switch we change the direction of the inequality to
net_random()>clg->a3, because clg->a3 is h in the GE model and when h is 0 all packets will be lost."

net/sched/sch_netem.c +1 -1
@@ -272,7 +272,7 @@ static bool loss_gilb_ell(struct netem_s
 	case 2:
 		if (net_random() < clg->a2)
 			clg->state = 1;
-		if (clg->a3 > net_random())
+		if (net_random() > clg->a3)
 			return true;
 	}
 
maintainer Applied
#4 lore raw

Re: [PATCH net 3/3] netem: fix gemodel loss generator

From: Stephen Hemminger <[email protected]>
Date: Fri, 29 Nov 2013 11:04:26 -0800

Quoted 8 lines

Patch from developers of the alternative loss models, downloaded from:
http://netgroup.uniroma2.it/twiki/bin/view.cgi/Main/NetemCLG

"in case 2, of the switch we change the direction of the inequality to
net_random()>clg->a3, because clg->a3 is h in the GE model and when h is 0 all packets will be lost."

Applied.