diff options
author | Johnathan Mantey <johnathanx.mantey@intel.com> | 2022-08-16 00:38:36 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-08-30 05:56:37 +0300 |
commit | 58283f41276f86666aca6943e7405a20a1ff38b6 (patch) | |
tree | ccb41d298191ca90f41d7b234ebe4532abb1dfb8 | |
parent | db18fc98241b4fc9a4274f45c1d6b07d7bd1b93d (diff) | |
download | bmcweb-58283f41276f86666aca6943e7405a20a1ff38b6.tar.xz |
Report MACAddress is read-only for a D-Bus Not Allowed response
The BMC Manager MACAddress ethernet property is a Read/Write property
in the Redfish spec. There are OpenBMC users that configure the
property to be Read Only. The phosphor-network build includes a
'persist-mac' configuration switch which controls MAC address
assignment. An attempt to set a R/O MACAddress causes D-Bus to return
an error. The exact error is available in a sdbus message.
The EthernetInterface XML indicates this is acceptable behavior:
"If an assignable MAC address is not supported, this value is a
read-only alias of the PermanentMACAddress."
As this condition is considered proper behavior it is incorrect to
return an internalError(). It is better behavior to return a
"Read-only" error message.
Tested:
Performed a Redfish PATCH for the MACAddress property.
The PATCH command returns a 403 error code, and a message body
indicating that the MACAddress is not writable.
Change-Id: Ice97affe694f4bee15436293c9e5944bcae7f4cc
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 5ccc25fe39..0469f74098 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -1123,10 +1123,25 @@ inline void const std::string& macAddress, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { + static constexpr std::string_view dbusNotAllowedError = + "xyz.openbmc_project.Common.Error.NotAllowed"; + crow::connections::systemBus->async_method_call( - [asyncResp, macAddress](const boost::system::error_code ec) { + [asyncResp, macAddress](const boost::system::error_code ec, + const sdbusplus::message::message& msg) { if (ec) { + const sd_bus_error* err = msg.get_error(); + if (err == nullptr) + { + messages::internalError(asyncResp->res); + return; + } + if (err->name == dbusNotAllowedError) + { + messages::propertyNotWritable(asyncResp->res, "MACAddress"); + return; + } messages::internalError(asyncResp->res); return; } |