]> git.karo-electronics.de Git - linux-beck.git/commitdiff
selftests: psock_tpacket: fix status check
authorDaniel Borkmann <dborkman@redhat.com>
Wed, 24 Apr 2013 23:08:00 +0000 (23:08 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 29 Apr 2013 16:26:53 +0000 (12:26 -0400)
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>
tools/testing/selftests/net/psock_tpacket.c

index a8d7ffadd49b7d0970d07e762adde79d38c27478..c41b58640a058308f42c25f6e20db473bb236519 100644 (file)
@@ -300,7 +300,7 @@ static void walk_v1_v2_rx(int sock, struct ring *ring)
 
 static inline int __v1_tx_kernel_ready(struct tpacket_hdr *hdr)
 {
-       return ((hdr->tp_status & TP_STATUS_AVAILABLE) == TP_STATUS_AVAILABLE);
+       return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
 }
 
 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)
 
 static inline int __v2_tx_kernel_ready(struct tpacket2_hdr *hdr)
 {
-       return ((hdr->tp_status & TP_STATUS_AVAILABLE) == TP_STATUS_AVAILABLE);
+       return !(hdr->tp_status & (TP_STATUS_SEND_REQUEST | TP_STATUS_SENDING));
 }
 
 static inline void __v2_tx_user_ready(struct tpacket2_hdr *hdr)