From edeb2a26c663085b3eae0a7eac6eb011a21ae7c3 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sat, 20 Jun 2026 01:26:26 +1000 Subject: udp: Improve messages for errors getting errors 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 Signed-off-by: Stefano Brivio --- udp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/udp.c b/udp.c index d23163f..505e554 100644 --- a/udp.c +++ b/udp.c @@ -693,6 +693,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 +710,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"); return -1; /* no way to clear, unrecoverable */ } -- cgit v1.2.3