Re: cBPF socket filters failing - inexplicably?

2021-01-15 Thread Tom Cook
On Fri, Jan 15, 2021 at 2:16 PM Eric Dumazet wrote: [snip] > > 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,

Re: cBPF socket filters failing - inexplicably?

2021-01-15 Thread Eric Dumazet
On Fri, Jan 15, 2021 at 7:52 AM Alexei Starovoitov wrote: > > Adding appropriate mailing list to cc... > > 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.

Re: cBPF socket filters failing - inexplicably?

2021-01-14 Thread Alexei Starovoitov
Adding appropriate mailing list to cc... 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? On Wed, Jan 6, 2021 at 6:55 AM Tom Cook wrote: > >

Re: cBPF socket filters failing - inexplicably?

2021-01-06 Thread Tom Cook
Another factoid to add to this: I captured all traffic on an interface while the test program was running using tcpdump -i wlo1 -w capture.pcap observing that multiple packets got through the filter. I then built the bpf_dbg program from the kernel source tree and ran the same filter and

Re: cBPF socket filters failing - inexplicably?

2021-01-06 Thread Tom Cook
Just to note I have also reproduced this on a 5.10.0 kernel. On Tue, Jan 5, 2021 at 1:42 PM Tom Cook wrote: > > In the course of tracking down a defect in some existing software, > I've found the failure demonstrated by the short program below. > Essentially, a cBPF program that just rejects

cBPF socket filters failing - inexplicably?

2021-01-05 Thread Tom Cook
In the course of tracking down a defect in some existing software, I've found the failure demonstrated by the short program below. Essentially, a cBPF program that just rejects every frame (ie always returns zero) and is attached to a socket using setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, ...)