Skip to contentSkip to conversation

Fixed NetEm's reorder option

PATCH Rafael Almeida 2 participants 2 messages Jun 11, 2008 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

I noticed no one said anything about my patch below, did I do something terrible wrong? Should I just be more patient?

Quoted 81 lines · Rafael C. de Almeida

The reorder option wasn't working correctly. It would only kick in if the gap option was set. In that case it would only lower the probability of reordering packets because of how the if conditional was stated.

This patch separetes the algorithm for reordering with gap from the rest, rendering the code more readable and correct.

---
 net/sched/sch_netem.c |   45 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 32 insertions(+), 13 deletions(-)
net/sched/sch_netem.c +32 -14
index c9c649b..477ee09 100644
@@ -206,27 +206,46 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
       }
 
       cb = (struct netem_skb_cb *)skb->cb;
-       if (q->gap == 0                 /* not doing reordering */
-           || q->counter < q->gap      /* inside last reordering gap */
-           || q->reorder < get_crandom(&q->reorder_cor)) {
+       if (q->gap) {
+               /* The comparison of reorder is here to keep compatibility with
+                * the old behaviour when one had reorder and gap set, maybe it
+                * could be removed.
+                */
+               if (q->counter < q->gap
+                   || q->reorder < get_crandom(&q->reorder_cor)) {
+                       psched_time_t now;
+                       psched_tdiff_t delay;
+
+                       delay = tabledist(q->latency, q->jitter,
+                                         &q->delay_cor, q->delay_dist);
+
+                       now = psched_get_time();
+                       cb->time_to_send = now + delay;
+                       ++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.
+                        */
+                       cb->time_to_send = psched_get_time();
+                       q->counter = 0;
+                       ret = q->qdisc->ops->requeue(skb, q->qdisc);
+               }
+       } else {
               psched_time_t now;
               psched_tdiff_t delay;
 
-               delay = tabledist(q->latency, q->jitter,
-                                 &q->delay_cor, q->delay_dist);
+               if (!q->reorder || q->reorder < get_crandom(&q->reorder_cor))
+                       delay = tabledist(q->latency, q->jitter,
+                                         &q->delay_cor, q->delay_dist);
+               else
+                       delay = 0;
 
               now = psched_get_time();
               cb->time_to_send = now + delay;
               ++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.
-                */
-               cb->time_to_send = psched_get_time();
-               q->counter = 0;
-               ret = q->qdisc->ops->requeue(skb, q->qdisc);
       }
 
       if (likely(ret == NET_XMIT_SUCCESS)) {
--

1.5.5.GIT

#2 lore raw
Quoted 14 lines · On Wed, 11 Jun 2008 17:05:10 -0300 "Rafael Almeida" <[email protected]>…

I noticed no one said anything about my patch below, did I do something terrible wrong? Should I just be more patient?

Quoted 9 lines · Rafael C. de Almeida

The reorder option wasn't working correctly. It would only kick in if the gap option was set. In that case it would only lower the probability of reordering packets because of how the if conditional was stated.

This patch separetes the algorithm for reordering with gap from the rest, rendering the code more readable and correct.

Haven't had time to look at this in detail, and I worry about the impact of changing assumptions people already have in their scripts.