From 2fa7fca1ad6fd4da4152e5ce12fddff5fbe36276 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 12:04:21 -0300 Subject: [PATCH] Allow rspconfig to disable VLAN on IPMI BMCs rspconfig vlan= only accepted values 1-4096 with no way to disable VLAN tagging. Users had to resort to raw IPMI commands to clear a stale VLAN after ip=dhcp. - Accept vlan=off/disable/disabled to clear VLAN tagging via standard IPMI parameter 0x14 with the enable bit unset - Fix valid range from 1-4096 to 1-4094 (IEEE 802.1Q) - Use strict digit matching to reject malformed inputs To clear VLAN after a DHCP reset: rspconfig vlan=off Tested on Supermicro IPMI BMC (10.20.0.51). Partially addresses #3725 --- .../references/man1/rspconfig.1.rst | 2 +- xCAT-client/pods/man1/rspconfig.1.pod | 2 +- xCAT-server/lib/xcat/plugins/ipmi.pm | 26 +++++++++++-------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst index 538e223ba..68446e443 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -450,7 +450,7 @@ OPTIONS \ **vlan**\ - Get or set vlan ID. For get vlan ID, if vlan is not enabled, 'BMC VLAN disabled' will be displayed. For set vlan ID, the valid value are [1-4096]. + Get or set VLAN ID. Valid VLAN IDs are 1-4094. On IPMI managed nodes, use \ **vlan=off**\ or \ **vlan=disable**\ to disable VLAN tagging. diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index f452dc2cc..4c70d966a 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -352,7 +352,7 @@ Get or set hostname on the service processor. =item B -Get or set vlan ID. For get vlan ID, if vlan is not enabled, 'BMC VLAN disabled' will be displayed. For set vlan ID, the valid value are [1-4096]. +Get or set VLAN ID. Valid VLAN IDs are 1-4094. On IPMI managed nodes, use B or B to disable VLAN tagging. =item B diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index b6962c9c8..09c19aed8 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -946,18 +946,22 @@ sub setnetinfo { } @cmd = (0x01, $channel_number, 12, @mask); } elsif ($subcommand =~ m/vlan/) { - unless ( int($argument) == $argument ) { - $callback->({ errorcode => [1], error => ["The input $argument is invalid, please input an integer"] }); - return; + if ($argument =~ /^(off|disable|disabled)$/i) { + @cmd = (0x01, $channel_number, 0x14, 0x00, 0x00); + } else { + unless ( $argument =~ /^\d+$/ ) { + $callback->({ errorcode => [1], error => ["The input $argument is invalid, please input an integer or 'off'"] }); + return; + } + unless (($argument>=1) && ($argument<=4094)) { + $callback->({ errorcode => [1], error => ["The input $argument is invalid, valid value [1-4094] or 'off'"] }); + return; + } + my @vlanparam = (); + $vlanparam[0] = ($argument & 0xff); + $vlanparam[1] = 0x80 | (($argument & 0xf00) >> 8); + @cmd = (0x01, $channel_number, 0x14, @vlanparam); } - unless (($argument>=1) && ($argument<=4096)) { - $callback->({ errorcode => [1], error => ["The input $argument is invalid, valid value [1-4096]"] }); - return; - } - my @vlanparam = (); - $vlanparam[0] = ($argument & 0xff); - $vlanparam[1] = 0x80 | (($argument & 0xf00) >> 8); - @cmd = (0x01, $channel_number, 0x14, @vlanparam); } elsif ($subcommand =~ m/ip/ and $argument =~ m/dhcp/) { @cmd = (0x01, $channel_number, 0x4, 0x2); } elsif ($subcommand =~ m/ip/) {