Skip to content

Commit c09c0b4

Browse files
author
Ming Lei
committed
io_uring/net: only consider msg_inq if larger than 1
JIRA: https://issues.redhat.com/browse/RHEL-106845 commit 2c7f023 Author: Jens Axboe <axboe@kernel.dk> Date: Wed May 28 13:45:44 2025 -0600 io_uring/net: only consider msg_inq if larger than 1 Currently retry and general validity of msg_inq is gated on it being larger than zero, but it's entirely possible for this to be slightly inaccurate. In particular, if FIN is received, it'll return 1. Just use larger than 1 as the check. This covers both the FIN case, and at the same time, it doesn't make much sense to retry a recv immediately if there's even just a single 1 byte of valid data in the socket. Leave the SOCK_NONEMPTY flagging when larger than 0 still, as an app may use that for the final receive. Cc: stable@vger.kernel.org Reported-by: Christian Mazakas <christian.mazakas@gmail.com> Fixes: 7c71a0a ("io_uring/net: improve recv bundles") Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent edd05bb commit c09c0b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

io_uring/net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
831831
* If more is available AND it was a full transfer, retry and
832832
* append to this one
833833
*/
834-
if (!sr->retry && kmsg->msg.msg_inq > 0 && this_ret > 0 &&
834+
if (!sr->retry && kmsg->msg.msg_inq > 1 && this_ret > 0 &&
835835
!iov_iter_count(&kmsg->msg.msg_iter)) {
836836
req->cqe.flags = cflags & ~CQE_F_MASK;
837837
sr->len = kmsg->msg.msg_inq;
@@ -1068,7 +1068,7 @@ static int io_recv_buf_select(struct io_kiocb *req, struct io_async_msghdr *kmsg
10681068
arg.mode |= KBUF_MODE_FREE;
10691069
}
10701070

1071-
if (kmsg->msg.msg_inq > 0)
1071+
if (kmsg->msg.msg_inq > 1)
10721072
arg.max_len = min_not_zero(sr->len, kmsg->msg.msg_inq);
10731073

10741074
ret = io_buffers_peek(req, &arg);

0 commit comments

Comments
 (0)