summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2015-04-13 13:53:43 +0200
committerLubomir Rintel <lkundrak@v3.sk>2015-04-13 13:53:43 +0200
commit0b9a4cd8df0cea367c1ca3767341738be466c126 (patch)
treeb8f8c0d40c835dcecf7da3fa0f48907400686b7a
parent62f40bade074ac8e555730957149d0888a2b7715 (diff)
parentbcc79cc0eb1172a51a25741cf61be6ae493672fb (diff)
downloadNetworkManager-0b9a4cd8df0cea367c1ca3767341738be466c126.tar.gz
device: merge branch 'lr/veth-no-external-up'
https://bugzilla.gnome.org/show_bug.cgi?id=747465
-rw-r--r--src/devices/nm-device-veth.c12
-rw-r--r--src/devices/nm-device.c14
-rw-r--r--src/devices/nm-device.h7
3 files changed, 27 insertions, 6 deletions
diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c
index 6a05cc3214..30994971ec 100644
--- a/src/devices/nm-device-veth.c
+++ b/src/devices/nm-device-veth.c
@@ -96,6 +96,15 @@ get_peer (NMDeviceVeth *self)
return priv->peer;
}
+static gboolean
+can_unmanaged_external_down (NMDevice *self)
+{
+ /* Unless running in a container, an udev rule causes these to be
+ * unmanaged. If there's no udev then we're probably in a container
+ * and should IFF_UP and configure the veth ourselves even if we
+ * didn't create it. */
+ return FALSE;
+}
/**************************************************************/
@@ -140,12 +149,15 @@ static void
nm_device_veth_class_init (NMDeviceVethClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
g_type_class_add_private (klass, sizeof (NMDeviceVethPrivate));
object_class->get_property = get_property;
object_class->dispose = dispose;
+ device_class->can_unmanaged_external_down = can_unmanaged_external_down;
+
/* properties */
g_object_class_install_property
(object_class, PROP_PEER,
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index c6f590c0e9..4735753366 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1019,8 +1019,15 @@ nm_device_release_one_slave (NMDevice *self, NMDevice *slave, gboolean configure
return success;
}
+/**
+ * can_unmanaged_external_down:
+ * @self: the device
+ *
+ * Check whether the device should stay NM_UNMANAGED_EXTERNAL_DOWN unless
+ * IFF_UP-ed externally.
+ */
static gboolean
-is_software_external (NMDevice *self)
+can_unmanaged_external_down (NMDevice *self)
{
return nm_device_is_software (self)
&& !nm_device_get_is_nm_owned (self);
@@ -1041,7 +1048,7 @@ nm_device_finish_init (NMDevice *self)
g_assert (priv->initialized == FALSE);
/* Do not manage externally created software devices until they are IFF_UP */
- if ( is_software_external (self)
+ if ( NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self)
&& !nm_platform_link_is_up (priv->ifindex)
&& priv->ifindex > 0)
nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN, TRUE);
@@ -1304,7 +1311,7 @@ device_link_changed (NMDevice *self, NMPlatformLink *info)
/* Manage externally-created software interfaces only when they are IFF_UP */
g_assert (priv->ifindex > 0);
- if (is_software_external (self)) {
+ if (NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self)) {
gboolean external_down = nm_device_get_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN);
if (external_down && info->up) {
@@ -8903,6 +8910,7 @@ nm_device_class_init (NMDeviceClass *klass)
klass->can_auto_connect = can_auto_connect;
klass->check_connection_compatible = check_connection_compatible;
klass->check_connection_available = check_connection_available;
+ klass->can_unmanaged_external_down = can_unmanaged_external_down;
klass->is_up = is_up;
klass->bring_up = bring_up;
klass->take_down = take_down;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index a204bc134f..6de11ba9d7 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -130,9 +130,10 @@ typedef struct {
void (* link_changed) (NMDevice *self, NMPlatformLink *info);
/* Hardware state (IFF_UP) */
- gboolean (*is_up) (NMDevice *self);
- gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware);
- gboolean (*take_down) (NMDevice *self);
+ gboolean (*can_unmanaged_external_down) (NMDevice *self);
+ gboolean (*is_up) (NMDevice *self);
+ gboolean (*bring_up) (NMDevice *self, gboolean *no_firmware);
+ gboolean (*take_down) (NMDevice *self);
/* Carrier state (IFF_LOWER_UP) */
void (*carrier_changed) (NMDevice *, gboolean carrier);