diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2024-10-22 17:43:12 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-10-29 22:43:27 +0300 |
commit | 93db98f6f1d62c9e58787f6beb62245ddb91f354 (patch) | |
tree | ae4f2b30256a1bfcc64c7036d4f4649d61430162 /io_uring/net.c | |
parent | e6d43739d0ee49a39505d696ba6a656f47c2bd39 (diff) | |
download | linux-93db98f6f1d62c9e58787f6beb62245ddb91f354.tar.xz |
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>
Diffstat (limited to 'io_uring/net.c')
-rw-r--r-- | io_uring/net.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/io_uring/net.c b/io_uring/net.c index b9e7e496ae85..aa256aa46409 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -385,16 +385,11 @@ static int io_send_setup(struct io_kiocb *req) return 0; } -static int io_sendmsg_prep_setup(struct io_kiocb *req, int is_msg) +static int io_sendmsg_setup(struct io_kiocb *req) { - struct io_async_msghdr *kmsg; + struct io_async_msghdr *kmsg = req->async_data; int ret; - kmsg = io_msg_alloc_async(req); - if (unlikely(!kmsg)) - return -ENOMEM; - if (!is_msg) - return io_send_setup(req); ret = io_sendmsg_copy_hdr(req, kmsg); if (!ret) req->flags |= REQ_F_NEED_CLEANUP; @@ -440,7 +435,11 @@ int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) if (req->ctx->compat) sr->msg_flags |= MSG_CMSG_COMPAT; #endif - return io_sendmsg_prep_setup(req, req->opcode == IORING_OP_SENDMSG); + if (unlikely(!io_msg_alloc_async(req))) + return -ENOMEM; + if (req->opcode != IORING_OP_SENDMSG) + return io_send_setup(req); + return io_sendmsg_setup(req); } 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) if (req->ctx->compat) zc->msg_flags |= MSG_CMSG_COMPAT; #endif - return io_sendmsg_prep_setup(req, req->opcode == IORING_OP_SENDMSG_ZC); + if (unlikely(!io_msg_alloc_async(req))) + return -ENOMEM; + if (req->opcode != IORING_OP_SENDMSG_ZC) + return io_send_setup(req); + return io_sendmsg_setup(req); } static int io_sg_from_iter_iovec(struct sk_buff *skb, |