From 447880fff7f5c28b22ba46cc1df9595987edf592 Mon Sep 17 00:00:00 2001 From: ligc Date: Mon, 10 May 2010 09:49:53 +0000 Subject: [PATCH] ipv6 fix, replace the Socket library calls with NetworkUtils subroutines git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6047 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index f9509e1f3..98cf7f6e9 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -2073,6 +2073,8 @@ sub my_nets { my $rethash; my @nets; + my $v6net; + my $v6ip; if ( $^O eq 'aix') { @nets = split /\n/, `/usr/sbin/ifconfig -a`; @@ -2083,29 +2085,48 @@ sub my_nets } foreach (@nets) { + $v6net = ''; my @elems = split /\s+/; - unless (/^\s*inet\s/) + unless (/^\s*inet/) { next; } my $curnet; my $maskbits; if ( $^O eq 'aix') { - $curnet = $elems[2]; - $maskbits = formatNetmask( $elems[4], 2, 1); + if ($elems[1] eq 'inet6') + { + $v6net=$elems[2]; + $v6ip=$elems[2]; + $v6ip =~ s/\/.*//; # ipv6 address 4000::99/64 + $v6ip =~ s/\%.*//; # ipv6 address ::1%1/128 + } + else + { + $curnet = $elems[2]; + $maskbits = formatNetmask( $elems[4], 2, 1); + } } else { ($curnet, $maskbits) = split /\//, $elems[2]; } - my $curmask = 2**$maskbits - 1 << (32 - $maskbits); - my $nown = unpack("N", inet_aton($curnet)); - $nown = $nown & $curmask; - my $textnet=inet_ntoa(pack("N",$nown)); - $textnet.="/$maskbits"; - $rethash->{$textnet} = $curnet; + if (!$v6net) + { + my $curmask = 2**$maskbits - 1 << (32 - $maskbits); + my $nown = unpack("N", inet_aton($curnet)); + $nown = $nown & $curmask; + my $textnet=inet_ntoa(pack("N",$nown)); + $textnet.="/$maskbits"; + $rethash->{$textnet} = $curnet; + } + else + { + $rethash->{$v6net} = $v6ip; + } } + # now get remote nets my $nettab = xCAT::Table->new("networks"); my $sitetab = xCAT::Table->new("site");