aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2025-04-15 17:16:19 +1000
committerStefano Brivio <sbrivio@redhat.com>2025-04-15 19:43:56 +0200
commit1bb8145c221a9124ca1671e64b27de173ff2d82d (patch)
tree4a6830cbd3e156af16219d2788024a908ea4e2c7
parentbaf049f8e06b7f0a73dfa7913297679a75aad381 (diff)
downloadpasst-1bb8145c221a9124ca1671e64b27de173ff2d82d.tar
passt-1bb8145c221a9124ca1671e64b27de173ff2d82d.tar.gz
passt-1bb8145c221a9124ca1671e64b27de173ff2d82d.tar.bz2
passt-1bb8145c221a9124ca1671e64b27de173ff2d82d.tar.lz
passt-1bb8145c221a9124ca1671e64b27de173ff2d82d.tar.xz
passt-1bb8145c221a9124ca1671e64b27de173ff2d82d.tar.zst
passt-1bb8145c221a9124ca1671e64b27de173ff2d82d.zip
udp: Be quieter about errors on UDP receive
If we get an error on UDP receive, either in udp_peek_addr() or udp_sock_recv(), we'll print an error message. However, this could be a perfectly routine UDP error triggered by an ICMP, which need not go to the error log. This doesn't usually happen, because before receiving we typically clear the error queue from udp_sock_errs(). However, it's possible an error could be flagged after udp_sock_errs() but before we receive. So it's better to handle this error "silently" (trace level only). We'll bail out of the receive, return to the epoll loop, and get an EPOLLERR where we'll handle and report the error properly. In particular there's one situation that can trigger this case much more easily. If we start a new outbound UDP flow to a local destination with nothing listening, we'll get a more or less immediate connection refused error. So, we'll get that error on the very first receive after the connect(). That will occur in udp_flow_defer() -> udp_flush_flow() -> udp_sock_fwd() -> udp_peek_addr() -> recvmsg(). This path doesn't call udp_sock_errs() first, so isn't (imperfectly) protected the way we are most of the time. Fixes: 84ab1305faba ("udp: Polish udp_vu_sock_info() and remove from vu specific code") Fixes: 69e5393c3722 ("udp: Move some more of sock_handler tasks into sub-functions") Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--udp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/udp.c b/udp.c
index f5fb98c..154f99b 100644
--- a/udp.c
+++ b/udp.c
@@ -619,8 +619,8 @@ static int udp_peek_addr(int s, union sockaddr_inany *src,
rc = recvmsg(s, &msg, MSG_PEEK | MSG_DONTWAIT);
if (rc < 0) {
- if (errno != EAGAIN && errno != EWOULDBLOCK)
- warn_perror("Error peeking at socket address");
+ trace("Error peeking at socket address: %s", strerror_(errno));
+ /* Bail out and let the EPOLLERR handler deal with it */
return rc;
}
@@ -664,7 +664,8 @@ static int udp_sock_recv(const struct ctx *c, int s, struct mmsghdr *mmh, int n)
n = recvmmsg(s, mmh, n, 0, NULL);
if (n < 0) {
- err_perror("Error receiving datagrams");
+ trace("Error receiving datagrams: %s", strerror_(errno));
+ /* Bail out and let the EPOLLERR handler deal with it */
return 0;
}