ethernet_interface: Fix gateway entry emission
When you emit both an IPv4 and IPv6 gateway, the current logic ends up
writing out something like
[Route]
Gateway=10.0.0.1
Gateway=fe80::1
This is not valid syntax for a [Route] section as you only get to define
a single route per section. We need to instead write out two sections
like
[Route]
Gateway=10.0.0.1
[Route]
Gateway=fe80::1
Change-Id: Iaf42d7f732f16cd7503f3cdef750621b23d59161
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 1375637..0c83fba 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -941,15 +941,16 @@
if (manager.getSystemConf())
{
- stream << "[Route]\n";
const auto& gateway = manager.getSystemConf()->defaultGateway();
if (!gateway.empty())
{
+ stream << "[Route]\n";
stream << "Gateway=" << gateway << "\n";
}
const auto& gateway6 = manager.getSystemConf()->defaultGateway6();
if (!gateway6.empty())
{
+ stream << "[Route]\n";
stream << "Gateway=" << gateway6 << "\n";
}
}