From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v2 6/6] udp: Improve messages for errors getting errors
Date: Wed, 17 Jun 2026 13:11:22 +1000 [thread overview]
Message-ID: <20260617031122.2086827-7-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20260617031122.2086827-1-david@gibson.dropbear.id.au>
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 <david@gibson.dropbear.id.au>
---
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
prev parent reply other threads:[~2026-06-17 3:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 3:11 [PATCH v2 0/6] Improvements to flow specific logging David Gibson
2026-06-17 3:11 ` [PATCH v2 1/6] flow: Regularise flow specific logging helpers David Gibson
2026-06-17 3:11 ` [PATCH v2 2/6] flow: Indent flow details messages David Gibson
2026-06-17 3:11 ` [PATCH v2 3/6] flow: Include flow details with higher priority log messages David Gibson
2026-06-17 3:11 ` [PATCH v2 4/6] flow, udp: Fix errno handling in udp_flow_sock() David Gibson
2026-06-17 3:11 ` [PATCH v2 5/6] flow, treewide: Promote priority of selected flow-linked messages David Gibson
2026-06-17 5:23 ` Stefano Brivio
2026-06-17 3:11 ` David Gibson [this message]
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 \
--in-reply-to=20260617031122.2086827-7-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).