diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-03-28 18:48:25 +0100 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-03-28 18:48:25 +0100 |
commit | 367efea8c9ba557a81158a69ecee267706a520eb (patch) | |
tree | 461ddf127e076a99d792e59006fd599ad1704c01 /trafgen.c | |
parent | b55fde49e9f3e772b62e175cdbbec8f9fcc77567 (diff) |
ring: purge timer before we unmap tx ring buffers
If we unmap TX ring buffers and still have timer shots that trigger
the kernel to traverse the TX_RING, it can send out random crap in
some situations. Prevent this by destroying the timer and flush the
TX_RING first in wait mode.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'trafgen.c')
-rw-r--r-- | trafgen.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -127,11 +127,24 @@ static void signal_handler(int number) static void timer_elapsed(int number) { - int ret; + int ret = pull_and_flush_tx_ring(sock); + if (unlikely(ret < 0)) { + /* We could hit EBADF if the socket has been closed before + * the timer was triggered. + */ + if (errno != EBADF && errno != ENOBUFS) + panic("Flushing TX_RING failed: %s!\n", strerror(errno)); + } set_itimer_interval_value(&itimer, 0, interval); + setitimer(ITIMER_REAL, &itimer, NULL); +} - ret = pull_and_flush_tx_ring(sock); +static void timer_purge(void) +{ + int ret; + + ret = pull_and_flush_tx_ring_wait(sock); if (unlikely(ret < 0)) { /* We could hit EBADF if the socket has been closed before * the timer was triggered. @@ -140,6 +153,7 @@ static void timer_elapsed(int number) panic("Flushing TX_RING failed: %s!\n", strerror(errno)); } + set_itimer_interval_value(&itimer, 0, 0); setitimer(ITIMER_REAL, &itimer, NULL); } @@ -669,6 +683,8 @@ static void xmit_fastpath_or_die(struct ctx *ctx, int cpu, unsigned long orig_nu bug_on(gettimeofday(&end, NULL)); timersub(&end, &start, &diff); + timer_purge(); + destroy_tx_ring(sock, &tx_ring); stats[cpu].tx_packets = tx_packets; |