[libvirt] [PATCH 2/2] rpc: treat EADDRNOTAVAIL as non-fatal when listening

2018-07-24 Thread Daniel P . Berrangé
Consider creating a listener socket from a hostname that resolves to
multiple addresses. It might be the case that the hostname resolves to
both an IPv4 and IPv6 address because it is reachable over both
protocols, but the IPv6 connectivity is provided off-host. In such a
case no local NIC will have IPv6 and so bind() would fail with the
EADDRNOTAVAIL errno. Thus it should be treated as non-fatal as long as
at least one socket was succesfully bound.

Signed-off-by: Daniel P. Berrangé 
---
 src/rpc/virnetsocket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 8e04d61e98..044e6d8804 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -382,7 +382,7 @@ int virNetSocketNewListenTCP(const char *nodename,
 #endif
 
 if (bind(fd, runp->ai_addr, runp->ai_addrlen) < 0) {
-if (errno != EADDRINUSE) {
+if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) {
 virReportSystemError(errno, "%s", _("Unable to bind to port"));
 goto error;
 }
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/2] rpc: treat EADDRNOTAVAIL as non-fatal when listening

2018-07-24 Thread Jiri Denemark
On Tue, Jul 24, 2018 at 15:18:10 +0100, Daniel P. Berrangé wrote:
> Consider creating a listener socket from a hostname that resolves to
> multiple addresses. It might be the case that the hostname resolves to
> both an IPv4 and IPv6 address because it is reachable over both
> protocols, but the IPv6 connectivity is provided off-host. In such a
> case no local NIC will have IPv6 and so bind() would fail with the
> EADDRNOTAVAIL errno. Thus it should be treated as non-fatal as long as
> at least one socket was succesfully bound.
> 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  src/rpc/virnetsocket.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
> index 8e04d61e98..044e6d8804 100644
> --- a/src/rpc/virnetsocket.c
> +++ b/src/rpc/virnetsocket.c
> @@ -382,7 +382,7 @@ int virNetSocketNewListenTCP(const char *nodename,
>  #endif
>  
>  if (bind(fd, runp->ai_addr, runp->ai_addrlen) < 0) {
> -if (errno != EADDRINUSE) {
> +if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) {
>  virReportSystemError(errno, "%s", _("Unable to bind to 
> port"));
>  goto error;
>  }

Reviewed-by: Jiri Denemark 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list