summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsthen <sthen@openbsd.org>2021-01-21 10:31:57 +0000
committersthen <sthen@openbsd.org>2021-01-21 10:31:57 +0000
commit26738f08923e5397f45d6250e088d60dca7351eb (patch)
tree15e1fa9875f04bb57a5bae03f226890d6964db2c
parentRevert r1.87 "Pledge before authentication when possible" (diff)
downloadwireguard-openbsd-26738f08923e5397f45d6250e088d60dca7351eb.tar.xz
wireguard-openbsd-26738f08923e5397f45d6250e088d60dca7351eb.zip
Backport "Squelch udp connect 'no route to host' errors" from upstream.
Problem reported and diff tested by danj@ From 5906811ff19f005110b2edbda5aa144ad5fa05b1 Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" <wouter@nlnetlabs.nl> Date: Tue, 1 Dec 2020 09:09:13 +0100 Subject: [PATCH] - Fix #358: Squelch udp connect 'no route to host' errors on low verbosity.
-rw-r--r--usr.sbin/unbound/services/outside_network.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/usr.sbin/unbound/services/outside_network.c b/usr.sbin/unbound/services/outside_network.c
index 11951adea7b..0886907f7c8 100644
--- a/usr.sbin/unbound/services/outside_network.c
+++ b/usr.sbin/unbound/services/outside_network.c
@@ -1745,6 +1745,33 @@ select_id(struct outside_network* outnet, struct pending* pend,
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
+ 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 +1831,11 @@ select_ifport(struct outside_network* outnet, struct pending* pend,
/* 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;
}