netem: Fix off-by-one bug in reordering
authorVijay Subramanian <subramanian.vijay@gmail.com>
Thu, 19 Jan 2012 10:20:59 +0000 (10:20 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 22 Jan 2012 20:08:44 +0000 (15:08 -0500)
With netem reordering, a gap of N is supposed to reorder every Nth packet with
given reorder probability.  However, the code currently skips N packets and
reorders every (N+1)th packet.

Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_netem.c

index e7e1d0b57b3d2a28d5e99276cd195f7dfde999d0..2776012132ea2b6448e5b0dadf1d6dd729b13afa 100644 (file)
@@ -419,7 +419,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 
        cb = netem_skb_cb(skb);
        if (q->gap == 0 ||              /* not doing reordering */
-           q->counter < q->gap ||      /* inside last reordering gap */
+           q->counter < q->gap - 1 ||  /* inside last reordering gap */
            q->reorder < get_crandom(&q->reorder_cor)) {
                psched_time_t now;
                psched_tdiff_t delay;