public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: io-uring <[email protected]>
Subject: [PATCH] io_uring/net: mark socket connected on -EINPROGRESS retry
Date: Fri, 3 Nov 2023 10:53:18 -0600	[thread overview]
Message-ID: <[email protected]> (raw)

With the removal of the retry on -EINPROGRESS, we're not getting the
socket marked connected before another connect attempt is made. This
can result in getting a successful connect completion where we're now
connected, yet it's not marked as such on the net side. A followup
connect request would then return '0' rather than -EISCONN, which then
gets the connectioned marked connected. A second followup would then
correctly return -EISCONN.

If we don't get a socket error on our -EINPROGRESS retry condition,
mark the socket as successfully connected.

Cc: [email protected]
Fixes: 3fb1bd688172 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT")
Link: https://github.com/axboe/liburing/issues/980
Signed-off-by: Jens Axboe <[email protected]>

---

diff --git a/io_uring/net.c b/io_uring/net.c
index 7a8e298af81b..b45ac315ef90 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -1466,8 +1466,15 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
 
 		ret = -ENOTSOCK;
 		socket = sock_from_file(req->file);
-		if (socket)
+		if (socket) {
 			ret = sock_error(socket->sk);
+			if (!ret) {
+				/* no error, mark us connected */
+				lock_sock(socket->sk);
+				socket->state = SS_CONNECTED;
+				release_sock(socket->sk);
+			}
+		}
 		goto out;
 	}
 
-- 
Jens Axboe


                 reply	other threads:[~2023-11-03 16:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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 \
    [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