mirror of
git://git.proxmox.com/git/pve-common.git
synced 2025-01-08 01:17:37 +03:00
daemon: explicitly bind to wildcard address.
with the recent change in pve-manager pveproxy (and spiceproxy) try binding to '::' per default. This fails for hosts having disabled ipv6 via kernel commandline. Our desired behavior of binding on '::' and only falling back to '0.0.0.0' in case this is not supported is not directly possible with IO::Socket::IP->new (or rather by Socket::GetAddrInfo, which at least on my system always returns the v4 wildcard-address first). the code now binds to: * the provided $host if not undef * '::' if $host is not set * '0.0.0.0' if $host is not set and binding on '::' yields undef, which means that it failed to create a socket which normally means that IPv6 is disabled Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
9449731c60
commit
2f8be3bfda
@ -819,14 +819,23 @@ sub create_reusable_socket {
|
||||
$socket->fcntl(Fcntl::F_SETFD(), Fcntl::FD_CLOEXEC);
|
||||
} else {
|
||||
|
||||
$socket = IO::Socket::IP->new(
|
||||
LocalHost => $host,
|
||||
my %sockargs = (
|
||||
LocalPort => $port,
|
||||
Listen => SOMAXCONN,
|
||||
Proto => 'tcp',
|
||||
GetAddrInfoFlags => 0,
|
||||
ReuseAddr => 1) ||
|
||||
die "unable to create socket - $@\n";
|
||||
ReuseAddr => 1,
|
||||
);
|
||||
if (defined($host)) {
|
||||
$socket = IO::Socket::IP->new( LocalHost => $host, %sockargs) ||
|
||||
die "unable to create socket - $@\n";
|
||||
} else {
|
||||
# disabling AF_INET6 (by adding ipv6.disable=1 to the kernel cmdline)
|
||||
# causes bind on :: to fail, try 0.0.0.0 in that case
|
||||
$socket = IO::Socket::IP->new( LocalHost => '::', %sockargs) //
|
||||
IO::Socket::IP->new( LocalHost => '0.0.0.0', %sockargs);
|
||||
die "unable to create socket - $@\n" if !$socket;
|
||||
}
|
||||
|
||||
# we often observe delays when using Nagle algorithm,
|
||||
# so we disable that to maximize performance
|
||||
|
Loading…
Reference in New Issue
Block a user