summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2019-02-01 21:07:10 -0800
committerWilliam A. Kennington III <wak@google.com>2019-02-14 12:10:12 -0800
commit781f3355bf1c0ba20748500385cce10d9629d0a9 (patch)
treedac0fc6b9a4fbe38693146ab998a0f1e3da58c64
parentd2d05940681fe3ca960638c924e886474c77ed69 (diff)
downloadphosphor-networkd-781f3355bf1c0ba20748500385cce10d9629d0a9.tar.gz
phosphor-networkd-781f3355bf1c0ba20748500385cce10d9629d0a9.zip
ethernet_interface: Only write Gateway= lines when present
This doesn't affect the total system behavior but it cleans up error output from systemd-networkd which doesn't like empty Gateway= lines when we don't have a set gateway. Tested: Set the system to a static configuration with no gateway configured and saw that the line was no longer written. Configured a gateway and the line is written as expected. Change-Id: I1ff9c4f564fab54d0c54e3f87fcd50b623f0fbda Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--ethernet_interface.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index e7da8ff..4825e5b 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -568,8 +568,11 @@ void EthernetInterface::writeConfigurationFile()
if (manager.getSystemConf())
{
- stream << "Gateway=" << manager.getSystemConf()->defaultGateway()
- << "\n";
+ const auto& gateway = manager.getSystemConf()->defaultGateway();
+ if (!gateway.empty())
+ {
+ stream << "Gateway=" << gateway << "\n";
+ }
}
// write the route section
OpenPOWER on IntegriCloud