From 8bab0c820314bc8261a4a8ffc17e326c68349dff Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 15 May 2013 14:56:36 -0500 Subject: [PATCH] core: ensure newly-created master interfaces are ready for activation Reverts part of 2226a00cc2400a4150a83c119c8bfcc06ff2e988 core: add a "default-unmanaged" setting for devices Newly-created master interfaces are in the UNAVAILABLE state, but if they were created in response to a slave connection being activated, the master must be activated immediately too. But a device cannot be activated unless it's in the DISCONNECTED state, so restore that state change. --- src/nm-manager.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/nm-manager.c b/src/nm-manager.c index 7b4de3d0b1..91c4f225f1 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2858,6 +2858,18 @@ nm_manager_activate_connection (NMManager *manager, "Failed to create virtual interface"); return NULL; } + + /* A newly created device, if allowed to be managed by NM, will be + * in the UNAVAILABLE state here. To ensure it can be activated + * immediately, we transition it to DISCONNECTED so it passes the + * nm_device_can_activate() check below. + */ + if ( nm_device_is_available (device) + && (nm_device_get_state (device) == NM_DEVICE_STATE_UNAVAILABLE)) { + nm_device_state_changed (device, + NM_DEVICE_STATE_DISCONNECTED, + NM_DEVICE_STATE_REASON_NONE); + } } }