mirror of
https://passt.top/passt
synced 2025-05-22 01:05:35 +02:00
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:84ab1305fa
("udp: Polish udp_vu_sock_info() and remove from vu specific code") Fixes:69e5393c37
("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>
This commit is contained in:
parent
baf049f8e0
commit
1bb8145c22
1 changed files with 4 additions and 3 deletions
7
udp.c
7
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue