aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/config.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-02-17 19:30:05 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-02-17 19:30:05 +0100
commitca5d2708e08d1c24e92639895199c3e835eb54d5 (patch)
tree23d9c5380bfc21157a2b2c273f74d7a001aeef47 /src/config.c
parentwg: do not collide types with libc clashes (diff)
downloadwireguard-tools-ca5d2708e08d1c24e92639895199c3e835eb54d5.tar.xz
wireguard-tools-ca5d2708e08d1c24e92639895199c3e835eb54d5.zip
wg: FreeBSD doesn't have EAI_NODATA
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index 93c39fa..b07aa46 100644
--- a/src/config.c
+++ b/src/config.c
@@ -224,8 +224,21 @@ static inline bool parse_endpoint(struct sockaddr *endpoint, const char *value)
if (!ret)
break;
timeout = timeout * 3 / 2;
- /* The set of return codes that are "permanent failures". All other possibilities are potentially transient. */
- if (ret == EAI_NONAME || ret == EAI_FAIL || ret == EAI_NODATA || timeout >= 90000000) {
+ /* The set of return codes that are "permanent failures". All other possibilities are potentially transient.
+ *
+ * This is according to https://sourceware.org/glibc/wiki/NameResolver which states:
+ * "From the perspective of the application that calls getaddrinfo() it perhaps
+ * doesn't matter that much since EAI_FAIL, EAI_NONAME and EAI_NODATA are all
+ * permanent failure codes and the causes are all permanent failures in the
+ * sense that there is no point in retrying later."
+ *
+ * So this is what we do, except FreeBSD removed EAI_NODATA some time ago, so that's conditional.
+ */
+ if (ret == EAI_NONAME || ret == EAI_FAIL ||
+ #ifdef EAI_NODATA
+ ret == EAI_NODATA ||
+ #endif
+ timeout >= 90000000) {
free(mutable);
fprintf(stderr, "%s: `%s'\n", ret == EAI_SYSTEM ? strerror(errno) : gai_strerror(ret), value);
return false;