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=202606 header.b=Fg47Fis4; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 97BB85A0624 for ; Wed, 17 Jun 2026 05:11:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1781665885; bh=l/NPn11uu/p5PFPARB85PwZsSVlfbWUvMCPK0lZaYxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fg47Fis4dXqvk1L8H1/dvzlo74B+fCXQj6nEmAdnyoKzczKspUBQxlD32wxnpsMfg 0a2Dp9R71oViuoL+UhloOB8/WdwvU7PCuHtQTs/3th9hGMPN+tJn7YyE1M1gZlIQur dAlWVJtqBga0KgohzucShW78nE3IRco73ZZpL/1iYU0+8qOerxoIQSxuV94neQAoxV FyF+4KATFoBhl2wgbJAQLDx9OMWFdPWIiSvcwBFfWaXXeQTfH2fBd0dV9ao4yLwwl2 h2e6BueIDzw7HOLwvZ3vMlZnLn2mn1OWz5/zP7CqLDHHCFZxOw3fKS8YyevkXinIbC iEvBUjRohfk7g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gg85T0YBTz58p2; Wed, 17 Jun 2026 13:11:25 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 6/6] udp: Improve messages for errors getting errors Date: Wed, 17 Jun 2026 13:11:22 +1000 Message-ID: <20260617031122.2086827-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260617031122.2086827-1-david@gibson.dropbear.id.au> References: <20260617031122.2086827-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: ZYZSGJCR2NNLP6HYRCGJXG3VTN6PH532 X-Message-ID-Hash: ZYZSGJCR2NNLP6HYRCGJXG3VTN6PH532 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: If udp_sock_recverr() gets an error retrieving the error queue, or udp_sock_errs() gets an error reading the SO_ERROR sockopt, we log a message with err_perror(), That severity is reasonable - this is something going unexpectedly wrong host side, not merely a connection getting shut down because we hit a network error. However, the messages can be made more useful by linking them to the specific flow, and safer by ratelimiting them. Remove the places where we included the numerical value of the socket fd: that's rarely useful, especially now that we have the context about the flow the fd belonged to. Signed-off-by: David Gibson --- udp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/udp.c b/udp.c index d23163f6..60bcfb89 100644 --- a/udp.c +++ b/udp.c @@ -580,10 +580,12 @@ static int udp_sock_recverr(const struct ctx *c, int s, flow_sidx_t sidx, rc = recvmsg(s, &mh, MSG_ERRQUEUE); if (rc < 0) { + struct udp_flow *uflow = udp_at_sidx(sidx); + if (errno == EAGAIN || errno == EWOULDBLOCK) return 0; - err_perror("UDP: Failed to read error queue"); + flow_perror_ratelimit(uflow, now, "Failed to read error queue"); return -1; } @@ -693,6 +695,7 @@ static int udp_sock_errs(const struct ctx *c, int s, flow_sidx_t sidx, uint8_t pif, in_port_t port, const struct timespec *now) { + struct udp_flow *uflow = udp_at_sidx(sidx); unsigned n_err = 0; socklen_t errlen; int rc, err; @@ -709,18 +712,20 @@ static int udp_sock_errs(const struct ctx *c, int s, flow_sidx_t sidx, errlen = sizeof(err); if (getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0 || errlen != sizeof(err)) { - err_perror("Error reading SO_ERROR"); + flow_perror_ratelimit(uflow, now, "Error reading SO_ERROR"); return -1; /* error reading error, unrecoverable */ } if (err) { - debug("Unqueued error on UDP socket %i: %s", s, strerror_(err)); + flow_dbg(uflow, "Unqueued error on UDP socket: %s", + strerror_(err)); n_err++; } if (!n_err) { /* EPOLLERR, but no errors to clear !? */ - err("EPOLLERR event without reported errors on socket %i", s); + flow_err_ratelimit(uflow, now, + "EPOLLERR event without reported errors", s); return -1; /* no way to clear, unrecoverable */ } -- 2.54.0