Blame SOURCES/0001-bpf-increase-snaplen-if-doing-cooked-mode-userspace-.patch

9b1536
From 8ce2c17fd359a758b08bd15a33a0deae872c8231 Mon Sep 17 00:00:00 2001
9b1536
From: rpm-build <rpm-build>
9b1536
Date: Mon, 20 Apr 2015 13:47:28 +0200
9b1536
Subject: [PATCH] bpf: increase snaplen if doing cooked mode userspace
9b1536
 filtering
9b1536
9b1536
This commit should address the issue when bpf_filter_with_auxdata returned 0 for valid
9b1536
packets because offset in filter exceeded tp_snaplen as returned by kernel. If
9b1536
we filter in cooked mode filter offsets are adjusted because sll_header, we
9b1536
should do the same for snaplen.
9b1536
---
9b1536
 pcap-linux.c | 5 ++++-
9b1536
 1 file changed, 4 insertions(+), 1 deletion(-)
9b1536
9b1536
diff --git a/pcap-linux.c b/pcap-linux.c
9b1536
index 95c94df..034bcd3 100644
9b1536
--- a/pcap-linux.c
9b1536
+++ b/pcap-linux.c
9b1536
@@ -4186,6 +4186,7 @@ static int pcap_handle_packet_mmap(
9b1536
 	unsigned char *bp;
9b1536
 	struct sockaddr_ll *sll;
9b1536
 	struct pcap_pkthdr pcaphdr;
9b1536
+	unsigned int snaplen = tp_snaplen;
9b1536
 
9b1536
 	/* perform sanity check on internal offset. */
9b1536
 	if (tp_mac + tp_snaplen > handle->bufsize) {
9b1536
@@ -4246,11 +4247,13 @@ static int pcap_handle_packet_mmap(
9b1536
 		hdrp->sll_halen = htons(sll->sll_halen);
9b1536
 		memcpy(hdrp->sll_addr, sll->sll_addr, SLL_ADDRLEN);
9b1536
 		hdrp->sll_protocol = sll->sll_protocol;
9b1536
+
9b1536
+		snaplen += sizeof(struct sll_header);
9b1536
 	}
9b1536
 
9b1536
         if (handlep->filter_in_userland && handle->fcode.bf_insns &&
9b1536
             (bpf_filter(handle->fcode.bf_insns, bp,
9b1536
-                        tp_len, tp_snaplen) == 0))
9b1536
+                        tp_len, snaplen) == 0))
9b1536
 		return 0;
9b1536
 
9b1536
 	if (!linux_check_direction(handle, sll))
9b1536
-- 
9b1536
2.3.4
9b1536