[ovs-dev] tests: Fix test that tests if the system doesn't support IPv6

Message ID 843c07cf1c578dc1180b4bf86efd7a59a9df199e.1528715735.git.tredaelli@redhat.com
State Accepted
Headers show
Series
  • [ovs-dev] tests: Fix test that tests if the system doesn't support IPv6
Related show

Commit Message

Timothy Redaelli June 11, 2018, 11:15 a.m.
Currently if IPv6 is globally disabled (net.ipv6.conf.all.disable_ipv6=1) or
if IPv6 is disabled on loopback interface (net.ipv6.conf.lo.disable_ipv6=1)
the check doesn't work since no interface have ::1 and EADDRNOTAVAIL is
returned.

This causes a Python exception to be printed, like this:

Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "/usr/lib64/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address

In this case HAVE_IPV6 is not set and all IPv6 tests fails.
This commit fixes the problem by check also for EADDRNOTAVAIL.

CC: Ben Pfaff <blp@ovn.org>
Fixes: 5c1d812d7fb3 ("tests: Avoid printing Python exception for hosts without IPv6 support.")
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 tests/atlocal.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff June 14, 2018, 8:47 p.m. | #1
On Mon, Jun 11, 2018 at 01:15:35PM +0200, Timothy Redaelli wrote:
> Currently if IPv6 is globally disabled (net.ipv6.conf.all.disable_ipv6=1) or
> if IPv6 is disabled on loopback interface (net.ipv6.conf.lo.disable_ipv6=1)
> the check doesn't work since no interface have ::1 and EADDRNOTAVAIL is
> returned.
> 
> This causes a Python exception to be printed, like this:
> 
> Traceback (most recent call last):
>   File "<string>", line 6, in <module>
>   File "/usr/lib64/python2.7/socket.py", line 228, in meth
>     return getattr(self._sock,name)(*args)
> socket.error: [Errno 99] Cannot assign requested address
> 
> In this case HAVE_IPV6 is not set and all IPv6 tests fails.
> This commit fixes the problem by check also for EADDRNOTAVAIL.
> 
> CC: Ben Pfaff <blp@ovn.org>
> Fixes: 5c1d812d7fb3 ("tests: Avoid printing Python exception for hosts without IPv6 support.")
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>

Thanks a lot.

I applied this to master.

Patch

diff --git a/tests/atlocal.in b/tests/atlocal.in
index 4e626266b..6fc30cbf8 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -123,7 +123,7 @@  import sys
 try:
     socket.socket(family=socket.AF_INET6).bind(("::1", 0, 0, 0))
 except socket.error as e:
-    if e.errno == errno.EAFNOSUPPORT:
+    if e.errno == errno.EAFNOSUPPORT or errno.EADDRNOTAVAIL:
         sys.exit(2)
     raise
 '