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
This commit is contained in:
parent
b7985bad1e
commit
3dc07052a1
@ -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} ) {
|
||||
|
@ -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
|
||||
###################################
|
||||
|
Loading…
Reference in New Issue
Block a user