pktgen: Fix delay handling
authorEric Dumazet <eric.dumazet@gmail.com>
Thu, 1 Oct 2009 16:29:45 +0000 (09:29 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Oct 2009 16:29:45 +0000 (09:29 -0700)
After last pktgen changes, delay handling is wrong.

pktgen actually sends packets at full line speed.

Fix is to update pkt_dev->next_tx even if spin() returns early,
so that next spin() calls have a chance to see a positive delay.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index 4d11c28ca8ca0f1b2dbbedb3a9e569a983087f40..b69455217ed6270fae1b3d6c4b011cf53b7a7f95 100644 (file)
@@ -2105,15 +2105,17 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
 static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
 {
        ktime_t start_time, end_time;
-       s32 remaining;
+       s64 remaining;
        struct hrtimer_sleeper t;
 
        hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
        hrtimer_set_expires(&t.timer, spin_until);
 
        remaining = ktime_to_us(hrtimer_expires_remaining(&t.timer));
-       if (remaining <= 0)
+       if (remaining <= 0) {
+               pkt_dev->next_tx = ktime_add_ns(spin_until, pkt_dev->delay);
                return;
+       }
 
        start_time = ktime_now();
        if (remaining < 100)