From 540ae1ee3b2456355fc9c36410667e1b5019e314 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Tue, 19 Mar 2013 18:09:08 +0100 Subject: ring: first unmap, then destroy ring buffer In both, the RX_RING and TX_RING we need to unmap first and then destroy the buffer, otherwise, we get a device or resource busy. Signed-off-by: Daniel Borkmann --- ring_tx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ring_tx.c') diff --git a/ring_tx.c b/ring_tx.c index 9869131..6804c43 100644 --- a/ring_tx.c +++ b/ring_tx.c @@ -33,16 +33,15 @@ void destroy_tx_ring(int sock, struct ring *ring) { int ret; - fmemset(&ring->layout, 0, sizeof(ring->layout)); + munmap(ring->mm_space, ring->mm_len); + ring->mm_len = 0; + fmemset(&ring->layout, 0, sizeof(ring->layout)); ret = setsockopt(sock, SOL_PACKET, PACKET_TX_RING, &ring->layout, sizeof(ring->layout)); if (unlikely(ret)) panic("Cannot destroy the TX_RING!\n"); - munmap(ring->mm_space, ring->mm_len); - ring->mm_len = 0; - xfree(ring->frames); } -- cgit v1.2.3-54-g00ecf