5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-26 07:21:26 +03:00

add a socket family argument to next_*_port functions

Instead of assuming a local address of 0.0.0.0, the next_*_port family
of functions now takes an optional packet family argument (AF_INET/AF_INET6),
used for ipv6 support.
This commit is contained in:
Wolfgang Bumiller 2015-05-12 09:51:11 +02:00 committed by Dietmar Maurer
parent 4808fea7c0
commit 467752183d

View File

@ -660,7 +660,7 @@ sub wait_for_vnc_port {
}
sub next_unused_port {
my ($range_start, $range_end) = @_;
my ($range_start, $range_end, $family) = @_;
# We use a file to register allocated ports.
# Those registrations expires after $expiretime.
@ -693,9 +693,9 @@ sub next_unused_port {
next if $ports->{$p}; # reserved
my $sock = IO::Socket::IP->new(Listen => 5,
LocalAddr => '0.0.0.0',
LocalPort => $p,
ReuseAddr => 1,
Family => $family,
Proto => 0);
if ($sock) {
@ -725,15 +725,18 @@ sub next_unused_port {
}
sub next_migrate_port {
return next_unused_port(60000, 60050);
my ($family) = @_;
return next_unused_port(60000, 60050, $family);
}
sub next_vnc_port {
return next_unused_port(5900, 6000);
my ($family) = @_;
return next_unused_port(5900, 6000, $family);
}
sub next_spice_port {
return next_unused_port(61000, 61099);
my ($family) = @_;
return next_unused_port(61000, 61099, $family);
}
# NOTE: NFS syscall can't be interrupted, so alarm does