Check eth intf existence before creating VLAN
Request to create VLAN interface for non-existing interface causes
non-existing ethernet-interface object to be accessed which in turn
causes segmentation fault.Check for requested ethernet root intf and
allow the creation of VLAN interface for ethernet objects.
Tested:
POSTMAN Request & Response
Request: https://xx.xx.xx.xx/redfish/v1/Managers/bmc/EthernetInterfaces/abcd/VLANs
Method: POST
Body Parameters: {"VLANId": 1, "VLANEnable": true }
Response:
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The request failed due to an internal service error. The service is still operational.",
"MessageArgs": [],
"MessageId": "Base.1.8.1.InternalError",
"MessageSeverity": "Critical",
"Resolution": "Resubmit the request. If the problem persists, consider resetting the service."
}
],
"code": "Base.1.8.1.InternalError",
"message": "The request failed due to an internal service error. The service is still operational."
}
Signed-off-by: sureshvijayv1 <suresh.vijayakumar@intel.com>
Change-Id: I38e5cf64935e120a14b6b91c631e7e20b58789a1
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index fe59f0b..8b4c5c2 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -188,6 +188,11 @@
ObjectPath Manager::vlan(IntfName interfaceName, uint32_t id)
{
+ if (!hasInterface(interfaceName))
+ {
+ elog<ResourceNotFound>();
+ }
+
return interfaces[interfaceName]->createVLAN(id);
}
diff --git a/yaml/xyz/openbmc_project/Network/VLAN/Create.interface.yaml b/yaml/xyz/openbmc_project/Network/VLAN/Create.interface.yaml
index 8e63f2f..494bdde 100644
--- a/yaml/xyz/openbmc_project/Network/VLAN/Create.interface.yaml
+++ b/yaml/xyz/openbmc_project/Network/VLAN/Create.interface.yaml
@@ -17,3 +17,5 @@
type: path
description: >
The path for the created VLAN object.
+ errors:
+ - xyz.openbmc_project.Common.Error.ResourceNotFound