From b849ef83e7058ceff2697f8329ce59a58bc07499 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 23 Apr 2009 21:19:03 +0000 Subject: [PATCH] -Validate discovery source is in a dynamic range that xCAT controls -Make MAC discovery contemplate the payload of a discovery packet rather than just contextual data git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3251 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/blade.pm | 15 +++++++++++++-- xCAT-server/lib/xcat/plugins/switch.pm | 23 +++++++++++++---------- xCAT-server/sbin/xcatd | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index dc312b001..7e0f3db6f 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -2143,7 +2143,6 @@ sub process_request { last; } } - unless ($mac) { return }; #Only refresh the the cache when the request permits and no useful answer if ($macmaptimestamp < (time() - 300)) { #after five minutes, invalidate cache @@ -2158,7 +2157,19 @@ sub process_request { process_request(\%invreq,\&fillresps); } } - unless ($macmap{$mac}) { + my $found=0; + if ($mac and $macmap{$mac}) { + $found=1; + } else { + foreach (@{$request->{mac}}) { + /.*\|.*\|([\dABCDEFabcdef:]+)(\||$)/; + if ($1 and $macmap{$1}) { + $found=1; + last; + } + } + } + unless ($found) { return 1; #failure } my $mactab = xCAT::Table->new('mac',-create=>1); diff --git a/xCAT-server/lib/xcat/plugins/switch.pm b/xCAT-server/lib/xcat/plugins/switch.pm index fd5f29506..98da62206 100644 --- a/xCAT-server/lib/xcat/plugins/switch.pm +++ b/xCAT-server/lib/xcat/plugins/switch.pm @@ -37,17 +37,20 @@ sub process_request { last; } } - unless ($mac) { - return; + my $node; + my $firstpass=1; + if ($mac) { + $node = $macmap->find_mac($mac,$req->{cacheonly}->[0]); + $firstpass=0; + } + if (not $node) { # and $req->{checkallmacs}->[0]) { + foreach (@{$req->{mac}}) { + /.*\|.*\|([\dABCDEFabcdef:]+)(\||$)/; + $node = $macmap->find_mac($1,$firstpass); + $firstpass=0; + if ($node) { last; } + } } - my $node = $macmap->find_mac($mac,$req->{cacheonly}->[0]); - #if (not $node and $req->{checkallmacs}->[0]) { - # foreach (@{$req->{mac}}) { - # /.*\|.*\|([\dABCDEFabcdef:]+)(\||$)/; - # $node = $macmap->find_mac($1,$req->{cacheonly}->[0]); - # if ($node) { last; } - # } - #} if ($node) { my $mactab = xCAT::Table->new('mac',-create=>1); diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 60b788b4c..584b9c3ce 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -357,7 +357,7 @@ if ($inet6support) { $req->{'_xcat_clienthost'}=gethostbyaddr($client,AF_INET); $req->{'_xcat_clientip'}=inet_ntoa($client); $req->{'_xcat_clientport'}=$sport; - if (defined($cmd_handlers{"findme"})) { + if (defined($cmd_handlers{"findme"}) and xCAT::Utils->nodeonmynet(inet_ntoa($client))) { #only discover from ips that appear to be on a managed network $req->{cacheonly}->[0] = 1; plugin_command($req,undef,\&build_response); if ($req->{cacheonly}->[0]) {