[pve-devel] [PATCH 1/2] pass extra args in next_unused_port functions to IP->new

Wolfgang Bumiller w.bumiller at proxmox.com
Mon May 11 16:24:24 CEST 2015


Instead of assuming a local address of 0.0.0.0, the next_*_port family
of functions can now take extra arguments which will be passed over to
IO::Socket::IP->new. Currently used to pass along the desired protocol
family (AF_INET/AF_INET6).
---
 src/PVE/Tools.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 0e1af09..cc181ee 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -660,7 +660,7 @@ sub wait_for_vnc_port {
 }
 
 sub next_unused_port {
-    my ($range_start, $range_end) = @_;
+    my ($range_start, $range_end, @args) = @_;
 
     # We use a file to register allocated ports.
     # Those registrations expires after $expiretime.
@@ -693,10 +693,10 @@ 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,
-					   Proto     => 0);
+					   Proto     => 0,
+					   @args);
 
 	    if ($sock) {
 		close($sock);
@@ -725,15 +725,15 @@ sub next_unused_port {
 }
 
 sub next_migrate_port {
-    return next_unused_port(60000, 60050);
+    return next_unused_port(60000, 60050, @_);
 }
 
 sub next_vnc_port {
-    return next_unused_port(5900, 6000);
+    return next_unused_port(5900, 6000, @_);
 }
 
 sub next_spice_port {
-    return next_unused_port(61000, 61099);
+    return next_unused_port(61000, 61099, @_);
 }
 
 # NOTE: NFS syscall can't be interrupted, so alarm does 
-- 
2.1.4




More information about the pve-devel mailing list