All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ferry Huberts <mailings@hupie.com>
To: netdev@vger.kernel.org
Subject: [PATCH 2/2] net: netem: always adjust now/delay when not reordering
Date: Tue, 20 Aug 2013 17:11:09 +0200	[thread overview]
Message-ID: <1377011469-26151-2-git-send-email-mailings@hupie.com> (raw)
In-Reply-To: <1377011469-26151-1-git-send-email-mailings@hupie.com>

From: Ferry Huberts <ferry.huberts@pelagic.nl>

Not doing this (current behaviour) introduces reordering.

The packet_len_2_sched_time call is the only thing that logically
depends on q->rate, so move the now/delay adjustment out of the if.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
---
 net/sched/sch_netem.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index abe5fa6..86c73d2 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -457,6 +457,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 	if (q->gap == 0 || q->reorder == 0 || /* not doing reordering */
 	    q->counter < q->gap - 1 ||	/* inside last reordering gap */
 	    q->reorder < get_crandom(&q->reorder_cor)) {
+		struct sk_buff *last;
+
 		psched_time_t now;
 		psched_tdiff_t delay;
 
@@ -465,24 +467,22 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 
 		now = psched_get_time();
 
-		if (q->rate) {
-			struct sk_buff *last;
-
-			if (!skb_queue_empty(&sch->q))
-				last = skb_peek_tail(&sch->q);
-			else
-				last = netem_rb_to_skb(rb_last(&q->t_root));
-			if (last) {
-				/*
-				 * Last packet in queue is reference point (now),
-				 * calculate this time bonus and subtract
-				 * from delay.
-				 */
-				delay -= netem_skb_cb(last)->time_to_send - now;
-				delay = max_t(psched_tdiff_t, 0, delay);
-				now = netem_skb_cb(last)->time_to_send;
-			}
+		if (!skb_queue_empty(&sch->q))
+			last = skb_peek_tail(&sch->q);
+		else
+			last = netem_rb_to_skb(rb_last(&q->t_root));
+		if (last) {
+			/*
+			 * Last packet in queue is reference point (now),
+			 * calculate this time bonus and subtract
+			 * from delay.
+			 */
+			delay -= netem_skb_cb(last)->time_to_send - now;
+			delay = max_t(psched_tdiff_t, 0, delay);
+			now = netem_skb_cb(last)->time_to_send;
+		}
 
+		if (q->rate) {
 			delay += packet_len_2_sched_time(skb->len, q);
 		}
 
-- 
1.8.3.1

  reply	other threads:[~2013-08-20 15:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20 15:11 [PATCH 1/2] net: netem: do not reorder when reordering is disabled Ferry Huberts
2013-08-20 15:11 ` Ferry Huberts [this message]
2013-08-20 18:31   ` [PATCH 2/2] net: netem: always adjust now/delay when not reordering Sergei Shtylyov
2013-08-20 20:33   ` Eric Dumazet
2013-08-21  5:59     ` [PATCH v2 " Ferry Huberts
2013-08-21  6:14       ` Eric Dumazet
2013-08-21  7:04         ` Ferry Huberts
2013-08-21 13:30           ` Eric Dumazet
2013-08-21 14:02             ` mailings
2013-08-21 14:10               ` mailings
2013-08-21 15:17   ` [PATCH " Johannes Naab
2013-08-21 15:39     ` Eric Dumazet
2013-08-21 16:14       ` Ferry Huberts
2013-08-21 17:00         ` Eric Dumazet
2013-08-21 17:35           ` Stephen Hemminger
2013-08-23 12:50         ` Ferry Huberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377011469-26151-2-git-send-email-mailings@hupie.com \
    --to=mailings@hupie.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.