netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] selftests: psock_tpacket: fix status check
@ 2013-04-25  9:08 Daniel Borkmann
  2013-04-29 16:27 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Borkmann @ 2013-04-25  9:08 UTC (permalink / raw)
  To: davem; +Cc: netdev

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>
---
 This is only for net-next, since net does not contain networking
 selftests yet.

 tools/testing/selftests/net/psock_tpacket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
index a8d7ffa..c41b586 100644
--- a/tools/testing/selftests/net/psock_tpacket.c
+++ b/tools/testing/selftests/net/psock_tpacket.c
@@ -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)
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] selftests: psock_tpacket: fix status check
  2013-04-25  9:08 [PATCH net-next] selftests: psock_tpacket: fix status check Daniel Borkmann
@ 2013-04-29 16:27 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-04-29 16:27 UTC (permalink / raw)
  To: dborkman; +Cc: netdev

From: Daniel Borkmann <dborkman@redhat.com>
Date: Thu, 25 Apr 2013 11:08:00 +0200

> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-29 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25  9:08 [PATCH net-next] selftests: psock_tpacket: fix status check Daniel Borkmann
2013-04-29 16:27 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).