device: merge branch 'lr/veth-no-external-up'

https://bugzilla.gnome.org/show_bug.cgi?id=747465
This commit is contained in:
Lubomir Rintel 2015-04-13 13:53:43 +02:00
commit 0b9a4cd8df
3 changed files with 27 additions and 6 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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);