Commit d1faee92 authored by Dan Winship's avatar Dan Winship

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
parent 529092f0
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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:
......
......@@ -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;
......
......@@ -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);
}
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment