Received: with ECARTIS (v1.0.0; list netdev); Mon, 23 May 2005 10:44:32 -0700 (PDT) Received: from smtp.osdl.org (fire.osdl.org [65.172.181.4]) by oss.sgi.com (8.12.10/8.12.10/SuSE Linux 0.7) with ESMTP id j4NHiTF3021111 for ; Mon, 23 May 2005 10:44:30 -0700 Received: from shell0.pdx.osdl.net (fw.osdl.org [65.172.181.6]) by smtp.osdl.org (8.12.8/8.12.8) with ESMTP id j4NHhgjA003503 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Mon, 23 May 2005 10:43:43 -0700 Received: from dxpl.pdx.osdl.net (dxpl.pdx.osdl.net [10.8.0.74]) by shell0.pdx.osdl.net (8.13.1/8.11.6) with ESMTP id j4NHhgvR009638; Mon, 23 May 2005 10:43:42 -0700 Date: Mon, 23 May 2005 10:43:42 -0700 From: Stephen Hemminger To: Julio Kriger Cc: "David S. Miller" , netdev@oss.sgi.com, netem@osdl.org Subject: [PATCH] netem: fix logic bug in reorder conditional Message-ID: <20050523104342.78b1032d@dxpl.pdx.osdl.net> In-Reply-To: <682bc30a05052116005bc813a2@mail.gmail.com> References: <20050519151254.79afe7e7@dxpl.pdx.osdl.net> <682bc30a05052116005bc813a2@mail.gmail.com> Organization: Open Source Development Lab X-Mailer: Sylpheed-Claws 1.0.4 (GTK+ 1.2.10; x86_64-unknown-linux-gnu) X-Face: &@E+xe?c%:&e4D{>f1O<&U>2qwRREG5!}7R4;D<"NO^UI2mJ[eEOA2*3>(`Th.yP,VDPo9$ /`~cw![cmj~~jWe?AHY7D1S+\}5brN0k*NE?pPh_'_d>6;XGG[\KDRViCfumZT3@[ Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-MIMEDefang-Filter: osdl$Revision: 1.109 $ X-Scanned-By: MIMEDefang 2.36 X-archive-position: 1499 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: shemminger@osdl.org Precedence: bulk X-list: netdev Content-Length: 1221 Lines: 34 Thanks, Julio you spotted the problem with the logic. This should fix it: Index: netem-2.6.12-rc4/net/sched/sch_netem.c =================================================================== --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c +++ netem-2.6.12-rc4/net/sched/sch_netem.c @@ -181,13 +181,9 @@ static int netem_enqueue(struct sk_buff q->duplicate = dupsave; } - /* - * Do re-ordering by putting one out of N packets at the front - * of the queue. - * gap == 0 is special case for no-reordering. - */ - if (q->gap == 0 && q->counter < q->gap && - q->reorder < get_crandom(&q->reorder_cor)) { + if (q->gap == 0 /* not doing reordering */ + || q->counter < q->gap /* inside last reordering gap */ + || q->reorder < get_crandom(&q->reorder_cor)) { psched_time_t now; PSCHED_GET_TIME(now); PSCHED_TADD2(now, tabledist(q->latency, q->jitter, @@ -196,6 +192,10 @@ static int netem_enqueue(struct sk_buff ++q->counter; ret = q->qdisc->enqueue(skb, q->qdisc); } else { + /* + * Do re-ordering by putting one out of N packets at the front + * of the queue. + */ PSCHED_GET_TIME(cb->time_to_send); q->counter = 0; ret = q->qdisc->ops->requeue(skb, q->qdisc);