From 737779fc4a284d7e3fb96bbf99d2d3d43681d599 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 17 Jan 2011 20:24:28 +0000 Subject: [PATCH] -Fix mistake in previous checkin -Implement 'nodeonmynet' ipv6 linux git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8687 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/NetworkUtils.pm | 6 +++--- perl-xCAT/xCAT/Utils.pm | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 14790df3c..a0a1ebdf6 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -347,15 +347,15 @@ sub ishostinsubnet { if ($mask) { $mask=getipaddr($mask,GetNumber=>1); } else { #CIDR notation supported - if ($ip =~ /\//) { - ($ip,$mask) = split /\//,$ip,2; + if ($subnet =~ /\//) { + ($subnet,$mask) = split /\//,$subnet,2; $mask=Math::BigInt->new("0b".("1"x$mask).("0"x($numbits-$mask))); } else { die "ishostinsubnet must either be called with a netmask or CIDR /bits notation"; } } $ip = getipaddr($ip,GetNumber=>1); - $subnet = getipaddr($ip,GetNumber=>1); + $subnet = getipaddr($subnet,GetNumber=>1); $ip &= $mask; if ($ip == $subnet) { return 1; diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index b1354308f..76cc374cb 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -2704,8 +2704,20 @@ sub nodeonmynet } } + } else { + my @v6routes = split /\n/,`ip -6 route`; + foreach (@v6routes) { + if (/via/ or /^unreachable/ or /^fe80::\/64/) { #only count local ones, remote ones can be caught in next loop + #also, link-local would be a pitfall, since more context than address is + #needed to determine locality + next; + } + s/ .*//; #remove all after the space + if (xCAT::NetworkUtils->ishostinsubnet($nodeip,'',$_)) { #bank on CIDR support + return 1; + } + } } - #TODO, ipv6 on Linux my $nettab=xCAT::Table->new("networks"); my @vnets = $nettab->getAllAttribs('net','mgtifname','mask'); foreach (@vnets) {