Add fix for GetChannelPaylodSupport
Currently `getChannelName` throws when the channel number
is invalid.
Because of which the error reported is Unspecified.
Example:
root@gb200nvl-obmc:~# ipmitool raw 0x06 0x4E 0x4
[1] Unable to send RAW command (channel=0x0 netfn=0x6 lun=0x0 cmd=0x4e rsp=0xff): Unspecified error
Added a patch to handle this gracefully
Tested:
Tested on gb200nvl-obmc platform
root@gb200nvl-obmc:~# ipmitool raw 0x06 0x4E 0x4
[2] Unable to send RAW command (channel=0x0 netfn=0x6 lun=0x0 cmd=0x4e rsp=0xcc): Invalid data field in request
Change-Id: Ibc9981d5e7143311f28bb9191fed4d68cd81356b
Signed-off-by: Prithvi Pai <ppai@nvidia.com>
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index e6cb102..c02c407 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -517,6 +517,12 @@
ipmi::Context::ptr& ctx)
{
auto ethdevice = ipmi::getChannelName(ethernetDefaultChannelNum);
+ if (ethdevice.empty())
+ {
+ lg2::error("Channel name does not exist for channel {CHANNEL}",
+ "CHANNEL", ethernetDefaultChannelNum);
+ return std::nullopt;
+ }
ipmi::DbusObjectInfo ethernetObj{};
boost::system::error_code ec = ipmi::getDbusObject(
ctx, ethernetIntf, networkRoot, ethdevice, ethernetObj);
diff --git a/transporthandler.cpp b/transporthandler.cpp
index c9a7492..d99c754 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -1420,8 +1420,16 @@
return responseInvalidFieldRequest();
}
+ auto channelName = ipmi::getChannelName(channel);
+ if (channelName.empty())
+ {
+ lg2::error("Channel name does not exist for channel {CHANNEL}",
+ "CHANNEL", channel);
+ return responseInvalidFieldRequest();
+ }
+
std::string solService{};
- std::string solPathWitheEthName = solPath + ipmi::getChannelName(channel);
+ std::string solPathWitheEthName = solPath + channelName;
if (ipmi::getService(ctx, solInterface, solPathWitheEthName, solService))
{
@@ -1597,8 +1605,16 @@
return responseInvalidFieldRequest();
}
+ auto channelName = ipmi::getChannelName(channel);
+ if (channelName.empty())
+ {
+ lg2::error("Channel name does not exist for channel {CHANNEL}",
+ "CHANNEL", channel);
+ return responseInvalidFieldRequest();
+ }
+
std::string solService{};
- std::string solPathWitheEthName = solPath + ipmi::getChannelName(channel);
+ std::string solPathWitheEthName = solPath + channelName;
if (ipmi::getService(ctx, solInterface, solPathWitheEthName, solService))
{
diff --git a/user_channel/channel_layer.cpp b/user_channel/channel_layer.cpp
index 26bc3fa..e59459f 100644
--- a/user_channel/channel_layer.cpp
+++ b/user_channel/channel_layer.cpp
@@ -30,7 +30,14 @@
// associated with ethernet interface as the channel number to
// eth association is not done. Need to revisit later
struct stat fileStat = {};
- std::string devName("/sys/class/net/" + getChannelName(chNum));
+ auto channelName = getChannelName(chNum);
+ if (channelName.empty())
+ {
+ lg2::error("Channel name does not exist for channel {CHANNEL}",
+ "CHANNEL", chNum);
+ return false;
+ }
+ std::string devName("/sys/class/net/" + channelName);
if (stat(devName.data(), &fileStat) != 0)
{
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index 77297c4..e3658eb 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -152,7 +152,7 @@
{
lg2::error("Get channel name - Invalid channel number: {CHANNEL_ID}",
"CHANNEL_ID", chNum);
- throw std::invalid_argument("Invalid channel number");
+ return "";
}
return channelData[chNum].chName;