ipmitool: fix lan print fails on unsupported parameters
After upgrading to ipmitool 1.8.19, ipmitool lan print can only print
out `Set in Progress` and other parameters are missing on our servers.
After bisecting, commit:
351dad24a2 lan: Add processing of get/set specific CCs
is identified to be the source of the problem, where the function
get_lan_param_select is expected to consider severial error codes it
receives as empty response. It then constructs an empty response in `p`
and assigns `p` to `rc` and the control flow falls through to the
default case, which prints the error code in verbose mode and should
return `rc` instead of `NULL`.
This bug has been fixed in the ipmitool upstream, but OpenBMC has not
yet done a version bump, so we will apply a patch to fix it for now.
Upstream URL:
https://codeberg.org/IPMITool/ipmitool/commit/137aeb64cbb493d61d6945cac156aba5f0510780
Tested:
```
root@:~# ipmitool lan print 1
Set in Progress : Set Complete
Auth Type Support :
Auth Type Enable : Callback :
: User :
: Operator :
: Admin :
: OEM :
IP Address Source : DHCP Address
IP Address : 10.10.11.242
Subnet Mask : 255.255.0.0
MAC Address : e8:d5:2b:12:4c:f8
Default Gateway IP : 10.10.10.204
Default Gateway MAC : 00:00:00:00:00:00
802.1q VLAN ID : Disabled
RMCP+ Cipher Suites : 3,17
Cipher Suite Priv Max : aaaaaaaaaaaaaaa
: X=Cipher Suite Unused
: c=CALLBACK
: u=USER
: o=OPERATOR
: a=ADMIN
: O=OEM
Bad Password Threshold : Not Available
root@:~# echo $?
0
```
Google-Bug-Id: 334000794
Change-Id: I615135b509d3995b8182661bc65a80078c8e2aaf
Signed-off-by: David Wang <davidwang@quanta.corp-partner.google.com>
diff --git a/recipes-phosphor/ipmi/ipmitool/0001-lan-fix-lan-print-fails-on-unsupported-parameters.patch b/recipes-phosphor/ipmi/ipmitool/0001-lan-fix-lan-print-fails-on-unsupported-parameters.patch
new file mode 100644
index 0000000..7bc6269
--- /dev/null
+++ b/recipes-phosphor/ipmi/ipmitool/0001-lan-fix-lan-print-fails-on-unsupported-parameters.patch
@@ -0,0 +1,43 @@
+From c78b0a20a285f4e1f14138190f960acae1bac4bc Mon Sep 17 00:00:00 2001
+From: David Wang <davidwang@quantatw.com>
+Date: Fri, 12 Apr 2024 11:09:00 +0800
+Subject: [PATCH] lan: fix lan print fails on unsupported parameters
+
+After upgrading to ipmitool 1.8.19, ipmitool lan print can only print out
+`Set in Progress` and other parameters are missing on our servers. After
+bisecting, commit:
+
+ 351dad24a2 lan: Add processing of get/set specific CCs
+
+is identified to be the source of the problem, where the function
+get_lan_param_select is expected to consider severial error codes it
+receives as empty response. It then constructs an empty response in `p`
+and assigns `p` to `rc` and the control flow falls through to the
+default case, which prints the error code in verbose mode and should
+return `rc` instead of `NULL`.
+
+Patch Tracking Bug: b/336108125
+Upstream info / review: merged (https://codeberg.org/IPMITool/ipmitool/commit/137aeb64cbb493d61d6945cac156aba5f0510780)
+Upstream-Status: Backport
+Justification: bugfix(b/334000794)
+Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
+---
+ lib/ipmi_lanp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/ipmi_lanp.c b/lib/ipmi_lanp.c
+index fe0046f..26e7365 100644
+--- a/lib/ipmi_lanp.c
++++ b/lib/ipmi_lanp.c
+@@ -245,7 +245,7 @@ get_lan_param_select(struct ipmi_intf *intf, uint8_t chan, int param, int select
+ specific_val2str(rsp->ccode,
+ get_lan_cc_vals,
+ completion_code_vals));
+- return NULL;
++ return rc;
+ }
+
+ p->data = rsp->data + 1;
+--
+2.34.1
+
diff --git a/recipes-phosphor/ipmi/ipmitool_%.bbappend b/recipes-phosphor/ipmi/ipmitool_%.bbappend
new file mode 100644
index 0000000..232f0b0
--- /dev/null
+++ b/recipes-phosphor/ipmi/ipmitool_%.bbappend
@@ -0,0 +1,5 @@
+FILESEXTRAPATHS:append:gbmc := "${THISDIR}/${PN}:"
+
+SRC_URI:append:gbmc = " \
+ file://0001-lan-fix-lan-print-fails-on-unsupported-parameters.patch \
+"