From 3dc07052a1761075486d40d4a07cd55827f26bf0 Mon Sep 17 00:00:00 2001 From: ligc Date: Mon, 31 May 2010 08:15:32 +0000 Subject: [PATCH] IPv6 fix: validate ip address git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6273 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCmac.pm | 56 +++++++++++++++++++++++----------------- perl-xCAT/xCAT/Utils.pm | 5 ++++ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/perl-xCAT/xCAT/PPCmac.pm b/perl-xCAT/xCAT/PPCmac.pm index a9b4944c0..dc7794d70 100644 --- a/perl-xCAT/xCAT/PPCmac.pm +++ b/perl-xCAT/xCAT/PPCmac.pm @@ -82,29 +82,6 @@ sub parse_args { my $server_ip; my %server_nethash; - my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( $node ); - ##################################### - # Network attributes undefined - ##################################### - if ( !%client_nethash ) { - return( [RC_ERROR,"Cannot get network information for node"] ); - } - - if ( exists($opt{C}) ) { - if ( scalar(@$node) > 1 ) { - return( [RC_ERROR,"Option '-C' doesn't work with noderange\n"] ); - } - push @network, $_; - } else { - # get, check the node IP - $client_ip = xCAT::NetworkUtils->getipaddr(@$node[0]); - chomp $client_ip; - if ( $client_ip ) { - $opt{C} = $client_ip; - push @network, $client_ip; - } - } - #################################### # Set server IP #################################### @@ -148,6 +125,39 @@ sub parse_args { } } + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( $node ); + ##################################### + # Network attributes undefined + ##################################### + if ( !%client_nethash ) { + # IPv6, the client ip address may not be available, + # if the link local address is being used, + # the link local address is calculated from mac address + if ($opt{S} =~ /:/) { + #get the network "fe80::" + my $tmpll = "fe80::1"; + %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$tmpll] ); + } else { + return( [RC_ERROR,"Cannot get network information for node"] ); + } + } + + if ( exists($opt{C}) ) { + if ( scalar(@$node) > 1 ) { + return( [RC_ERROR,"Option '-C' doesn't work with noderange\n"] ); + } + push @network, $_; + } else { + # get, check the node IP + $client_ip = xCAT::NetworkUtils->getipaddr(@$node[0]); + chomp $client_ip; + if ( $client_ip ) { + $opt{C} = $client_ip; + push @network, $client_ip; + } + } + + if ( exists($opt{G}) ) { push @network, $_; } elsif ( $client_nethash{@$node[0]}{net} eq $server_nethash{$server}{net} ) { diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 049a461ea..0fc07a59d 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3910,6 +3910,11 @@ sub validate_ip my ($class, @IPs) = @_; foreach (@IPs) { my $ip = $_; + #TODO need more check for IPv6 address + if ($ip =~ /:/) + { + return([0]); + } ################################### # Length is 4 for IPv4 addresses ###################################