From baee9080b790830183fa74fd83f5bf9757f4ac78 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 6 May 2015 09:20:55 -0500 Subject: platform: recognize Bluetooth BNEP devices via DEVTYPE Instead of strcmp()-ing the device name, recognize these devices from their driver's DEVTYPE. --- src/nm-manager.c | 2 +- src/nm-types.h | 1 + src/platform/nm-linux-platform.c | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 0bb3b0efdd..fe80156712 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2187,7 +2187,7 @@ platform_link_added (NMManager *self, /* Ignore Bluetooth PAN interfaces; they are handled by their NMDeviceBt * parent and don't get a separate interface. */ - if (!strncmp (plink->name, "bnep", STRLEN ("bnep"))) + if (plink->type == NM_LINK_TYPE_BNEP) return; if (device == NULL) { diff --git a/src/nm-types.h b/src/nm-types.h index f22272d91f..1c0ba9b46a 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -101,6 +101,7 @@ typedef enum { NM_LINK_TYPE_VETH, NM_LINK_TYPE_VLAN, NM_LINK_TYPE_VXLAN, + NM_LINK_TYPE_BNEP, /* Bluetooth Ethernet emulation */ /* Software types with slaves */ NM_LINK_TYPE_BRIDGE = 0x10000 | 0x20000, diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 0ef684d971..532fa4de4e 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -881,6 +881,7 @@ static const LinkDesc linktypes[] = { { NM_LINK_TYPE_VETH, "veth", "veth", NULL }, { NM_LINK_TYPE_VLAN, "vlan", "vlan", "vlan" }, { NM_LINK_TYPE_VXLAN, "vxlan", "vxlan", "vxlan" }, + { NM_LINK_TYPE_BNEP, "bluetooth", NULL, "bluetooth" }, { NM_LINK_TYPE_BRIDGE, "bridge", "bridge", "bridge" }, { NM_LINK_TYPE_BOND, "bond", "bond", "bond" }, @@ -980,7 +981,6 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink) else if (arptype == ARPHRD_INFINIBAND) return NM_LINK_TYPE_INFINIBAND; - ifname = rtnl_link_get_name (rtnllink); if (ifname) { const char *driver = ethtool_get_driver (ifname); @@ -1007,8 +1007,16 @@ link_extract_type (NMPlatform *platform, struct rtnl_link *rtnllink) devtype = read_devtype (sysfs_path); for (i = 0; devtype && i < G_N_ELEMENTS (linktypes); i++) { - if (g_strcmp0 (devtype, linktypes[i].devtype) == 0) + if (g_strcmp0 (devtype, linktypes[i].devtype) == 0) { + if (linktypes[i].nm_type == NM_LINK_TYPE_BNEP) { + /* Both BNEP and 6lowpan use DEVTYPE=bluetooth, so we must + * use arptype to distinguish between them. + */ + if (arptype != ARPHRD_ETHER) + continue; + } return linktypes[i].nm_type; + } } /* Fallback for drivers that don't call SET_NETDEV_DEVTYPE() */ -- cgit v1.2.1