summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-05-31 15:13:20 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-05-31 15:13:20 +0200
commitcfdc25dbcd0e17de870aebf222b2fdbc7789312a (patch)
tree8a0fd4cdafb829fd5c7be9559116aa667d409a4d
parentd8cdc6ab87550de9c93b1f6763ea6015f292d7fb (diff)
ring_rx: if v3, free it in kernel space during close
Let this be freed by the kernel during close(2) call in case of v3 otherwise we would get a -EINVAL. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r--ring_rx.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ring_rx.c b/ring_rx.c
index ae8ce0a..28ecaf4 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -22,17 +22,22 @@
void destroy_rx_ring(int sock, struct ring *ring)
{
int ret;
+ bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3;
munmap(ring->mm_space, ring->mm_len);
ring->mm_len = 0;
+ xfree(ring->frames);
+
+ /* In general, this is freed during close(2) anyway. */
+ if (v3)
+ return;
+
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: %s!\n", strerror(errno));
-
- xfree(ring->frames);
}
void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size,