[pve-devel] [RFC manager 1/1] proxy: fix wildcard address use

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Apr 30 09:12:09 CEST 2021


On Thu, Apr 29, 2021 at 03:37:02PM +0200, Stoiko Ivanov wrote:
> This patch fixes a regression for hosts disabling ipv6 via kernel
> commandline ('ipv6.disable=1')introduced in commit
> fc087ec2b924dc9c72d3bf80face8a1731c15405
> 
> by hardcoding the address to '::', pveproxy and spiceproxy failed to
> start with:
> 'unable to create socket - Address family not supported by protocol'
> 
> Disabling IPv6 via sysctl did not exhibit these problems.
> 
> This patch depends on the commit in pve-common and needs a versioned
> dependency bump on libpve-common-perl.
> 
> With this patch the listening addresses are (`ss -tlnp |grep 8006` output)
> * disabled via kernel cmdline: '0.0.0.0:8006'
> * disabled via sysctl net.ipv6.conf.all.disable_ipv6=1: '0.0.0.0:8006'
> * else: '*:8006'
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> ---
>  PVE/Service/pveproxy.pm   | 2 +-
>  PVE/Service/spiceproxy.pm | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
> index 4ecd442a..742c0a9a 100755
> --- a/PVE/Service/pveproxy.pm
> +++ b/PVE/Service/pveproxy.pm
> @@ -69,7 +69,7 @@ sub init {
>      my $lockfh = IO::File->new(">>${accept_lock_fn}") ||
>  	die "unable to open lock file '${accept_lock_fn}' - $!\n";
>  
> -    my $listen_ip = $proxyconf->{LISTEN_IP} // "::0";
> +    my $listen_ip = $proxyconf->{LISTEN_IP} // PVE::Tools::get_wildcard_address();
>      my $socket = $self->create_reusable_socket(8006, $listen_ip);

^ This passes `Domain => PF_INET6`. That makes no sense given that I can
literally give it an IPv4 :S

It also actually uses getaddrinfo in the background, however, the
commmit forcing this to be 0 explains:

    perl's IO::Socket::IP passes AI_ADDRCONFIG if no GetAddrInfoFlags are passed,
    which is often useful but also causes it to error when explicitly trying to
    bind to 127.0.0.1 when there are no _other_ IPv4 addresses present.

In this case however, we don't do that, so maybe instead of ending up using
`getaddrinfo` twice, we should just make this an optional parameter?
I'm hoping passing `undef` as host, the proper port and `AI_ADDRCONFIG |
AI_PASSIVE` here should do the same?

We also don't use `$listen_ip` for anything else either, so we don't need it
explicitly ;-)

>  
>      my $dirs = {};
> diff --git a/PVE/Service/spiceproxy.pm b/PVE/Service/spiceproxy.pm
> index 24be0ed7..34882ca4 100755
> --- a/PVE/Service/spiceproxy.pm
> +++ b/PVE/Service/spiceproxy.pm
> @@ -39,7 +39,7 @@ sub init {
>      my $lockfh = IO::File->new(">>${accept_lock_fn}") ||
>  	die "unable to open lock file '${accept_lock_fn}' - $!\n";
>  
> -    my $listen_ip = $proxyconf->{LISTEN_IP} // "::0";
> +    my $listen_ip = $proxyconf->{LISTEN_IP} // PVE::Tools::get_wildcard_address();
>      my $socket = $self->create_reusable_socket(3128, $listen_ip);
>  
>      $self->{server_config} = {
> -- 
> 2.20.1





More information about the pve-devel mailing list