[PATCH 04 of 10 ipv6 V2] tinyproxy: use IPv6 if HGIPV6 is set to 1

Jun Wu quark at fb.com
Mon Feb 20 22:03:36 EST 2017


Excerpts from David Soria Parra's message of 2017-02-20 13:48:40 -0800:
> On Fri, Feb 17, 2017 at 10:51:18AM -0800, Jun Wu wrote:
> > # HG changeset patch
> > # User Jun Wu <quark at fb.com>
> > # Date 1487228025 28800
> > #      Wed Feb 15 22:53:45 2017 -0800
> > # Node ID c34ad0f0fc375de9e2d96d17ddcb644d9054d154
> > # Parent  5e76ef1698fde7a47fa78003beac71324793d051
> > # Available At https://bitbucket.org/quark-zju/hg-draft 
> > #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r c34ad0f0fc37
> > tinyproxy: use IPv6 if HGIPV6 is set to 1
> > 
> > This patch makes tinyproxy.py work in IPv6 mode if HGIPV6 is set to 1.
> > 
> > This will make test-http-proxy.t pass on IPv6 machines.
> > 
> 
> I might be missing something here as I am a bit rusty on Mercurial
> internals, I feel we are not doing the right thing here. I think the
> series is not the correct way to approach the issue. When IPv6 and IPv4
> is available we should bind to both sockets and have the client doing
> proper destination address selection according to rfc6724. According
> to the rfc preferring IPv6 over IPv4 should be the default and I feel
> introducing a specific switch does not test the correct behavior.

Thanks for pointing out the RFC.

The V1 series was ipv6 by default. But buildbot was not happy with all
changes. In order to make all changesets green, I have to temporarily
disable V6 handling, therefore V2 and IPv4 by default.

Since the changes were committed, we could change it to V6 by default now.
Maybe add a flag like --netaddr-family=auto|ipv6|ipv4

> In order to obtain the available localhost addresses we should use
> socket.getaddrinfo() to obtain a list of available v4/v6 addresses and
> bind on both. This should be doable without using HGIPV6 in tinyproxy

As long as "hg serve" sticks to one address family, I don't think it's
useful to make tinyproxy bind on both.

"HGIPV6" is a way to provide hgrc's "web.ipv6" for non-hgrc-aware programs.
So if you'd like to remove "HGIPV6", maybe try remove "web.ipv6" first.

> and dumbhttp. We can use this list to glob() 127.0.0.1 correctly, even in the
> case of FreeBSD jails and don't rely on hardcoded ::1/127.0.0.1 addresses. This

This looks like a separate issue. Note that "getaddrinfo()" just reads
"/etc/hosts", instead of the real interfaces. The list returned by
"getaddrinfo()" cannot be trusted, if we want real interface info.

> should allow us to use IPv6 on a test host correctly when avaialble and fallback
> to IPv4 graciously. I see why we want to introduce switches in tests for v4/v6
> only, but I feel that the current implementation does not correctly test default
> addr selection (which might be part of causing the flakeyness).

Previously, there is no IPv6 support at all. The system has to have a
working IPv4 configuration to run tests. And the port check logic only
checked "localhost", which is simply wrong since "hg serve" binds on all
interfaces.

So in weird situations, the tests will just fail, like:

  - All network interfaces (incl. "lo") do not have IPv4 addresses.
  - The "localhost" hostname does not resolve to an IPv4 address.
  - The port being used by "hg serve" is free on "lo", but not all
    interfaces.

My patches should have made tests just work instead of failing, in the above
situations.

The behavior change that leads to "flakeyness" is mostly about setting
"web.address" to explicitly bind() to localhost only. "localhost" is where
we do port check. Making "hg serve" bind on a single "localhost" interface
looks better than binding on every interface.

I'll fix FreeBSD jail later.

> 
> /D


More information about the Mercurial-devel mailing list