From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202408 header.b=nR8cm/bL; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 267275A0275 for ; Fri, 06 Sep 2024 07:17:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202408; t=1725599833; bh=GKNJKRBSLftydbgJ6xpJ1V10akXAARyl+do2+iOopWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nR8cm/bL28XUW7hYTl5HijSBNiVYbZZtMZlMkHKRFl3W1N+c0AH99RNZHKXuM0w8X oPnd1hIVv7xpx6AehOlrB59wpkD89Ck8kObryP8oND9tHHmv+PDrzZ4OW3X9ay2JXo /KZTf3nmnxBBi/p1piMnl9a/vmRwUqxd4dlg7QbjXh0ltebx3YcnzYtVjegtw9br7V JgSHIeU35WUrYDc1r2I7Sljm1PLqcf3wfz9z6diSdrQb1Q+lO2h6RVleGoUblui3b6 G5JERyMBVbNzbZtkPxaa+qy8CLOBoM07YHiZmvjP+VKX/qgph3wbHFdmSDpHQ1hGdP tIUknD+Zt8F8Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4X0Pc95BQ7z4xFt; Fri, 6 Sep 2024 15:17:13 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 6/6] udp: Handle more error conditions in udp_sock_errs() Date: Fri, 6 Sep 2024 15:17:10 +1000 Message-ID: <20240906051710.3863211-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240906051710.3863211-1-david@gibson.dropbear.id.au> References: <20240906051710.3863211-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: TNMTBKJR7HOYZMYGCXO34ADYEMIMVDHB X-Message-ID-Hash: TNMTBKJR7HOYZMYGCXO34ADYEMIMVDHB 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: udp_sock_errs() reads out everything in the socket error queue. However we've seen some cases[0] where an EPOLLERR event is active, but there isn't anything in the queue. One possibility is that the error is reported instead by the SO_ERROR sockopt. Check for that case and report it as best we can. If we still get an EPOLLERR without visible error, we have no way to clear the error state, so treat it as an unrecoverable error. [0] https://github.com/containers/podman/issues/23686#issuecomment-2324945010 Link: https://bugs.passt.top/show_bug.cgi?id=95 Signed-off-by: David Gibson --- udp.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/udp.c b/udp.c index fe5df995..2ba00c9c 100644 --- a/udp.c +++ b/udp.c @@ -450,7 +450,8 @@ static int udp_sock_recverr(int s) static int udp_sock_errs(const struct ctx *c, int s, uint32_t events) { unsigned n_err = 0; - int rc; + socklen_t errlen; + int rc, err; ASSERT(!c->no_udp); @@ -464,6 +465,24 @@ static int udp_sock_errs(const struct ctx *c, int s, uint32_t events) if (rc < 0) return -1; /* error reading error, unrecoverable */ + errlen = sizeof(err); + if (getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0 || + errlen != sizeof(err)) { + err_perror("Error reading SO_ERROR"); + return -1; /* error reading error, unrecoverable */ + } + + if (err) { + debug("Unqueued error on UDP socket %i: %s", s, strerror(err)); + n_err++; + } + + if (!n_err) { + /* EPOLLERR, but no errors to clear !? */ + err("EPOLLERR event without reported errors on socket %i", s); + return -1; /* no way to clear, unrecoverable */ + } + return n_err; } -- 2.46.0