Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: psock_tpacket: fix status check

Testing like this for TP_STATUS_AVAILABLE clearly is a stupid bug
since it always returns true. Fix this by only checking for flags
where the kernel owns the packet and negate this result, since we
also could run into the non-zero status TP_STATUS_WRONG_FORMAT
and need to reclaim frames.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Borkmann and committed by
David S. Miller
fdd5f43a 823aa873

+2 -2
+2 -2
tools/testing/selftests/net/psock_tpacket.c
··· 300 300 301 301 static inline int __v1_tx_kernel_ready(struct tpacket_hdr *hdr) 302 302 { 303 - return ((hdr->tp_status & TP_STATUS_AVAILABLE) == TP_STATUS_AVAILABLE); 303 + return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING)); 304 304 } 305 305 306 306 static inline void __v1_tx_user_ready(struct tpacket_hdr *hdr) ··· 311 311 312 312 static inline int __v2_tx_kernel_ready(struct tpacket2_hdr *hdr) 313 313 { 314 - return ((hdr->tp_status & TP_STATUS_AVAILABLE) == TP_STATUS_AVAILABLE); 314 + return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING)); 315 315 } 316 316 317 317 static inline void __v2_tx_user_ready(struct tpacket2_hdr *hdr)