@@ -304,6 +304,7 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
struct io_async_msghdr iomsg, *kmsg;
struct socket *sock;
+ unsigned int cflags;
unsigned flags;
int min_ret = 0;
int ret;
@@ -326,6 +327,17 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
(sr->flags & IORING_RECVSEND_POLL_FIRST))
return io_setup_async_msg(req, kmsg, issue_flags);
+ if (io_do_buffer_select(req)) {
+ void __user *buf;
+ size_t len = 0;
+
+ buf = io_buffer_select(req, &len, issue_flags);
+ if (!buf)
+ return -ENOBUFS;
+
+ iov_iter_ubuf(&kmsg->msg.msg_iter, ITER_SOURCE, buf, len);
+ }
+
flags = sr->msg_flags;
if (issue_flags & IO_URING_F_NONBLOCK)
flags |= MSG_DONTWAIT;
@@ -357,7 +369,8 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
ret += sr->done_io;
else if (sr->done_io)
ret = sr->done_io;
- io_req_set_res(req, ret, 0);
+ cflags = io_put_kbuf(req, issue_flags);
+ io_req_set_res(req, ret, cflags);
return IOU_OK;
}
@@ -139,6 +139,7 @@ const struct io_issue_def io_issue_defs[] = {
.pollout = 1,
.ioprio = 1,
.manual_alloc = 1,
+ .buffer_select = 1,
#if defined(CONFIG_NET)
.prep = io_sendmsg_prep,
.issue = io_sendmsg,
Adds provided buffer support for sendmsg as well, see the previous commit that added it to IORING_OP_SEND for a longer explanation of why this makes sense. Signed-off-by: Jens Axboe <axboe@kernel.dk> --- io_uring/net.c | 15 ++++++++++++++- io_uring/opdef.c | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)