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

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