2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-25 03:42:14 +00:00
Files
xcat-core/xCAT-server/lib/xcat/plugins/aaadiscovery.pm
T
Daniel Hilst 0373cd6568 fix(xcat-core): discovery cannot resolve an IPv6 findme and never calls an IPv6 node back
A node that sends its findme request over IPv6 is never discovered. Two
steps fail.

seqdiscovery.pm reads the arp(8) table to turn the client address into a MAC
and looks that MAC up in the mac table. arp(8) prints the IPv4 table only, so
the table holds no row for the client and the plugin logs "Could not find mac
of the <address>" and returns. aaadiscovery.pm, profilednodes.pm, blade.pm and
hpblade.pm carry the same parse. All five interpolate the address into a
regular expression as well, so a dot matches any character and 192.168.201.1
matches the row of 192.168.201.120.

nodediscover.pm then opens a TCP connection to the node to send "restart",
and NetworkUtils::send_tcp_msg does the same for its callers. Both build the
socket with IO::Socket::INET, which has no AF_INET6, so the node receives
nothing and Genesis exits on DISCOVERY_TIMEOUT after 36 attempts.

NetworkUtils gains mac_from_neighbour_table, which takes the text of a
neighbour table and the address and returns the MAC; neighbour_table_text,
which reads arp(8) for IPv4 and "ip -6 neigh show" for IPv6; and
mac_of_neighbour, which joins them. The addresses are compared after both
are normalized, so 2001:db8::2 and its full form are one address. The five
plugins call mac_of_neighbour. open_tcp_socket opens the callback through
IO::Socket::INET6 when it is installed and keeps IO::Socket::INET as the
fallback, the way credentials.pm already does; nodediscover.pm and
send_tcp_msg use it.

networkutils_neighbour_mac.t and networkutils_tcp_callback_family.t fail
without this change.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-11-05 09:44:41 -03:00

52 lines
1.8 KiB
Perl

# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# The first module to deal with hardware discovery request, write the request into "discoverydata" table only
package xCAT_plugin::aaadiscovery;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
}
use lib "$::XCATROOT/lib/perl";
use xCAT::DiscoveryUtils;
use xCAT::NetworkUtils;
sub handled_commands {
return {
findme => 'aaadiscovery',
};
}
sub process_request {
my $req = shift;
my $cb = shift;
my $doreq = shift;
if ($req->{command}->[0] eq 'findme') {
if (defined($req->{discoverymethod}) and defined($req->{discoverymethod}->[0])) {
my $rsp = {};
$rsp->{error}->[0] = "The findme request had been processed by " . $req->{discoverymethod}->[0] . " module";
$cb->($rsp);
return;
}
my $client_ip = $req->{'_xcat_clientip'};
# arp(8) prints the IPv4 table only, and the address used to be interpolated
# into a regular expression, where every dot matched any character.
my $mac;
$mac = xCAT::NetworkUtils->mac_of_neighbour($client_ip);
unless ($mac) {
xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: Failed to get MAC address for $client_ip in arp cache.");
$mac = "$req->{mtm}->[0]*$req->{serial}->[0]";
}
xCAT::MsgUtils->message("S", "xcat.discovery.aaadiscovery: ($mac) Got a discovery request, attempting to discover the node...");
$req->{discoverymethod}->[0] = 'undef';
$req->{_xcat_clientmac}->[0] = $mac;
#Workaround (#4890) for IP changed cases.
xCAT::NetworkUtils->clearcache();
xCAT::DiscoveryUtils->update_discovery_data($req);
return;
}
}
1;