From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 4BCA05A0287 for ; Wed, 28 Feb 2024 12:25:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1709119522; bh=IPxsLK98qYMF1CEI7GWNVdxdirWyfSM0H0w/a+cC1o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=elLETgJECuxpuI0nfr6G1nWUjWA0ycYxs8ULhhdzJEC6zpEjvtavczwXRobE/9rP2 XRF3puDV1PlcyrNxF2NS37K3Z10FPXvoM3SfB7EZ8CaW3SQoTMzX22yNupMbHX4JKu 8qYBzNha3m9Ja+koN1x7Ol5V1nwBfKQG3mpgVf4d31OQJmlwtu0trmYulB1vVg8NEP sc5lqcLJ4EA6OSRPKv1xqu3c9c2wUmHRsS9SWl01vvuREtDh0o5ivZwS6cL+MYVFpP Z54CDw1wJUqoiuEtSZ8PRgzY6r0X59Sr4Gmy8myDq080fHi4oBPQXvWj6iJhnaCFOW qZcBmeQ4D1hXg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TlBq667xXz4wyq; Wed, 28 Feb 2024 22:25:22 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v3 14/20] tcp_splice: Improve error reporting on connect path Date: Wed, 28 Feb 2024 22:25:14 +1100 Message-ID: <20240228112520.2078220-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228112520.2078220-1-david@gibson.dropbear.id.au> References: <20240228112520.2078220-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 6X4N2MZEOEFPGJZB56NH3YSKN6HJ5FXP X-Message-ID-Hash: 6X4N2MZEOEFPGJZB56NH3YSKN6HJ5FXP X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This makes a number of changes to improve error reporting while connecting a new spliced socket: * We use flow_err() and similar functions so all messages include info on which specific flow was affected * We use strerror() to interpret raw error values * We now report errors on connection (at "trace" level, since this would allow spamming the logs) * We also look up and report some details on EPOLLERR events, which can include connection errors, since we use a non-blocking connect(). Again we use "trace" level since this can spam the logs. Signed-off-by: David Gibson --- tcp_splice.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tcp_splice.c b/tcp_splice.c index 0e5b6524..a202715c 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -367,8 +367,11 @@ static int tcp_splice_connect(const struct ctx *c, struct tcp_splice_conn *conn, } if (connect(conn->s[1], sa, sl)) { - if (errno != EINPROGRESS) + if (errno != EINPROGRESS) { + flow_trace(conn, "Couldn't connect socket for splice: %s", + strerror(errno)); return -errno; + } conn_event(c, conn, SPLICE_CONNECT); } else { @@ -484,8 +487,20 @@ void tcp_splice_sock_handler(struct ctx *c, union epoll_ref ref, if (conn->events == SPLICE_CLOSED) return; - if (events & EPOLLERR) + if (events & EPOLLERR) { + int err, rc; + socklen_t sl = sizeof(err); + + rc = getsockopt(ref.fd, SOL_SOCKET, SO_ERROR, &err, &sl); + if (rc) + flow_err(conn, "Error retrieving SO_ERROR: %s", + strerror(errno)); + else + flow_trace(conn, "Error event on socket: %s", + strerror(err)); + goto close; + } if (conn->events == SPLICE_CONNECT) { if (!(events & EPOLLOUT)) -- 2.43.2