On Sun, Jan 24, 2021 at 12:52:50PM +0100, Theo Buehler wrote:
> Probably better to sync first with the corresponding unbound commit
> https://cvsweb.openbsd.org/src/usr.sbin/unbound/services/outside_network.c#rev1.21
> then adjust udp_connect_needs_log() as needed.
Good call, thanks.
Here's the combined diff that syncs with unbound and adds EADDRNOTAVAIL
in the same fashion.
In case that is OK, I'd commit sync and addition separately.
Feedback? OK?
Index: libunbound/services/outside_network.c
===================================================================
RCS file: /cvs/src/sbin/unwind/libunbound/services/outside_network.c,v
retrieving revision 1.9
diff -u -p -r1.9 outside_network.c
--- libunbound/services/outside_network.c 11 Dec 2020 12:21:40 -0000
1.9
+++ libunbound/services/outside_network.c 24 Jan 2021 12:03:38 -0000
@@ -1745,6 +1745,36 @@ select_id(struct outside_network* outnet
return 1;
}
+/** return true is UDP connect error needs to be logged */
+static int udp_connect_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
+# ifdef EADDRNOTAVAIL
+ case EADDRNOTAVAIL:
+# endif
+ if(verbosity >= VERB_ALGO)
+ return 1;
+ return 0;
+ default:
+ break;
+ }
+ return 1;
+}
+
+
/** Select random interface and port */
static int
select_ifport(struct outside_network* outnet, struct pending* pend,
@@ -1804,9 +1834,11 @@ select_ifport(struct outside_network* ou
/* connect() to the destination */
if(connect(fd, (struct sockaddr*)&pend->addr,
pend->addrlen) < 0) {
- log_err_addr("udp connect failed",
- strerror(errno), &pend->addr,
- pend->addrlen);
+ if(udp_connect_needs_log(errno)) {
+ log_err_addr("udp connect
failed",
+ strerror(errno),
&pend->addr,
+ pend->addrlen);
+ }
sock_close(fd);
return 0;
}