From a362922c122045ba5c5c51493812ad9e0e6cdab3 Mon Sep 17 00:00:00 2001 From: Gunnar Mills Date: Tue, 19 Jun 2018 16:32:04 -0500 Subject: Throw InvalidArgument on bad Default Gateway If the Default Gateway parameter is not valid, throw the InvalidArgument error. Resolves openbmc/openbmc#3261 Tested: See the InvalidArgument error on values such as "blah" or "1.0.8". Change-Id: Ieeb0da7e3c3806144634cda6cd069758dba92a47 Signed-off-by: Gunnar Mills --- system_configuration.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/system_configuration.cpp b/system_configuration.cpp index a957ded..da5140a 100644 --- a/system_configuration.cpp +++ b/system_configuration.cpp @@ -23,6 +23,7 @@ constexpr auto METHOD_SET = "SetStaticHostname"; using namespace phosphor::logging; using namespace sdbusplus::xyz::openbmc_project::Common::Error; +using InvalidArgumentMetadata = xyz::openbmc_project::Common::InvalidArgument; using SystemConfigIntf = sdbusplus::xyz::openbmc_project::Network::server::SystemConfiguration; @@ -106,7 +107,9 @@ std::string SystemConfiguration::defaultGateway(std::string gateway) { log("Not a valid Gateway", entry("GATEWAY=%s", gateway.c_str())); - return gw; + elog(InvalidArgumentMetadata::ARGUMENT_NAME("GATEWAY"), + InvalidArgumentMetadata::ARGUMENT_VALUE( + gateway.c_str())); } gw = SystemConfigIntf::defaultGateway(gateway); manager.writeToConfigurationFile(); -- cgit v1.2.1