Skip to contentSkip to conversation

io_uring/net: mark socket connected on -EINPROGRESS retry

PATCH New Jens Axboe 1 participant 1 message Nov 3, 2023 io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring/net: mark socket connected on -EINPROGRESS retry

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.

Fixes 3fb1bd688172 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT")

---

io_uring/net.c +8 -1
index 7a8e298af81b..b45ac315ef90 100644
@@ -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;
 	}
 
Signature · 1 line
Jens Axboe