Skip to content

Commit 49dbce5

Browse files
isilenceaxboe
authored andcommitted
io_uring/net: clusterise send vs msghdr branches
We have multiple branches at prep for send vs sendmsg handling, put them together so that the variant handling is more localised. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/33abf666d9ded74cba4da2f0d9fe58e88520dffe.1743202294.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 63b16e4 commit 49dbce5

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

io_uring/net.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,6 @@ int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
395395

396396
sr->done_io = 0;
397397
sr->retry = false;
398-
399-
if (req->opcode != IORING_OP_SEND) {
400-
if (sqe->addr2 || sqe->file_index)
401-
return -EINVAL;
402-
}
403-
404398
sr->len = READ_ONCE(sqe->len);
405399
sr->flags = READ_ONCE(sqe->ioprio);
406400
if (sr->flags & ~SENDMSG_FLAGS)
@@ -426,6 +420,8 @@ int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
426420
return -ENOMEM;
427421
if (req->opcode != IORING_OP_SENDMSG)
428422
return io_send_setup(req, sqe);
423+
if (unlikely(sqe->addr2 || sqe->file_index))
424+
return -EINVAL;
429425
return io_sendmsg_setup(req, sqe);
430426
}
431427

@@ -1303,11 +1299,6 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13031299
}
13041300
}
13051301

1306-
if (req->opcode != IORING_OP_SEND_ZC) {
1307-
if (unlikely(sqe->addr2 || sqe->file_index))
1308-
return -EINVAL;
1309-
}
1310-
13111302
zc->len = READ_ONCE(sqe->len);
13121303
zc->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL | MSG_ZEROCOPY;
13131304
req->buf_index = READ_ONCE(sqe->buf_index);
@@ -1323,6 +1314,8 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13231314
req->flags |= REQ_F_IMPORT_BUFFER;
13241315
return io_send_setup(req, sqe);
13251316
}
1317+
if (unlikely(sqe->addr2 || sqe->file_index))
1318+
return -EINVAL;
13261319
ret = io_sendmsg_setup(req, sqe);
13271320
if (unlikely(ret))
13281321
return ret;

0 commit comments

Comments
 (0)