diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2018-06-19 16:32:04 -0500 |
---|---|---|
committer | Ratan Gupta <ratagupt@linux.vnet.ibm.com> | 2018-09-05 01:44:30 +0000 |
commit | a362922c122045ba5c5c51493812ad9e0e6cdab3 (patch) | |
tree | fe4aa4883842953ae181fa0554786ee5969f699d | |
parent | 189d44eddd93d1a2eb9e69d479b2f66b7d41f59c (diff) | |
download | phosphor-networkd-a362922c122045ba5c5c51493812ad9e0e6cdab3.tar.gz phosphor-networkd-a362922c122045ba5c5c51493812ad9e0e6cdab3.zip |
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 <gmills@us.ibm.com>
-rw-r--r-- | system_configuration.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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<level::ERR>("Not a valid Gateway", entry("GATEWAY=%s", gateway.c_str())); - return gw; + elog<InvalidArgument>(InvalidArgumentMetadata::ARGUMENT_NAME("GATEWAY"), + InvalidArgumentMetadata::ARGUMENT_VALUE( + gateway.c_str())); } gw = SystemConfigIntf::defaultGateway(gateway); manager.writeToConfigurationFile(); |