public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 4/4] tests: fix minor connect flaws
Date: Fri,  7 May 2021 17:22:51 +0100	[thread overview]
Message-ID: <8b81dadc9c5060e7d6099d22ce4f39fcadaf303c.1620404433.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Use inet_aton() to set address, otherwise can lead to problems depending
on endianness.

Also, set user_data only after io_uring_prep_link_timeout(), otherwise
will be rewritten.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/connect.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/connect.c b/test/connect.c
index ab81bb8..91b5578 100644
--- a/test/connect.c
+++ b/test/connect.c
@@ -14,6 +14,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#include <arpa/inet.h>
 
 #include "liburing.h"
 
@@ -125,9 +126,8 @@ static int configure_connect(int fd, struct sockaddr_in* addr)
 	memset(addr, 0, sizeof(*addr));
 	addr->sin_family = AF_INET;
 	addr->sin_port = use_port;
-	addr->sin_addr.s_addr = 0x0100007fU;
-
-	return 0;
+	ret = inet_aton("127.0.0.1", &addr->sin_addr);
+	return ret;
 }
 
 static int connect_socket(struct io_uring *ring, int fd, int *code)
@@ -292,9 +292,9 @@ static int test_connect_timeout(struct io_uring *ring)
 		fprintf(stderr, "unable to get sqe\n");
 		goto err;
 	}
+	io_uring_prep_link_timeout(sqe, &ts, 0);
 	sqe->user_data = 2;
 
-	io_uring_prep_link_timeout(sqe, &ts, 0);
 	ret = io_uring_submit(ring);
 	if (ret != 2) {
 		fprintf(stderr, "submitted %d\n", ret);
-- 
2.31.1


  parent reply	other threads:[~2021-05-07 16:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 16:22 [PATCH liburing 0/4] rsrc tests and fixes Pavel Begunkov
2021-05-07 16:22 ` [PATCH liburing 1/4] sync io_uring.h API file with Linux 5.13 Pavel Begunkov
2021-05-07 16:22 ` [PATCH liburing 2/4] tests: add rsrc tags tests Pavel Begunkov
2021-05-07 16:22 ` [PATCH liburing 3/4] tests: fix timeout-new for old kernels Pavel Begunkov
2021-05-07 16:22 ` Pavel Begunkov [this message]
2021-05-07 16:28 ` [PATCH liburing 0/4] rsrc tests and fixes 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=8b81dadc9c5060e7d6099d22ce4f39fcadaf303c.1620404433.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