ethernet_interface: Get rid of address gateway usage

This parameter doesn't make any sense the way it is used currently. It
applies a "gateway" route to the routing table for the network of the IP
address that gets assigned to the interface. This ends up with two
routes being configured, one that designates all addresses on the
network be routed locally, and a second that designates those same
addresses be routed through the "gateway". Since the l2 route has
priority, we will never actually use this gateway route. The logic
didn't make sense conceptually anyway.

If you created an ip of 192.168.10.2/24 and gw 192.168.10.1 you would
end up with the routes:
192.168.10.0/24 via 192.168.10.1 dev eth0 proto static
192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.100

But the kernel won't actually let you do this an will just ignore the
"gateway" route.

Change-Id: I4fb8b322e45164031599a94e573ff0bbd3cc8eb5
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index a1438de..a2cd1c8 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -6,7 +6,6 @@
 #include "ipaddress.hpp"
 #include "neighbor.hpp"
 #include "network_manager.hpp"
-#include "routing_table.hpp"
 #include "vlan_interface.hpp"
 
 #include <arpa/inet.h>
@@ -79,8 +78,6 @@
 
     auto addrs = getInterfaceAddrs()[interfaceName()];
 
-    route::Table routingTable;
-
     for (auto& addr : addrs)
     {
         IP::Protocol addressType = convertFamily(addr.addrType);
@@ -93,8 +90,8 @@
         {
             origin = IP::AddressOrigin::LinkLocal;
         }
-        std::string gateway =
-            routingTable.getGateway(addr.addrType, addr.ipaddress, addr.prefix);
+        // Obsolete parameter
+        std::string gateway = "";
 
         std::string ipAddressObjectPath = generateObjectPath(
             addressType, addr.ipaddress, addr.prefix, gateway);
@@ -165,18 +162,13 @@
                               Argument::ARGUMENT_VALUE(ipaddress.c_str()));
     }
 
-    if (!gateway.empty() && (!isValidIP(addressFamily, gateway)))
-    {
-        log<level::ERR>("Not a valid Gateway"),
-            entry("GATEWAY=%s", gateway.c_str());
-        elog<InvalidArgument>(Argument::ARGUMENT_NAME("gateway"),
-                              Argument::ARGUMENT_VALUE(gateway.c_str()));
-    }
+    // Gateway is an obsolete parameter
+    gateway = "";
 
     if (!isValidPrefix(addressFamily, prefixLength))
     {
         log<level::ERR>("PrefixLength is not correct "),
-            entry("PREFIXLENGTH=%d", gateway.c_str());
+            entry("PREFIXLENGTH=%" PRIu8, prefixLength);
         elog<InvalidArgument>(
             Argument::ARGUMENT_NAME("prefixLength"),
             Argument::ARGUMENT_VALUE(std::to_string(prefixLength).c_str()));
@@ -679,30 +671,6 @@
                 stream << "Gateway=" << gateway6 << "\n";
             }
         }
-
-        // write the route section
-        for (const auto& addr : addrs)
-        {
-            if (addr.second->origin() == AddressOrigin::Static)
-            {
-                int addressFamily = addr.second->type() == IP::Protocol::IPv4
-                                        ? AF_INET
-                                        : AF_INET6;
-
-                std::string destination =
-                    getNetworkID(addressFamily, addr.second->address(),
-                                 addr.second->prefixLength());
-
-                if (addr.second->gateway() != "0.0.0.0" &&
-                    addr.second->gateway() != "" && destination != "0.0.0.0" &&
-                    destination != "")
-                {
-                    stream << "[Route]\n";
-                    stream << "Gateway=" << addr.second->gateway() << "\n";
-                    stream << "Destination=" << destination << "\n";
-                }
-            }
-        }
     }
 
     // Write the neighbor sections