[libvirt] [PATCH 1/4] tests: Fix virnetsockettest on FreeBSD

Andrea Bolognani posted 4 patches 6 years, 7 months ago
There is a newer version of this series
[libvirt] [PATCH 1/4] tests: Fix virnetsockettest on FreeBSD
Posted by Andrea Bolognani 6 years, 7 months ago
FreeBSD doesn't let IPv4 clients to connect to IPv6 sockets,
so one of our test cases has to be compiled out there.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 tests/virnetsockettest.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 9f9a243484..d39481067e 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -470,9 +470,19 @@ mymain(void)
         if (virTestRun("Socket TCP/IPv4+IPv6 Accept", testSocketTCPAccept, &tcpData) < 0)
             ret = -1;
 
+        /* From FreeBSD's inet6(4):
+         *
+         *   By default, FreeBSD does not route IPv4 traffic to AF_INET6
+         *   sockets.  The default behavior intentionally violates RFC2553
+         *   for security reasons.  Listen to two sockets if you want to
+         *   accept both IPv4 and IPv6 traffic.
+         *
+         * So this test will never work on FreeBSD, and need to skip it. */
+# ifndef __FreeBSD__
         tcpData.cnode = "::1";
         if (virTestRun("Socket TCP/IPv4+IPv6 Accept", testSocketTCPAccept, &tcpData) < 0)
             ret = -1;
+# endif /* __FreeBSD__ */
     }
 #endif
 
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] tests: Fix virnetsockettest on FreeBSD
Posted by Daniel P. Berrangé 6 years, 7 months ago
On Fri, Apr 27, 2018 at 05:21:20PM +0200, Andrea Bolognani wrote:
> FreeBSD doesn't let IPv4 clients to connect to IPv6 sockets,
> so one of our test cases has to be compiled out there.

Yep, IPV6_V6ONLY is set to true by default, where as it is false
by default on Linux, however, .....

> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>  tests/virnetsockettest.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
> index 9f9a243484..d39481067e 100644
> --- a/tests/virnetsockettest.c
> +++ b/tests/virnetsockettest.c
> @@ -470,9 +470,19 @@ mymain(void)
>          if (virTestRun("Socket TCP/IPv4+IPv6 Accept", testSocketTCPAccept, &tcpData) < 0)
>              ret = -1;
>  
> +        /* From FreeBSD's inet6(4):
> +         *
> +         *   By default, FreeBSD does not route IPv4 traffic to AF_INET6
> +         *   sockets.  The default behavior intentionally violates RFC2553
> +         *   for security reasons.  Listen to two sockets if you want to
> +         *   accept both IPv4 and IPv6 traffic.
> +         *
> +         * So this test will never work on FreeBSD, and need to skip it. */

This code is not supposed to be relying on IPV6_V6ONLY. The testSocketTCPAccept
method is supposed to create multiple listener sockets. We passing NULL as the
listen address, which means we are supposed to get two sockets, one listening
on IPv4 and one on IPv6. So the comment is right about FreeBSD being different
but that situation should not apply to this test AFAIK.

So I'm wondering why it hasn't listened on both sockets...

> +# ifndef __FreeBSD__
>          tcpData.cnode = "::1";
>          if (virTestRun("Socket TCP/IPv4+IPv6 Accept", testSocketTCPAccept, &tcpData) < 0)
>              ret = -1;
> +# endif /* __FreeBSD__ */
>      }
>  #endif
>  
> -- 
> 2.14.3
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] tests: Fix virnetsockettest on FreeBSD
Posted by Andrea Bolognani 6 years, 7 months ago
On Fri, 2018-04-27 at 16:32 +0100, Daniel P. Berrangé wrote:
> > +        /* From FreeBSD's inet6(4):
> > +         *
> > +         *   By default, FreeBSD does not route IPv4 traffic to AF_INET6
> > +         *   sockets.  The default behavior intentionally violates RFC2553
> > +         *   for security reasons.  Listen to two sockets if you want to
> > +         *   accept both IPv4 and IPv6 traffic.
> > +         *
> > +         * So this test will never work on FreeBSD, and need to skip it. */
> 
> This code is not supposed to be relying on IPV6_V6ONLY. The testSocketTCPAccept
> method is supposed to create multiple listener sockets. We passing NULL as the
> listen address, which means we are supposed to get two sockets, one listening
> on IPv4 and one on IPv6. So the comment is right about FreeBSD being different
> but that situation should not apply to this test AFAIK.
> 
> So I'm wondering why it hasn't listened on both sockets...

Mh, you're right, the IPv6 thing was just a red herring: the test
case just seems to fail or succeed pretty much randomly.

I tried compiling out everything but the basic "Socket TCP/IPv4
Accept" part, and even that didn't manage to run successfully for
any extended lenght of time in a tight loop.

I'm afraid we're going to need someone with more network expertise
than I have to look into it.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/4] tests: Fix virnetsockettest on FreeBSD
Posted by Daniel P. Berrangé 6 years, 7 months ago
On Mon, Apr 30, 2018 at 10:29:46AM +0200, Andrea Bolognani wrote:
> On Fri, 2018-04-27 at 16:32 +0100, Daniel P. Berrangé wrote:
> > > +        /* From FreeBSD's inet6(4):
> > > +         *
> > > +         *   By default, FreeBSD does not route IPv4 traffic to AF_INET6
> > > +         *   sockets.  The default behavior intentionally violates RFC2553
> > > +         *   for security reasons.  Listen to two sockets if you want to
> > > +         *   accept both IPv4 and IPv6 traffic.
> > > +         *
> > > +         * So this test will never work on FreeBSD, and need to skip it. */
> > 
> > This code is not supposed to be relying on IPV6_V6ONLY. The testSocketTCPAccept
> > method is supposed to create multiple listener sockets. We passing NULL as the
> > listen address, which means we are supposed to get two sockets, one listening
> > on IPv4 and one on IPv6. So the comment is right about FreeBSD being different
> > but that situation should not apply to this test AFAIK.
> > 
> > So I'm wondering why it hasn't listened on both sockets...
> 
> Mh, you're right, the IPv6 thing was just a red herring: the test
> case just seems to fail or succeed pretty much randomly.
> 
> I tried compiling out everything but the basic "Socket TCP/IPv4
> Accept" part, and even that didn't manage to run successfully for
> any extended lenght of time in a tight loop.
> 
> I'm afraid we're going to need someone with more network expertise
> than I have to look into it.

This kind of nastiness usually requires an strace  log (or whatever BSD
equiv is) to  diagnose. I've got a BSD VM I can try on

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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