From 79461a7280d8e0539902dabb183fdf398fccf94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Mon, 28 Sep 2026 15:08:35 -0300 Subject: [PATCH] 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. --- xCAT-server/lib/xcat/plugins/dhcp.pm | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 5999da459..b58c666ba 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -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) {