]> The Tcpdump Group git mirrors - libpcap/commit
nflog: only increment packets_nobufs when recv() returns an error 1090/head
authorKenny Luong <[email protected]>
Tue, 8 Feb 2022 15:08:02 +0000 (09:08 -0600)
committerKenny Luong <[email protected]>
Tue, 8 Feb 2022 15:27:07 +0000 (09:27 -0600)
commit3fd11447cbbf424604b426a5fa1481fb68d662e9
tree26f040c0b95cfc0fa6432ec84470e289604c8756
parent5079d5e4d398a74a9a8e11b9ae18d76fdc0c1dd9
nflog: only increment packets_nobufs when recv() returns an error

Errno should only be valid when recv() returns a `-1`, indicating an
error.

I believe the intended behavior here is for packets_nobufs to
be a counter that reports back how many times recv() returns
an ENOBUFS during a packet capture. Because of the existing logic
however, packets_nobufs begins incrementing for every recv() call
once the first ENOBUFS error is seen, since errno is not reset when
there are no errors returned from recv().

Before (counter deviates from strace):

    # tcpdump output
    38069 packets captured
    38069 packets received by filter
    38061 packets dropped by kernel

    # strace output
    % time     seconds  usecs/call     calls    errors syscall
    ------ ----------- ----------- --------- --------- ----------------
    26.47    0.282728           7     38067         3 recvfrom

After (counter matches strace):

    # tcpdump output
    38095 packets captured
    38095 packets received by filter
    7 packets dropped by kernel

    # strace output
    % time     seconds  usecs/call     calls    errors syscall
    ------ ----------- ----------- --------- --------- ----------------
    27.11    0.258596           6     38096         7 recvfrom
pcap-netfilter-linux.c