mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-08 01:15:32 +00: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);
|
$socket->fcntl(Fcntl::F_SETFD(), Fcntl::FD_CLOEXEC);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$socket = IO::Socket::IP->new(
|
my %sockargs = (
|
||||||
LocalHost => $host,
|
|
||||||
LocalPort => $port,
|
LocalPort => $port,
|
||||||
Listen => SOMAXCONN,
|
Listen => SOMAXCONN,
|
||||||
Proto => 'tcp',
|
Proto => 'tcp',
|
||||||
GetAddrInfoFlags => 0,
|
GetAddrInfoFlags => 0,
|
||||||
ReuseAddr => 1) ||
|
ReuseAddr => 1,
|
||||||
die "unable to create socket - $@\n";
|
);
|
||||||
|
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,
|
# we often observe delays when using Nagle algorithm,
|
||||||
# so we disable that to maximize performance
|
# so we disable that to maximize performance
|
||||||
|
Loading…
Reference in New Issue
Block a user