diff options
author | Jiaqing Zhao <jiaqing.zhao@intel.com> | 2022-04-14 14:14:45 +0300 |
---|---|---|
committer | Jiaqing Zhao <jiaqing.zhao@intel.com> | 2022-05-25 04:48:51 +0300 |
commit | 3927e13ebcd7e4b30b64f7787f76c42b5c35d089 (patch) | |
tree | 61d058bb35da54dd66e426ec7a8abd72fd89b8c8 | |
parent | 17e220249df3d8215261fb7f27878045aeded858 (diff) | |
download | bmcweb-3927e13ebcd7e4b30b64f7787f76c42b5c35d089.tar.xz |
ethernet: Remove PATCH VLANId support
phosphor-networkd does not support changing VLAN ID of an existing VLAN
interface. Though the DBus property can be updated, the change never
takes effect. This patch disallows PATCH VLANId requests.
Tested:
PATCH {"VLANId": 3} /redfish/v1/Managers/bmc/EthernetInterfaces/eth0
/VLANs/eth0_1 returns PropertyNotWritable error.
Change-Id: Ice43064de761d63aa3cfde8019e5d4db138fcf02
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index d451904c50..e7f6b8b57c 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -2144,8 +2144,8 @@ inline void requestEthernetInterfacesRoutes(App& app) return; } - bool vlanEnable = false; - uint32_t vlanId = 0; + std::optional<bool> vlanEnable; + std::optional<uint32_t> vlanId; if (!json_util::readJsonPatch(req, asyncResp->res, "VLANEnable", vlanEnable, "VLANId", vlanId)) @@ -2153,11 +2153,17 @@ inline void requestEthernetInterfacesRoutes(App& app) return; } + if (vlanId) + { + messages::propertyNotWritable(asyncResp->res, "VLANId"); + return; + } + // Get single eth interface data, and call the below callback // for JSON preparation getEthernetIfaceData( ifaceId, - [asyncResp, parentIfaceId, ifaceId, &vlanEnable, &vlanId]( + [asyncResp, parentIfaceId, ifaceId, vlanEnable]( const bool& success, const EthernetInterfaceData& ethData, const boost::container::flat_set<IPv4AddressData>&, @@ -2170,20 +2176,11 @@ inline void requestEthernetInterfacesRoutes(App& app) if (ec) { messages::internalError(asyncResp->res); + return; } }; - if (vlanEnable) - { - crow::connections::systemBus->async_method_call( - std::move(callback), - "xyz.openbmc_project.Network", - "/xyz/openbmc_project/network/" + ifaceId, - "org.freedesktop.DBus.Properties", "Set", - "xyz.openbmc_project.Network.VLAN", "Id", - dbus::utility::DbusVariantType(vlanId)); - } - else + if (vlanEnable && !(*vlanEnable)) { BMCWEB_LOG_DEBUG << "vlanEnable is false. Deleting the " |