summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-09-24 17:46:15 -0500
committerDan Williams <dcbw@redhat.com>2015-05-19 09:25:16 -0500
commitd4e0a1e8cc09b0cdc408501d4521d3ddac617f81 (patch)
tree3093fa6ff0128e3cfdbfb54aa8acad94da88abba
parent81db51299719a4cbf3f1f15ead912391d2b52330 (diff)
downloadNetworkManager-d4e0a1e8cc09b0cdc408501d4521d3ddac617f81.tar.gz
core: earlier software capability detection
We need to know whether we can create interfaces of any given NMDevice subclass or not. So don't rely on just the NMPlatformLink for that information, because we won't have a platform link for software devices before we create them.
-rw-r--r--src/devices/nm-device-bond.c2
-rw-r--r--src/devices/nm-device-bridge.c2
-rw-r--r--src/devices/nm-device-infiniband.c26
-rw-r--r--src/devices/nm-device-vlan.c2
-rw-r--r--src/devices/nm-device.c26
-rw-r--r--src/devices/team/nm-device-team.c2
6 files changed, 39 insertions, 21 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 17fb12c919..50094189d9 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -64,7 +64,7 @@ enum {
static NMDeviceCapabilities
get_generic_capabilities (NMDevice *dev)
{
- return NM_DEVICE_CAP_CARRIER_DETECT;
+ return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
}
static gboolean
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 221bed97bb..ece01c6d6d 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -62,7 +62,7 @@ enum {
static NMDeviceCapabilities
get_generic_capabilities (NMDevice *dev)
{
- return NM_DEVICE_CAP_CARRIER_DETECT;
+ return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
}
static gboolean
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index 5e89660e7d..06fad615d1 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -44,12 +44,15 @@ G_DEFINE_TYPE (NMDeviceInfiniband, nm_device_infiniband, NM_TYPE_DEVICE)
#define NM_DEVICE_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_INFINIBAND, NMDeviceInfinibandPrivate))
+#define NM_DEVICE_INFINIBAND_IS_PARTITION "is-partition"
+
typedef struct {
- int dummy;
+ gboolean is_partition;
} NMDeviceInfinibandPrivate;
enum {
PROP_0,
+ PROP_IS_PARTITION,
LAST_PROP
};
@@ -62,7 +65,12 @@ nm_device_infiniband_init (NMDeviceInfiniband * self)
static NMDeviceCapabilities
get_generic_capabilities (NMDevice *dev)
{
- return NM_DEVICE_CAP_CARRIER_DETECT;
+ guint32 caps = NM_DEVICE_CAP_CARRIER_DETECT;
+
+ if (NM_DEVICE_INFINIBAND_GET_PRIVATE (dev)->is_partition)
+ caps |= NM_DEVICE_CAP_IS_SOFTWARE;
+
+ return caps;
}
static NMActStageReturn
@@ -243,6 +251,9 @@ get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
+ case PROP_IS_PARTITION:
+ g_value_set_boolean (value, NM_DEVICE_INFINIBAND_GET_PRIVATE (object)->is_partition);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -254,6 +265,9 @@ set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
+ case PROP_IS_PARTITION:
+ NM_DEVICE_INFINIBAND_GET_PRIVATE (object)->is_partition = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -281,6 +295,12 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass)
parent_class->ip4_config_pre_commit = ip4_config_pre_commit;
/* properties */
+ g_object_class_install_property
+ (object_class, PROP_IS_PARTITION,
+ g_param_spec_boolean (NM_DEVICE_INFINIBAND_IS_PARTITION, "", "",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
G_TYPE_FROM_CLASS (klass),
@@ -299,6 +319,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore,
NM_DEVICE_PLATFORM_DEVICE, plink,
NM_DEVICE_TYPE_DESC, "InfiniBand",
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
+ NM_DEVICE_INFINIBAND_IS_PARTITION, (plink->parent > 0),
NULL);
}
@@ -342,6 +363,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
NM_DEVICE_DRIVER, nm_device_get_driver (parent),
NM_DEVICE_TYPE_DESC, "InfiniBand",
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
+ NM_DEVICE_INFINIBAND_IS_PARTITION, TRUE,
NULL);
}
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index fcbe402aba..24dd36b1e5 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -77,7 +77,7 @@ static NMDeviceCapabilities
get_generic_capabilities (NMDevice *dev)
{
/* We assume VLAN interfaces always support carrier detect */
- return NM_DEVICE_CAP_CARRIER_DETECT;
+ return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
}
static gboolean
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 52ba10eef0..5dbb239a7f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -187,7 +187,6 @@ typedef struct {
char * path;
char * iface; /* may change, could be renamed by user */
int ifindex;
- gboolean is_software;
char * ip_iface;
int ip_ifindex;
NMDeviceType type;
@@ -540,9 +539,7 @@ nm_device_get_ifindex (NMDevice *self)
gboolean
nm_device_is_software (NMDevice *self)
{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
-
- return priv->is_software;
+ return NM_FLAGS_HAS (NM_DEVICE_GET_PRIVATE (self)->capabilities, NM_DEVICE_CAP_IS_SOFTWARE);
}
const char *
@@ -1066,7 +1063,7 @@ nm_device_finish_init (NMDevice *self)
nm_device_enslave_slave (priv->master, self, NULL);
if (priv->ifindex > 0) {
- if (priv->platform_link_initialized || (priv->is_nm_owned && priv->is_software)) {
+ if (priv->platform_link_initialized || (priv->is_nm_owned && nm_device_is_software (self))) {
nm_platform_link_get_unmanaged (NM_PLATFORM_GET, priv->ifindex, &platform_unmanaged);
nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_DEFAULT, platform_unmanaged);
} else {
@@ -8532,6 +8529,12 @@ constructor (GType type,
priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self);
if (priv->ifindex > 0) {
+ priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex);
+ priv->dev_id = nm_platform_link_get_dev_id (NM_PLATFORM_GET, priv->ifindex);
+ if (nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex))
+ priv->capabilities |= NM_DEVICE_CAP_IS_SOFTWARE;
+ priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex);
+
nm_platform_link_get_driver_info (NM_PLATFORM_GET,
priv->ifindex,
NULL,
@@ -8539,6 +8542,9 @@ constructor (GType type,
&priv->firmware_version);
}
+ if (NM_DEVICE_GET_CLASS (self)->get_generic_capabilities)
+ priv->capabilities |= NM_DEVICE_GET_CLASS (self)->get_generic_capabilities (self);
+
/* Watch for external IP config changes */
platform = nm_platform_get ();
g_signal_connect (platform, NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, G_CALLBACK (device_ip_changed), self);
@@ -8615,16 +8621,6 @@ constructed (GObject *object)
priv->carrier = TRUE;
}
- if (priv->ifindex > 0) {
- priv->is_software = nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex);
- priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex);
- priv->dev_id = nm_platform_link_get_dev_id (NM_PLATFORM_GET, priv->ifindex);
- priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex);
- }
- /* Indicate software device in capabilities. */
- if (priv->is_software)
- priv->capabilities |= NM_DEVICE_CAP_IS_SOFTWARE;
-
/* Enslave ourselves */
master = nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex);
if (master)
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 1f80d543c4..4256bec2b4 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -73,7 +73,7 @@ static gboolean teamd_start (NMDevice *device, NMSettingTeam *s_team);
static NMDeviceCapabilities
get_generic_capabilities (NMDevice *device)
{
- return NM_DEVICE_CAP_CARRIER_DETECT;
+ return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
}
static gboolean