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>
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 @@
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