public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring/zcrx: return early from io_zcrx_recv_skb if readlen is 0
@ 2025-04-01 18:28 David Wei
  2025-04-01 18:56 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: David Wei @ 2025-04-01 18:28 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, Pavel Begunkov

When readlen is set for a recvzc request, tcp_read_sock() will call
io_zcrx_recv_skb() one final time with len == desc->count == 0. This is
caused by the !desc->count check happening too late. The offset + 1 !=
skb->len happens earlier and causes the while loop to continue.

Fix this in io_zcrx_recv_skb() instead of tcp_read_sock(). Return early
if len is 0 i.e. the read is done.

Signed-off-by: David Wei <dw@davidwei.uk>
---
 io_uring/zcrx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 9c95b5b6ec4e..d1dd25e7cf4a 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -818,6 +818,8 @@ io_zcrx_recv_skb(read_descriptor_t *desc, struct sk_buff *skb,
 	int ret = 0;
 
 	len = min_t(size_t, len, desc->count);
+	if (!len)
+		goto out;
 	if (unlikely(args->nr_skbs++ > IO_SKBS_PER_CALL_LIMIT))
 		return -EAGAIN;
 
-- 
2.47.1


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

end of thread, other threads:[~2025-04-01 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 18:28 [PATCH] io_uring/zcrx: return early from io_zcrx_recv_skb if readlen is 0 David Wei
2025-04-01 18:56 ` Jens Axboe
2025-04-01 19:10   ` David Wei
2025-04-01 19:12     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox