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>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index d451904..e7f6b8b 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -2144,8 +2144,8 @@
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 @@
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 @@
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 "