[PATCH 3/3] virNetSocketCheckProtocols: Confirm IPv4 by lookup too

Michal Privoznik mprivozn at redhat.com
Wed Jul 15 11:48:46 UTC 2020

Historically, if we found an interface with an IPv6 address we
did not blindly trust that host is IPv6 capable (as in we can
successfully translate IPv4 addresses) but used getaddrinfo() to
confirm it. Turns out, we have use the same argument for IPv4.
For instance, in an namespace created by the following steps,
getaddrinfo("", ...) fails (demonstrating by "Socket
TCP/IPv4 Accept" test case failing in virnetsockettest):

  unshare -n
  ip link set lo up
  ip link add dummy0 type dummy
  ip link set dummy0 up

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
 src/rpc/virnetsocket.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index b0d63f0f2c..c62c2fb3fc 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -204,6 +204,9 @@ int virNetSocketCheckProtocols(bool *hasIPv4,
+    if (hasIPv4 &&
+        virNetSocketCheckProtocolByLookup("", AF_INET, hasIPv4) < 0)
+        return -1;
     if (hasIPv6 &&
         virNetSocketCheckProtocolByLookup("::1", AF_INET6, hasIPv6) < 0)

More information about the libvir-list mailing list