diff mbox series

io_uring/net: clear msg_controllen on partial sendmsg retry

Message ID 0fd9ed30-c542-fc18-cc4c-140890da5db4@kernel.dk (mailing list archive)
State New
Headers show
Series io_uring/net: clear msg_controllen on partial sendmsg retry | expand

Commit Message

Jens Axboe June 19, 2023, 3:38 p.m. UTC
If we have cmsg attached AND we transferred partial data at least, clear
msg_controllen on retry so we don't attempt to send that again.

Cc: stable@vger.kernel.org # 5.10+
Fixes: cac9e4418f4c ("io_uring/net: save msghdr->msg_control for retries")
Reported-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

Comments

Stefan Metzmacher June 20, 2023, 7:56 a.m. UTC | #1
Hi Jens,

> If we have cmsg attached AND we transferred partial data at least, clear
> msg_controllen on retry so we don't attempt to send that again.
> 
> Cc: stable@vger.kernel.org # 5.10+
> Fixes: cac9e4418f4c ("io_uring/net: save msghdr->msg_control for retries")
> Reported-by: Stefan Metzmacher <metze@samba.org>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> 
> ---
> 
> diff --git a/io_uring/net.c b/io_uring/net.c
> index 51b0f7fbb4f5..fe1c478c7dec 100644
> --- a/io_uring/net.c
> +++ b/io_uring/net.c
> @@ -326,6 +326,7 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
>   		if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
>   			return io_setup_async_msg(req, kmsg, issue_flags);
>   		if (ret > 0 && io_net_retry(sock, flags)) {
> +			kmsg->msg.msg_controllen = 0;
>   			sr->done_io += ret;
>   			req->flags |= REQ_F_PARTIAL_IO;
>   			return io_setup_async_msg(req, kmsg, issue_flags);
> 

Should we also set 'kmsg->msg.msg_control' to NULL?

metze
Jens Axboe June 20, 2023, 1:06 p.m. UTC | #2
On 6/20/23 1:56?AM, Stefan Metzmacher wrote:
> Hi Jens,
> 
>> If we have cmsg attached AND we transferred partial data at least, clear
>> msg_controllen on retry so we don't attempt to send that again.
>>
>> Cc: stable@vger.kernel.org # 5.10+
>> Fixes: cac9e4418f4c ("io_uring/net: save msghdr->msg_control for retries")
>> Reported-by: Stefan Metzmacher <metze@samba.org>
>> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>>
>> ---
>>
>> diff --git a/io_uring/net.c b/io_uring/net.c
>> index 51b0f7fbb4f5..fe1c478c7dec 100644
>> --- a/io_uring/net.c
>> +++ b/io_uring/net.c
>> @@ -326,6 +326,7 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
>>           if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
>>               return io_setup_async_msg(req, kmsg, issue_flags);
>>           if (ret > 0 && io_net_retry(sock, flags)) {
>> +            kmsg->msg.msg_controllen = 0;
>>               sr->done_io += ret;
>>               req->flags |= REQ_F_PARTIAL_IO;
>>               return io_setup_async_msg(req, kmsg, issue_flags);
>>
> 
> Should we also set 'kmsg->msg.msg_control' to NULL?

We could, but I don't think it matters as we gate any checks on that
anyway. But in terms of completeness, may as well I suppose.
diff mbox series

Patch

diff --git a/io_uring/net.c b/io_uring/net.c
index 51b0f7fbb4f5..fe1c478c7dec 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -326,6 +326,7 @@  int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
 		if (ret == -EAGAIN && (issue_flags & IO_URING_F_NONBLOCK))
 			return io_setup_async_msg(req, kmsg, issue_flags);
 		if (ret > 0 && io_net_retry(sock, flags)) {
+			kmsg->msg.msg_controllen = 0;
 			sr->done_io += ret;
 			req->flags |= REQ_F_PARTIAL_IO;
 			return io_setup_async_msg(req, kmsg, issue_flags);