From 90480c46bbc9f8c9fddcc6296ea6d8a728f276b7 Mon Sep 17 00:00:00 2001 From: Gunnar Mills Date: Tue, 19 Jun 2018 16:02:17 -0500 Subject: Throw error when invalid MAC Address is set sdbusplus supports errors on properties, so we can now throw exceptions on such cases as invalid parameters. Also changed the journal log levels to ERR. Tested: Built an image and see invalid parameter errors on values like garbage MAC addresses and non-admin MAC Addresses. Change-Id: I69687bbf34fe51f0c812f40dfc99bb88ce141a2f Signed-off-by: Gunnar Mills --- ethernet_interface.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'ethernet_interface.cpp') diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp index 35e61a7..d887bf5 100644 --- a/ethernet_interface.cpp +++ b/ethernet_interface.cpp @@ -664,9 +664,10 @@ std::string EthernetInterface::mACAddress(std::string value) { if (!mac_address::validate(value)) { - log("MACAddress is not valid.", + log("MACAddress is not valid.", entry("MAC=%s", value.c_str())); - return MacAddressIntf::mACAddress(); + elog(Argument::ARGUMENT_NAME("MACAddress"), + Argument::ARGUMENT_VALUE(value.c_str())); } // check whether MAC is broadcast mac. @@ -674,9 +675,10 @@ std::string EthernetInterface::mACAddress(std::string value) if (!(intMac ^ mac_address::broadcastMac)) { - log("MACAddress is a broadcast mac.", + log("MACAddress is a broadcast mac.", entry("MAC=%s", value.c_str())); - return MacAddressIntf::mACAddress(); + elog(Argument::ARGUMENT_NAME("MACAddress"), + Argument::ARGUMENT_VALUE(value.c_str())); } // Check if the MAC changed. @@ -700,9 +702,10 @@ std::string EthernetInterface::mACAddress(std::string value) if (intInventoryMac != intMac) { - log("Given MAC address is neither a local Admin " + log("Given MAC address is neither a local Admin " "type nor is same as in inventory"); - return MacAddressIntf::mACAddress(); + elog(Argument::ARGUMENT_NAME("MACAddress"), + Argument::ARGUMENT_VALUE(value.c_str())); } } catch(InternalFailure& e) -- cgit v1.2.1