From d71c7f7ac685c4ae14565737388ab671b97180df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sun, 3 May 2026 18:36:37 -0300 Subject: [PATCH] Improve rspconfig SET readback and fix backupgateway SET target On some BMCs (notably Supermicro), a GET immediately after SET returns the old value until the BMC applies the change. This made rspconfig output misleading for network setting operations. - Store the canonical SET value after normalization and compare with the GET readback for ip, netmask, gateway, and backupgateway. When they differ, annotate the output: "BMC Gateway: 10.20.0.1 (requested 10.20.0.254, not yet reflected)" - Consolidate ip/netmask/gateway/backupgateway display into one block - Fix backupgateway SET: was routed through the gateway branch writing parameter 0x0C instead of 0x0E. Now has its own branch writing the correct IPMI parameter. - ip=dhcp is unaffected (separate code path, never stores a value) Tested on Supermicro IPMI BMC (10.20.0.51). Fixes #3445 --- xCAT-server/lib/xcat/plugins/ipmi.pm | 54 +++++++++++++--------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 0553acdc7..93bc0f6d6 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -936,15 +936,25 @@ sub setnetinfo { foreach (0 .. 3) { $mask[$_] = $mask[$_] + 0; } + $sessdata->{setnetinfo_value} = join(".", @mask); @cmd = (0x01, $channel_number, 0x6, @mask); } - } elsif ($subcommand =~ m/gateway/ and $argument) { + } elsif ($subcommand eq "gateway" and $argument) { my $gw = inet_ntoa(inet_aton($argument)); my @mask = split /\./, $gw; foreach (0 .. 3) { $mask[$_] = $mask[$_] + 0; } - @cmd = (0x01, $channel_number, 12, @mask); + $sessdata->{setnetinfo_value} = $gw; + @cmd = (0x01, $channel_number, 0x0C, @mask); + } elsif ($subcommand eq "backupgateway" and $argument) { + my $gw = inet_ntoa(inet_aton($argument)); + my @mask = split /\./, $gw; + foreach (0 .. 3) { + $mask[$_] = $mask[$_] + 0; + } + $sessdata->{setnetinfo_value} = $gw; + @cmd = (0x01, $channel_number, 0x0E, @mask); } elsif ($subcommand =~ m/vlan/) { unless ( int($argument) == $argument ) { $callback->({ errorcode => [1], error => ["The input $argument is invalid, please input an integer"] }); @@ -975,6 +985,7 @@ sub setnetinfo { foreach (0 .. 3) { $mask[$_] = $mask[$_] + 0; } + $sessdata->{setnetinfo_value} = $mip; @cmd = (0x01, $channel_number, 0x3, @mask); } @@ -1165,34 +1176,17 @@ sub getnetinfo_response { } else { xCAT::SvrUtils::sendmsg("BMC VLAN disabled" . $bmcifo, $callback, $sessdata->{node}, %allerrornodes); } - } elsif ($subcommand eq "ip") { - xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d" . $bmcifo, - "BMC IP:", - $returnd[2], - $returnd[3], - $returnd[4], - $returnd[5]), $callback, $sessdata->{node}, %allerrornodes); - } elsif ($subcommand eq "netmask") { - xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d" . $bmcifo, - "BMC Netmask:", - $returnd[2], - $returnd[3], - $returnd[4], - $returnd[5]), $callback, $sessdata->{node}, %allerrornodes); - } elsif ($subcommand eq "gateway") { - xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d" . $bmcifo, - "BMC Gateway:", - $returnd[2], - $returnd[3], - $returnd[4], - $returnd[5]), $callback, $sessdata->{node}, %allerrornodes); - } elsif ($subcommand eq "backupgateway") { - xCAT::SvrUtils::sendmsg(sprintf("$format %d.%d.%d.%d" . $bmcifo, - "BMC Backup Gateway:", - $returnd[2], - $returnd[3], - $returnd[4], - $returnd[5]), $callback, $sessdata->{node}, %allerrornodes); + } elsif ($subcommand =~ /^(ip|netmask|gateway|backupgateway)$/) { + my %labels = (ip => "BMC IP:", netmask => "BMC Netmask:", gateway => "BMC Gateway:", backupgateway => "BMC Backup Gateway:"); + my $current = sprintf("%d.%d.%d.%d", $returnd[2], $returnd[3], $returnd[4], $returnd[5]); + my $requested = delete $sessdata->{setnetinfo_value}; + if (defined($requested) and $requested ne $current) { + xCAT::SvrUtils::sendmsg(sprintf("$format %s (requested %s, not yet reflected)" . $bmcifo, + $labels{$subcommand}, $current, $requested), $callback, $sessdata->{node}, %allerrornodes); + } else { + xCAT::SvrUtils::sendmsg(sprintf("$format %s" . $bmcifo, + $labels{$subcommand}, $current), $callback, $sessdata->{node}, %allerrornodes); + } } elsif ($subcommand eq "community") { my $text = sprintf("$format ", "SP SNMP Community:"); my $l = 2;