summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-03-19 18:09:08 +0100
committerDaniel Borkmann <dborkman@redhat.com>2013-03-19 18:09:08 +0100
commit540ae1ee3b2456355fc9c36410667e1b5019e314 (patch)
tree402eca4b3d2fadd88c6a7bcbb97ef3706fe345fe
parentceae98914962e4375a98db2622b65ecf44b0232a (diff)
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 <dborkman@redhat.com>
-rw-r--r--ring_rx.c7
-rw-r--r--ring_tx.c7
2 files changed, 6 insertions, 8 deletions
diff --git a/ring_rx.c b/ring_rx.c
index 4c5846c..5675a81 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -23,16 +23,15 @@ void destroy_rx_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_RX_RING, &ring->layout,
sizeof(ring->layout));
if (unlikely(ret))
panic("Cannot destroy the RX_RING!\n");
- munmap(ring->mm_space, ring->mm_len);
- ring->mm_len = 0;
-
xfree(ring->frames);
}
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);
}