Skip to contentSkip to conversation

util: don't use AI_V4MAPPED flag to getaddrinfo on FreeBSD

PATCH New Daniel P. Berrange 1 participant 1 message Mar 31, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 util: don't use AI_V4MAPPED flag to getaddrinfo on FreeBSD

The FreeBSD header files define the AI_V4MAPPED but its implementation of getaddrinfo() always returns an error when that flag is set. eg

address resolution failed for localhost:9000: Invalid value for ai_flags

Since this flag is not critical for DNS lookups, just undefine it on FreeBSD platforms.

---
 util/qemu-sockets.c | 9 +++++++++
 1 file changed, 9 insertions(+)
util/qemu-sockets.c +9 -0
index b87e17f..3007345 100644
@@ -29,6 +29,15 @@
 #ifndef AI_ADDRCONFIG
 # define AI_ADDRCONFIG 0
 #endif
+
+/* FreeBSD defines AI_V4MAPPED in its header files but its
+ * getaddrinfo() implementation always returns an error
+ * when it is used. Tested with FreeBSD 10.2. Recheck new
+ * releases periodically to see if this gets fixed....
+ */
+#if defined(AI_V4MAPPED) && defined(__FreeBSD__)
+# undef AI_V4MAPPED
+#endif
 #ifndef AI_V4MAPPED
 # define AI_V4MAPPED 0
 #endif
Signature · 1 line
2.5.5