mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-20 03:25:18 +00:00
Fix test failure when no IPv6 is avail
When the system doesn't have IPv6 available (e.g. not built into the kernel or the module isn't loaded), you can not create an IPv6 socket. The test determines earlier on that IPv6 isn't available then goes and creates a socket. This makes socket creation conditional on IPv6 availability. (cherry picked from commit faffe26909d8e5cde7e80e5a8f33296ed56dcfc7)
This commit is contained in:
parent
c27523e635
commit
eddceda2f3
@ -90,11 +90,13 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6,
|
||||
if ((s4 = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (*hasIPv6) {
|
||||
if ((s6 = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (setsockopt(s6, IPPROTO_IPV6, IPV6_V6ONLY, &only, sizeof(only)) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
memset(&in4, 0, sizeof(in4));
|
||||
memset(&in6, 0, sizeof(in6));
|
||||
@ -114,6 +116,8 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6,
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (*hasIPv6) {
|
||||
if (bind(s6, (struct sockaddr *)&in6, sizeof(in6)) < 0) {
|
||||
if (errno == EADDRINUSE) {
|
||||
VIR_FORCE_CLOSE(s4);
|
||||
@ -122,6 +126,7 @@ checkProtocols(bool *hasIPv4, bool *hasIPv6,
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
*freePort = BASE_PORT + i;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user