treewide: Ignore non-ethernet devices

These are not regular ethernet devices that use INET protocols. We can
ignore them as they just produce journal spam otherwise.

Tested: Verified that our MCTP interfaces are no longer reported as
objects and that our NCSI and ETH interfaces are still added.

Change-Id: Idd5723e443b358fe76f039bcc4ce70390824094d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/60-phosphor-networkd-default.network.in b/60-phosphor-networkd-default.network.in
index 4230aeb..9024543 100644
--- a/60-phosphor-networkd-default.network.in
+++ b/60-phosphor-networkd-default.network.in
@@ -1,6 +1,5 @@
 [Match]
-Name=*
-Name=!lo
+Type=ether
 [Network]
 DHCP=true
 LinkLocalAddressing=@LINK_LOCAL_AUTOCONFIGURATION@
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index a2d123d..e4108f3 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -11,6 +11,7 @@
 #include <fmt/format.h>
 #include <linux/rtnetlink.h>
 #include <net/if.h>
+#include <net/if_arp.h>
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/lg2.hpp>
@@ -563,6 +564,7 @@
         mac.emplace(ToAddr<ether_addr>{}(macStr));
     }
     auto info = AllIntfInfo{InterfaceInfo{
+        .type = ARPHRD_ETHER,
         .idx = 0, // TODO: Query the correct value after creation
         .flags = 0,
         .name = intfName,
diff --git a/src/network_manager.cpp b/src/network_manager.cpp
index 85133c7..ca3b517 100644
--- a/src/network_manager.cpp
+++ b/src/network_manager.cpp
@@ -9,6 +9,7 @@
 #include <linux/if_addr.h>
 #include <linux/neighbour.h>
 #include <net/if.h>
+#include <net/if_arp.h>
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/lg2.hpp>
@@ -202,7 +203,7 @@
 
 void Manager::addInterface(const InterfaceInfo& info)
 {
-    if (info.flags & IFF_LOOPBACK)
+    if (info.type != ARPHRD_ETHER)
     {
         ignoredIntf.emplace(info.idx);
         return;
diff --git a/src/rtnetlink.cpp b/src/rtnetlink.cpp
index fd68671..1c80c1d 100644
--- a/src/rtnetlink.cpp
+++ b/src/rtnetlink.cpp
@@ -55,8 +55,9 @@
 {
     const auto& ifinfo = netlink::extractRtData<ifinfomsg>(msg);
     InterfaceInfo ret;
-    ret.flags = ifinfo.ifi_flags;
+    ret.type = ifinfo.ifi_type;
     ret.idx = ifinfo.ifi_index;
+    ret.flags = ifinfo.ifi_flags;
     while (!msg.empty())
     {
         auto [hdr, data] = netlink::extractRtAttr(msg);
diff --git a/src/types.hpp b/src/types.hpp
index ba4ee1a..6351b24 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -81,6 +81,7 @@
  */
 struct InterfaceInfo
 {
+    unsigned short type;
     unsigned idx;
     unsigned flags;
     std::optional<std::string> name = std::nullopt;
diff --git a/test/test_ethernet_interface.cpp b/test/test_ethernet_interface.cpp
index 7b72166..f6c59b1 100644
--- a/test/test_ethernet_interface.cpp
+++ b/test/test_ethernet_interface.cpp
@@ -4,6 +4,7 @@
 #include "test_network_manager.hpp"
 
 #include <net/if.h>
+#include <net/if_arp.h>
 
 #include <sdbusplus/bus.hpp>
 #include <stdplus/gtest/tmp.hpp>
@@ -40,7 +41,8 @@
         makeInterface(stdplus::PinnedRef<sdbusplus::bus_t> bus,
                       TestManager& manager)
     {
-        AllIntfInfo info{InterfaceInfo{.idx = 1, .flags = 0, .name = "test0"}};
+        AllIntfInfo info{InterfaceInfo{
+            .type = ARPHRD_ETHER, .idx = 1, .flags = 0, .name = "test0"}};
         return {bus, manager, info, "/xyz/openbmc_test/network"sv,
                 config::Parser()};
     }
@@ -72,7 +74,8 @@
     constexpr ether_addr mac{0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
     constexpr unsigned mtu = 150;
 
-    AllIntfInfo info{InterfaceInfo{.idx = 2,
+    AllIntfInfo info{InterfaceInfo{.type = ARPHRD_ETHER,
+                                   .idx = 2,
                                    .flags = IFF_RUNNING,
                                    .name = "test1",
                                    .mac = mac,
diff --git a/test/test_netlink.cpp b/test/test_netlink.cpp
index 4514fa4..f256c3a 100644
--- a/test/test_netlink.cpp
+++ b/test/test_netlink.cpp
@@ -299,8 +299,10 @@
         system::mock_clear();
         for (unsigned i = 0; i < ifs; ++i)
         {
-            system::mock_addIF(InterfaceInfo{
-                .idx = i + 1u, .flags = 0, .name = fmt::format("eth{}", i)});
+            system::mock_addIF(InterfaceInfo{.type = 1u,
+                                             .idx = i + 1u,
+                                             .flags = 0,
+                                             .name = fmt::format("eth{}", i)});
         }
 
         size_t cbCalls = 0;
diff --git a/test/test_network_manager.cpp b/test/test_network_manager.cpp
index 03d2944..304ddcd 100644
--- a/test/test_network_manager.cpp
+++ b/test/test_network_manager.cpp
@@ -2,6 +2,8 @@
 
 #include "config_parser.hpp"
 
+#include <net/if_arp.h>
+
 #include <sdbusplus/bus.hpp>
 #include <stdplus/gtest/tmp.hpp>
 
@@ -40,7 +42,8 @@
 
 TEST_F(TestNetworkManager, WithSingleInterface)
 {
-    manager.addInterface({.idx = 2, .flags = 0, .name = "igb1"});
+    manager.addInterface(
+        {.type = ARPHRD_ETHER, .idx = 2, .flags = 0, .name = "igb1"});
     manager.handleAdminState("managed", 2);
 
     // Now create the interfaces which will call the mocked getifaddrs
@@ -51,10 +54,12 @@
 // getifaddrs returns two interfaces.
 TEST_F(TestNetworkManager, WithMultipleInterfaces)
 {
-    manager.addInterface({.idx = 1, .flags = 0, .name = "igb0"});
+    manager.addInterface(
+        {.type = ARPHRD_ETHER, .idx = 1, .flags = 0, .name = "igb0"});
     manager.handleAdminState("managed", 1);
     manager.handleAdminState("unmanaged", 2);
-    manager.addInterface({.idx = 2, .flags = 0, .name = "igb1"});
+    manager.addInterface(
+        {.type = ARPHRD_ETHER, .idx = 2, .flags = 0, .name = "igb1"});
 
     EXPECT_THAT(manager.interfaces,
                 UnorderedElementsAre(Key("igb0"), Key("igb1")));
@@ -66,7 +71,8 @@
     EXPECT_THROW(manager.vlan("", 0), std::exception);
     EXPECT_THROW(manager.vlan("eth0", 2), std::exception);
 
-    manager.addInterface({.idx = 1, .flags = 0, .name = "eth0"});
+    manager.addInterface(
+        {.type = ARPHRD_ETHER, .idx = 1, .flags = 0, .name = "eth0"});
     manager.handleAdminState("managed", 1);
     EXPECT_NO_THROW(manager.vlan("eth0", 2));
     EXPECT_NO_THROW(manager.vlan("eth0", 4094));
diff --git a/test/test_rtnetlink.cpp b/test/test_rtnetlink.cpp
index 73a0f00..a0dddfe 100644
--- a/test/test_rtnetlink.cpp
+++ b/test/test_rtnetlink.cpp
@@ -21,10 +21,11 @@
     {
         ifinfomsg hdr __attribute__((aligned(NLMSG_ALIGNTO)));
     } msg;
+    msg.hdr.ifi_type = 3;
     msg.hdr.ifi_index = 1;
     msg.hdr.ifi_flags = 2;
     EXPECT_EQ(intfFromRtm(stdplus::raw::asView<char>(msg)),
-              (InterfaceInfo{.idx = 1, .flags = 2}));
+              (InterfaceInfo{.type = 3, .idx = 1, .flags = 2}));
 }
 
 TEST(IntfFromRtm, AllAttrs)
@@ -40,6 +41,7 @@
         rtattr mtu_hdr __attribute__((aligned((RTA_ALIGNTO))));
         unsigned mtu __attribute__((aligned((RTA_ALIGNTO)))) = 50;
     } msg;
+    msg.hdr.ifi_type = 4;
     msg.hdr.ifi_index = 1;
     msg.hdr.ifi_flags = 2;
     msg.addr_hdr.rta_type = IFLA_ADDRESS;
@@ -50,7 +52,8 @@
     msg.mtu_hdr.rta_len = RTA_LENGTH(sizeof(msg.mtu));
 
     auto info = intfFromRtm(stdplus::raw::asView<char>(msg));
-    auto expected = InterfaceInfo{.idx = 1,
+    auto expected = InterfaceInfo{.type = 4,
+                                  .idx = 1,
                                   .flags = 2,
                                   .name = "eth0",
                                   .mac = ether_addr{0, 1, 2, 3, 4, 5},