diff mbox series

[4/4] qemu-sockets: do not require configured ipv4/ipv6 address

Message ID 20190523234011.583-5-marcandre.lureau@redhat.com
State New
Headers show
Series tests/docker: add podman support | expand

Commit Message

Marc-André Lureau May 23, 2019, 11:40 p.m. UTC
podman containers without network don't have ipv4/ipv6 addresses other
than loopback address. However, some of our tests require
getaddrinfo("127.0.0.1") to succeed.

Alternatively, we may want to treat 127.0.0.1 as a special case, to
keep the AI_ADDRCONFIG convenience.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 util/qemu-sockets.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Daniel P. Berrangé June 5, 2019, 3:06 p.m. UTC | #1
On Fri, May 24, 2019 at 01:40:11AM +0200, Marc-André Lureau wrote:
> podman containers without network don't have ipv4/ipv6 addresses other
> than loopback address. However, some of our tests require
> getaddrinfo("127.0.0.1") to succeed.
> 
> Alternatively, we may want to treat 127.0.0.1 as a special case, to
> keep the AI_ADDRCONFIG convenience.

Keeping AI_ADDRCONFIG is mandatory as this is required for correctly
operating IPv4/IPv6 dual stack support.

In tests/socket-helpers.h I have a couple of APIs designed to help
in this case.

  int socket_can_bind_connect(const char *hostname);
  int socket_check_protocol_support(bool *has_ipv4, bool *has_ipv6);

The latter function just calls the former with "127.0.0.1" and
"::1" and reports results =.

The intention is that any test which relies on using getaddrinfo()
should call one of these functions, and then skip any tests which
have a dependancy on this working.

We certainly don't do these checks it all our tests right now
though, so it is not surprising if some fail.


Regards,
Daniel
diff mbox series

Patch

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 8850a280a8..f9c1392a05 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -31,10 +31,6 @@ 
 #include "qapi/qobject-output-visitor.h"
 #include "qemu/cutils.h"
 
-#ifndef AI_ADDRCONFIG
-# define AI_ADDRCONFIG 0
-#endif
-
 #ifndef AI_V4MAPPED
 # define AI_V4MAPPED 0
 #endif
@@ -385,7 +381,7 @@  static struct addrinfo *inet_parse_connect_saddr(InetSocketAddress *saddr,
 
     memset(&ai, 0, sizeof(ai));
 
-    ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
+    ai.ai_flags = AI_CANONNAME;
     if (atomic_read(&useV4Mapped)) {
         ai.ai_flags |= AI_V4MAPPED;
     }
@@ -472,7 +468,7 @@  static int inet_dgram_saddr(InetSocketAddress *sraddr,
 
     /* lookup peer addr */
     memset(&ai,0, sizeof(ai));
-    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED | AI_ADDRCONFIG;
+    ai.ai_flags = AI_CANONNAME | AI_V4MAPPED;
     ai.ai_family = inet_ai_family_from_address(sraddr, &err);
     ai.ai_socktype = SOCK_DGRAM;