2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-12 08:12:33 +00:00

fix(dhcp): keep an ISC host whose omshell line is too long

omshell reads 1023 bytes of a line and parses the rest as a new command.
makedhcp removes the old host of a node before it creates it again, so a
longer "set statements" line, as an iSCSI node with long target and
initiator names can give, left the node without its reservation.

makedhcp now checks every command of a host before it sends any. For a
node whose command is too long, it reports the node and leaves its host
unchanged.
This commit is contained in:
Vinícius Ferrão
2026-09-28 15:08:35 -03:00
parent 0e192f58c8
commit 79461a7280
+25 -4
View File
@@ -1058,6 +1058,19 @@ sub _isc_omapi_host_commands
return $commands;
}
# omshell reads 1023 bytes of a line, and the commands remove the old host before they create it again.
sub _send_isc_omapi_host
{
my ($omshell, $node, $commands) = @_;
my ($long) = grep { length($_) > 1023 } $commands =~ /([^\n]*\n)/g;
return "$node: an omshell command for its DHCP host is " . length($long)
. " bytes, over the 1023 bytes that omshell reads in a line, so makedhcp leaves the host unchanged"
if defined $long;
print $omshell $commands;
return;
}
sub addnode
{
@@ -1315,11 +1328,19 @@ sub addnode
if ($ip ne "DENIED") {
$lstatements = _node_host_statements($node, $lstatements);
}
print $omshell _isc_omapi_host_commands(
$hostname, $mac, $hardwaretype,
$client_nethash{$node}{mgtifname}, $ip, $lstatements,
$has_infiniband_identity
my $error = _send_isc_omapi_host(
$omshell, $node,
_isc_omapi_host_commands(
$hostname, $mac, $hardwaretype,
$client_nethash{$node}{mgtifname}, $ip, $lstatements,
$has_infiniband_identity
)
);
if ($error) {
$callback->({ error => [$error], errorcode => [1] });
$count = $count + 2;
next;
}
unless ($::XCATSITEVALS{externaldhcpservers}) {
unless (grep /#definition for host $node aka host $hostname/, @dhcpconf)
{