From cfdc25dbcd0e17de870aebf222b2fdbc7789312a Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Fri, 31 May 2013 15:13:20 +0200 Subject: 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 --- ring_rx.c | 9 +++++++-- 1 file 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, -- cgit v1.2.3-54-g00ecf