From 97e6f994785ce5f3f486f8eddb62df964119d121 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 26 May 2014 15:10:33 +0200 Subject: netsniff-ng: Restore tpacket v2 capturing Some older systems (e.g. RHEL 6) don't have tpacket v3 available, but only tpacket v2. However, since commit d8cdc6a ("ring: netsniff-ng: migrate capture only to TPACKET_V3") we solely rely on tpacket v3 for capturing packets. This patch restores the possibility to capture using tpacket v2. For now this is just a fallback if the configure script doesn't detect tpacket v3 (and thus HAVE_TPACKET3 isn't set). Thus, on most modern systems this shouldn't change anything and they will continue using tpacket v3. For now this fix contains quite a bit of ugly #ifdefery which should be cleaned up in the future. Fixes #76 Signed-off-by: Tobias Klauser --- ring_rx.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ring_rx.h') diff --git a/ring_rx.h b/ring_rx.h index 02c65bc..60a0eeb 100644 --- a/ring_rx.h +++ b/ring_rx.h @@ -22,19 +22,21 @@ static inline int user_may_pull_from_rx(struct tpacket2_hdr *hdr) return ((hdr->tp_status & TP_STATUS_USER) == TP_STATUS_USER); } -static inline int user_may_pull_from_rx_block(struct block_desc *pbd) +static inline void kernel_may_pull_from_rx(struct tpacket2_hdr *hdr) { - return ((pbd->h1.block_status & TP_STATUS_USER) == TP_STATUS_USER); + hdr->tp_status = TP_STATUS_KERNEL; } -static inline void kernel_may_pull_from_rx(struct tpacket2_hdr *hdr) +#ifdef HAVE_TPACKET3 +static inline int user_may_pull_from_rx_block(struct block_desc *pbd) { - hdr->tp_status = TP_STATUS_KERNEL; + return ((pbd->h1.block_status & TP_STATUS_USER) == TP_STATUS_USER); } static inline void kernel_may_pull_from_rx_block(struct block_desc *pbd) { pbd->h1.block_status = TP_STATUS_KERNEL; } +#endif /* HAVE_TPACKETV3 */ #endif /* RX_RING_H */ -- cgit v1.2.3-54-g00ecf