- Fix to omit UDP receive errors from log, if verbosity low.

These happen because of udp-connect.
This commit is contained in:
W.C.A. Wijngaards 2020-11-26 09:39:54 +01:00
parent f6bf015f90
commit 4a8669612a
2 changed files with 33 additions and 2 deletions

View file

@ -1,3 +1,7 @@
26 November 2020: Wouter
- Fix to omit UDP receive errors from log, if verbosity low.
These happen because of udp-connect.
25 November 2020: Wouter 25 November 2020: Wouter
- with udp-connect ignore connection refused with UDP timeouts. - with udp-connect ignore connection refused with UDP timeouts.
- Fix udp-connect on FreeBSD, do send calls on connected UDP socket. - Fix udp-connect on FreeBSD, do send calls on connected UDP socket.

View file

@ -579,6 +579,32 @@ comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
#endif /* AF_INET6 && IPV6_PKTINFO && HAVE_SENDMSG */ #endif /* AF_INET6 && IPV6_PKTINFO && HAVE_SENDMSG */
} }
/** return true is UDP receive error needs to be logged */
static int udp_recv_needs_log(int err)
{
switch(err) {
case ECONNREFUSED:
# ifdef ENETUNREACH
case ENETUNREACH:
# endif
# ifdef EHOSTDOWN
case EHOSTDOWN:
# endif
# ifdef EHOSTUNREACH
case EHOSTUNREACH:
# endif
# ifdef ENETDOWN
case ENETDOWN:
# endif
if(verbosity >= VERB_ALGO)
return 1;
return 0;
default:
break;
}
return 1;
}
void void
comm_point_udp_ancil_callback(int fd, short event, void* arg) comm_point_udp_ancil_callback(int fd, short event, void* arg)
{ {
@ -621,7 +647,8 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg)
msg.msg_flags = 0; msg.msg_flags = 0;
rcv = recvmsg(fd, &msg, 0); rcv = recvmsg(fd, &msg, 0);
if(rcv == -1) { if(rcv == -1) {
if(errno != EAGAIN && errno != EINTR) { if(errno != EAGAIN && errno != EINTR
&& udp_recv_needs_log(errno)) {
log_err("recvmsg failed: %s", strerror(errno)); log_err("recvmsg failed: %s", strerror(errno));
} }
return; return;
@ -703,7 +730,7 @@ comm_point_udp_callback(int fd, short event, void* arg)
if(rcv == -1) { if(rcv == -1) {
#ifndef USE_WINSOCK #ifndef USE_WINSOCK
if(errno != EAGAIN && errno != EINTR if(errno != EAGAIN && errno != EINTR
&& errno != ECONNREFUSED) && udp_recv_needs_log(errno))
log_err("recvfrom %d failed: %s", log_err("recvfrom %d failed: %s",
fd, strerror(errno)); fd, strerror(errno));
#else #else