From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 1/4] tests: verify that send addr is copied when async
Date: Fri, 2 Sep 2022 12:12:36 +0100 [thread overview]
Message-ID: <67fa1af95c4565ef0e9f43833b67d6c4d50d66f6.1662116617.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
The kernel should not be touching timespec after returning from submit
syscall, make sure it's not reloaded after a request goes async.
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/send-zerocopy.c | 69 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 307c114..97727e3 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -836,6 +836,69 @@ static int test_inet_send(struct io_uring *ring)
return 0;
}
+static int test_async_addr(struct io_uring *ring)
+{
+ struct io_uring_sqe *sqe;
+ struct io_uring_cqe *cqe;
+ struct sockaddr_storage addr;
+ int sock_tx = -1, sock_rx = -1;
+ struct __kernel_timespec ts;
+ int ret;
+
+ ret = prepare_ip(&addr, &sock_tx, &sock_rx, true, false, false, false);
+ if (ret) {
+ fprintf(stderr, "sock prep failed %d\n", ret);
+ return 1;
+ }
+
+ sqe = io_uring_get_sqe(ring);
+ ts.tv_sec = 1;
+ ts.tv_nsec = 0;
+ io_uring_prep_timeout(sqe, &ts, 0, IORING_TIMEOUT_ETIME_SUCCESS);
+ sqe->user_data = 1;
+ sqe->flags |= IOSQE_IO_LINK;
+
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_sendzc(sqe, sock_tx, tx_buffer, 1, 0, 0, 0);
+ sqe->user_data = 2;
+ io_uring_prep_sendzc_set_addr(sqe, (const struct sockaddr *)&addr,
+ sizeof(struct sockaddr_in6));
+
+ ret = io_uring_submit(ring);
+ assert(ret == 2);
+ memset(&addr, 0, sizeof(addr));
+
+ ret = io_uring_wait_cqe(ring, &cqe);
+ if (ret) {
+ fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
+ return 1;
+ }
+ if (cqe->user_data != 1 || cqe->res != -ETIME) {
+ fprintf(stderr, "invalid timeout res %i %i\n",
+ (int)cqe->user_data, cqe->res);
+ return 1;
+ }
+ io_uring_cqe_seen(ring, cqe);
+
+ ret = io_uring_wait_cqe(ring, &cqe);
+ if (ret) {
+ fprintf(stderr, "io_uring_wait_cqe failed %i\n", ret);
+ return 1;
+ }
+ if (cqe->user_data != 2 || cqe->res != 1) {
+ fprintf(stderr, "invalid send %i %i\n",
+ (int)cqe->user_data, cqe->res);
+ return 1;
+ }
+ io_uring_cqe_seen(ring, cqe);
+ ret = recv(sock_rx, rx_buffer, 1, MSG_TRUNC);
+ assert(ret == 1);
+
+ close(sock_tx);
+ close(sock_rx);
+ return 0;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring;
@@ -973,6 +1036,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "test_inet_send() failed\n");
return ret;
}
+
+ ret = test_async_addr(&ring);
+ if (ret) {
+ fprintf(stderr, "test_async_addr() failed\n");
+ return ret;
+ }
out:
io_uring_queue_exit(&ring);
close(sp[0]);
--
2.37.2
next prev parent reply other threads:[~2022-09-02 11:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 11:12 [PATCH liburing 0/4] zerocopy send API changes Pavel Begunkov
2022-09-02 11:12 ` Pavel Begunkov [this message]
2022-09-02 11:12 ` [PATCH liburing 2/4] zc: adjust sendzc to the simpler uapi Pavel Begunkov
2022-09-02 11:12 ` [PATCH liburing 3/4] test: test iowq zc sends Pavel Begunkov
2022-09-02 11:12 ` [PATCH liburing 4/4] examples: adjust zc bench to the new uapi Pavel Begunkov
2022-09-02 11:56 ` [PATCH liburing 0/4] zerocopy send API changes Ammar Faizi
2022-09-02 12:01 ` Ammar Faizi
2022-09-02 12:03 ` Jens Axboe
2022-09-02 12:07 ` Pavel Begunkov
2022-09-02 12:11 ` Jens Axboe
2022-09-02 11:57 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67fa1af95c4565ef0e9f43833b67d6c4d50d66f6.1662116617.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox