Thread (3 messages) flat view 3 messages, 3 authors, 2021-01-15

Re: cBPF socket filters failing - inexplicably?

From: Tom Cook <hidden>
Date: 2021-01-15 22:47:10
Also in: bpf, lkml

On Fri, Jan 15, 2021 at 2:16 PM Eric Dumazet [off-list ref] wrote:
[snip]
quoted
My wild guess is that as soon as socket got created:
socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
the packets were already queued to it.
So later setsockopt() is too late to filter.

Eric, thoughts?
Exactly, this is what happens.
I understand.  Thanks for the explanation.
I do not know how tcpdump and other programs deal with this.

Maybe by setting a small buffer size, or draining the queue.
libpcap has its own cBPF implementation which it applies after it
receives the packets from the queue.

Thanks again,
Tom Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help