From fafeee09054f764a5c3a0356f0920ff5b959b5b2 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sun, 4 Nov 2007 16:06:16 +0000 Subject: [PATCH] IPv6 support for SSL and install monitor git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@36 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Client.pm | 4 +++- xCAT-server-2.0/usr/sbin/xcatd | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/perl-xCAT-2.0/xCAT/Client.pm b/perl-xCAT-2.0/xCAT/Client.pm index 0adeba7f6..afe5695ee 100644 --- a/perl-xCAT-2.0/xCAT/Client.pm +++ b/perl-xCAT-2.0/xCAT/Client.pm @@ -2,7 +2,9 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT::Client; use xCAT::NodeRange; -use IO::Socket::SSL; +use IO::Socket::INET6; +use Socket6; +use IO::Socket::SSL qw(inet6); use XML::Simple; use Data::Dumper; use Storable qw(dclone); diff --git a/xCAT-server-2.0/usr/sbin/xcatd b/xCAT-server-2.0/usr/sbin/xcatd index b7c32b282..509661513 100755 --- a/xCAT-server-2.0/usr/sbin/xcatd +++ b/xCAT-server-2.0/usr/sbin/xcatd @@ -2,11 +2,12 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html use Socket; +use Socket6; use IO::Socket; use IO::Handle; use IO::Select; -use IO::Socket::SSL; -use IO::Socket::INET; +use IO::Socket::INET6; +use IO::Socket::SSL qw(inet6); use XML::Simple; use xCAT::Table; use Data::Dumper; @@ -74,7 +75,7 @@ sub daemonize { my %cmd_handlers; sub do_installm_service { #This function servers as a handler for messages from installing nodes - my $socket = IO::Socket::INET->new(LocalPort=>$sport, + my $socket = IO::Socket::INET6->new(LocalPort=>$sport, Proto => 'tcp', ReuseAddr => 1, Listen => 64); @@ -86,13 +87,20 @@ sub do_installm_service { $SIG{ALRM} = sub { die "XCATTIMEOUT"; }; my $conn; next unless $conn = $socket->accept; - my $client = gethostbyaddr(inet_aton($conn->peerhost),AF_INET); - $client =~ s/\..*//; + my @clients = gethostbyaddr($conn->peeraddr,AF_INET6); + my $validclient=0; my $node; - ($node) = noderange($client); #ensure this is coming from a node IP at least - unless ($node) { #Means the source isn't a valid deal... - close($conn); - next; + foreach my $client (@clients) { + $client =~ s/\..*//; + ($node) = noderange($client); #ensure this is coming from a node IP at least + if ($node) { #Means the source isn't a valid deal... + $validclient=1; + last; + } + } + unless ($validclient) { + close($conn); + next; } eval { alarm(2); @@ -137,8 +145,9 @@ sub do_udp_service { #This function opens up a UDP port #Also, this throttles to handle one message at a time, so no forking either #Explicitly, to handle whatever operations nodes periodically send during discover state #Could be used for heartbeating and such as desired - my $socket = IO::Socket::INET->new(LocalPort => $port, - Proto => 'udp'); + my $socket = IO::Socket::INET6->new(LocalPort => $port, + Proto => 'udp', + Domain => AF_INET); openlog("xCAT UDP",'','local1'); unless ($socket) { syslog("err","xCAT UDP service unable to open port $port: $!");