Skip to content

Commit 93db98f

Browse files
isilenceaxboe
authored andcommitted
io_uring/net: split send and sendmsg prep helpers
A preparation patch splitting io_sendmsg_prep_setup into two separate helpers for send and sendmsg variants. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/1a2319471ba040e053b7f1d22f4af510d1118eca.1729607201.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e6d4373 commit 93db98f

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

io_uring/net.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,11 @@ static int io_send_setup(struct io_kiocb *req)
385385
return 0;
386386
}
387387

388-
static int io_sendmsg_prep_setup(struct io_kiocb *req, int is_msg)
388+
static int io_sendmsg_setup(struct io_kiocb *req)
389389
{
390-
struct io_async_msghdr *kmsg;
390+
struct io_async_msghdr *kmsg = req->async_data;
391391
int ret;
392392

393-
kmsg = io_msg_alloc_async(req);
394-
if (unlikely(!kmsg))
395-
return -ENOMEM;
396-
if (!is_msg)
397-
return io_send_setup(req);
398393
ret = io_sendmsg_copy_hdr(req, kmsg);
399394
if (!ret)
400395
req->flags |= REQ_F_NEED_CLEANUP;
@@ -440,7 +435,11 @@ int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
440435
if (req->ctx->compat)
441436
sr->msg_flags |= MSG_CMSG_COMPAT;
442437
#endif
443-
return io_sendmsg_prep_setup(req, req->opcode == IORING_OP_SENDMSG);
438+
if (unlikely(!io_msg_alloc_async(req)))
439+
return -ENOMEM;
440+
if (req->opcode != IORING_OP_SENDMSG)
441+
return io_send_setup(req);
442+
return io_sendmsg_setup(req);
444443
}
445444

446445
static void io_req_msg_cleanup(struct io_kiocb *req,
@@ -1278,7 +1277,11 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
12781277
if (req->ctx->compat)
12791278
zc->msg_flags |= MSG_CMSG_COMPAT;
12801279
#endif
1281-
return io_sendmsg_prep_setup(req, req->opcode == IORING_OP_SENDMSG_ZC);
1280+
if (unlikely(!io_msg_alloc_async(req)))
1281+
return -ENOMEM;
1282+
if (req->opcode != IORING_OP_SENDMSG_ZC)
1283+
return io_send_setup(req);
1284+
return io_sendmsg_setup(req);
12821285
}
12831286

12841287
static int io_sg_from_iter_iovec(struct sk_buff *skb,

0 commit comments

Comments
 (0)