From dbd83f04dfb4b4265a290bad6a1813825f7ab3c6 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 29 Oct 2015 14:18:03 +0100 Subject: ring: Move generic code for ring layout setup to own function Initialization of the ring->layout members is the same for RX and TX rings. Instead of duplicating the code in setup_rx_ring_layout() and setup_tx_ring_layout(), create a new function setup_ring_layout_generic() which is called from the former two. Signed-off-by: Tobias Klauser --- ring_rx.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'ring_rx.c') diff --git a/ring_rx.c b/ring_rx.c index 11d1d08..1df7eb3 100644 --- a/ring_rx.c +++ b/ring_rx.c @@ -1,7 +1,7 @@ /* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010 Daniel Borkmann. - * Copyright 2014 Tobias Klauser. + * Copyright 2014, 2015 Tobias Klauser. * Subject to the GPL, version 2. */ @@ -142,20 +142,7 @@ void destroy_rx_ring(int sock, struct ring *ring) static void setup_rx_ring_layout(int sock, struct ring *ring, size_t size, bool jumbo_support, bool v3) { - fmemset(&ring->layout, 0, sizeof(ring->layout)); - - ring->layout.tp_block_size = (jumbo_support ? - RUNTIME_PAGE_SIZE << 4 : - RUNTIME_PAGE_SIZE << 2); - - ring->layout.tp_frame_size = (jumbo_support ? - TPACKET_ALIGNMENT << 12 : - TPACKET_ALIGNMENT << 7); - - ring->layout.tp_block_nr = size / ring->layout.tp_block_size; - ring->layout.tp_frame_nr = ring->layout.tp_block_size / - ring->layout.tp_frame_size * - ring->layout.tp_block_nr; + setup_ring_layout_generic(sock, ring, size, jumbo_support); if (v3) { setup_rx_ring_layout_v3(ring); -- cgit v1.2.3-54-g00ecf