Skip to content

Commit fdd5f43

Browse files
Daniel Borkmanndavem330
authored andcommitted
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>
1 parent 823aa87 commit fdd5f43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/net/psock_tpacket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ static void walk_v1_v2_rx(int sock, struct ring *ring)
300300

301301
static inline int __v1_tx_kernel_ready(struct tpacket_hdr *hdr)
302302
{
303-
return ((hdr->tp_status & TP_STATUS_AVAILABLE) == TP_STATUS_AVAILABLE);
303+
return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
304304
}
305305

306306
static inline void __v1_tx_user_ready(struct tpacket_hdr *hdr)
@@ -311,7 +311,7 @@ static inline void __v1_tx_user_ready(struct tpacket_hdr *hdr)
311311

312312
static inline int __v2_tx_kernel_ready(struct tpacket2_hdr *hdr)
313313
{
314-
return ((hdr->tp_status & TP_STATUS_AVAILABLE) == TP_STATUS_AVAILABLE);
314+
return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
315315
}
316316

317317
static inline void __v2_tx_user_ready(struct tpacket2_hdr *hdr)

0 commit comments

Comments
 (0)