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