summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-11-13 17:17:06 -0500
committerDan Winship <danw@gnome.org>2014-11-14 15:36:31 -0500
commitd1faee92288831517f6f5f7baa057c790be3b022 (patch)
tree9b3a33b2cb636ef92036a87b16e079b9e4239bd7
parent529092f035680584e38f4fcfa8473876e9b7f86c (diff)
downloadNetworkManager-d1faee92288831517f6f5f7baa057c790be3b022.tar.gz
core: fix a spurious warning with non-kernel network devices
NMDevice was warning about not being able to set ifindex even on devices that we know don't have an ifindex. https://bugzilla.gnome.org/show_bug.cgi?id=739889
-rw-r--r--src/devices/adsl/nm-device-adsl.c4
-rw-r--r--src/devices/bluetooth/nm-device-bt.c7
-rw-r--r--src/devices/nm-device-private.h3
-rw-r--r--src/devices/nm-device.c15
-rw-r--r--src/devices/wwan/nm-device-modem.c7
-rw-r--r--src/tests/config/nm-test-device.c11
-rw-r--r--src/tests/config/test-config.c3
7 files changed, 36 insertions, 14 deletions
diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c
index fac6ce0e6f..e664ff4850 100644
--- a/src/devices/adsl/nm-device-adsl.c
+++ b/src/devices/adsl/nm-device-adsl.c
@@ -76,7 +76,9 @@ typedef struct {
static guint32
get_generic_capabilities (NMDevice *dev)
{
- return (NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_NONSTANDARD_CARRIER);
+ return ( NM_DEVICE_CAP_CARRIER_DETECT
+ | NM_DEVICE_CAP_NONSTANDARD_CARRIER
+ | NM_DEVICE_CAP_IS_NON_KERNEL);
}
static gboolean
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 0a1f591540..2cf2794da6 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -124,6 +124,12 @@ get_connection_bt_type (NMConnection *connection)
return NM_BT_CAPABILITY_NONE;
}
+static guint32
+get_generic_capabilities (NMDevice *device)
+{
+ return NM_DEVICE_CAP_IS_NON_KERNEL;
+}
+
static gboolean
can_auto_connect (NMDevice *device,
NMConnection *connection,
@@ -1179,6 +1185,7 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
object_class->dispose = dispose;
object_class->finalize = finalize;
+ device_class->get_generic_capabilities = get_generic_capabilities;
device_class->can_auto_connect = can_auto_connect;
device_class->deactivate = deactivate;
device_class->act_stage2_config = act_stage2_config;
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index 16c4d03885..fd87fd77a1 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -37,8 +37,9 @@ enum NMActStageReturn {
};
#define NM_DEVICE_CAP_NONSTANDARD_CARRIER 0x80000000
+#define NM_DEVICE_CAP_IS_NON_KERNEL 0x40000000
-#define NM_DEVICE_CAP_INTERNAL_MASK 0x80000000
+#define NM_DEVICE_CAP_INTERNAL_MASK 0xc0000000
void nm_device_set_ip_iface (NMDevice *self, const char *iface);
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 39a9f282b2..eb37b468d6 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7771,6 +7771,9 @@ constructor (GType type,
if (NM_DEVICE_GET_CLASS (self)->get_generic_capabilities)
priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self);
+ if (priv->ifindex <= 0 && !device_has_capability (self, NM_DEVICE_CAP_IS_NON_KERNEL))
+ _LOGW (LOGD_HW, "failed to look up interface index");
+
device_get_driver_info (self, priv->iface, &priv->driver_version, &priv->firmware_version);
/* Watch for external IP config changes */
@@ -7969,18 +7972,8 @@ set_property (GObject *object, guint prop_id,
case PROP_IFACE:
if (g_value_get_string (value)) {
g_free (priv->iface);
- priv->ifindex = 0;
priv->iface = g_value_dup_string (value);
-
- /* Only look up the ifindex if it appears to be an actual kernel
- * interface name. eg Bluetooth devices won't have one until we know
- * the IP interface.
- */
- if (priv->iface && !strchr (priv->iface, ':')) {
- priv->ifindex = nm_platform_link_get_ifindex (priv->iface);
- if (priv->ifindex <= 0)
- _LOGW (LOGD_HW, "failed to look up interface index");
- }
+ priv->ifindex = nm_platform_link_get_ifindex (priv->iface);
}
break;
case PROP_DRIVER:
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 3eb570c465..f681e59ca1 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -373,6 +373,12 @@ device_state_changed (NMDevice *device,
}
}
+static guint32
+get_generic_capabilities (NMDevice *device)
+{
+ return NM_DEVICE_CAP_IS_NON_KERNEL;
+}
+
static gboolean
check_connection_compatible (NMDevice *device, NMConnection *connection)
{
@@ -701,6 +707,7 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
object_class->set_property = set_property;
object_class->constructed = constructed;
+ device_class->get_generic_capabilities = get_generic_capabilities;
device_class->check_connection_compatible = check_connection_compatible;
device_class->check_connection_available = check_connection_available;
device_class->complete_connection = complete_connection;
diff --git a/src/tests/config/nm-test-device.c b/src/tests/config/nm-test-device.c
index 8f9c431cc2..63067b25f6 100644
--- a/src/tests/config/nm-test-device.c
+++ b/src/tests/config/nm-test-device.c
@@ -67,10 +67,17 @@ finalize (GObject *object)
g_object_class->finalize (object);
}
+static guint32
+get_generic_capabilities (NMDevice *device)
+{
+ return NM_DEVICE_CAP_IS_NON_KERNEL;
+}
+
static void
nm_test_device_class_init (NMTestDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
g_object_class = g_type_class_peek (G_TYPE_OBJECT);
@@ -78,13 +85,15 @@ nm_test_device_class_init (NMTestDeviceClass *klass)
object_class->constructed = constructed;
object_class->dispose = dispose;
object_class->finalize = finalize;
+
+ device_class->get_generic_capabilities = get_generic_capabilities;
}
NMDevice *
nm_test_device_new (const char *hwaddr)
{
return g_object_new (NM_TYPE_TEST_DEVICE,
- NM_DEVICE_IFACE, "dummy:",
+ NM_DEVICE_IFACE, "dummy",
NM_DEVICE_HW_ADDRESS, hwaddr,
NULL);
}
diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c
index fff2d2a092..808fc670b3 100644
--- a/src/tests/config/test-config.c
+++ b/src/tests/config/test-config.c
@@ -26,6 +26,7 @@
#include <nm-config.h>
#include "nm-test-device.h"
+#include "nm-fake-platform.h"
static void
setup_config (const char *config_file, const char *config_dir, ...)
@@ -287,6 +288,8 @@ main (int argc, char **argv)
g_test_init (&argc, &argv, NULL);
+ nm_fake_platform_setup ();
+
g_test_add_func ("/config/simple", test_config_simple);
g_test_add_func ("/config/non-existent", test_config_non_existent);
g_test_add_func ("/config/parse-error", test_config_parse_error);