From e694f2cec1a0e7bc188776c8573e07a4d57851dc Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 13 May 2021 10:49:39 +0200 Subject: [PATCH 1/2] manager: fix active_connection_find() Commit 33b9fa3a3caf ("manager: Keep volatile/external connections while referenced by async_op_lst") changed active_connection_find() to also return active connections that are not yet activating but are waiting authorization. This has side effect for other callers of the function. In particular, _get_activatable_connections_filter() should exclude only ACs that are really active, not those waiting for authorization. Otherwise, in ensure_master_active_connection() all the ACs waiting authorization are missed and we might fail to find the right master AC. Add an argument to active_connection_find to select whether include ACs waiting authorization. Fixes: 33b9fa3a3caf ('manager: Keep volatile/external connections while referenced by async_op_lst') https://bugzilla.redhat.com/show_bug.cgi?id=1955101 --- src/core/nm-manager.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 8024513959..419ce88dfe 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -363,6 +363,7 @@ static NMActiveConnection *active_connection_find(NMManager * self, NMSettingsConnection * sett_conn, const char * uuid, NMActiveConnectionState max_state, + gboolean also_waiting_auth, GPtrArray ** out_all_matching); static NMConnectivity *concheck_get_mgr(NMManager *self); @@ -833,6 +834,7 @@ _delete_volatile_connection_do(NMManager *self, NMSettingsConnection *connection connection, NULL, NM_ACTIVE_CONNECTION_STATE_DEACTIVATED, + TRUE, NULL)) return; @@ -978,6 +980,7 @@ active_connection_find( NMSettingsConnection * sett_conn, const char * uuid, NMActiveConnectionState max_state /* candidates in state @max_state will be found */, + gboolean also_waiting_auth /* return also ACs waiting authorization */, GPtrArray ** out_all_matching) { NMManagerPrivate * priv = NM_MANAGER_GET_PRIVATE(self); @@ -1017,6 +1020,9 @@ active_connection_find( if (!best_ac) { AsyncOpData *async_op_data; + if (!also_waiting_auth) + return NULL; + c_list_for_each_entry (async_op_data, &priv->async_op_lst_head, async_op_lst) { NMSettingsConnection *ac_conn; @@ -1078,6 +1084,7 @@ active_connection_find_by_connection(NMManager * self, sett_conn, sett_conn ? NULL : nm_connection_get_uuid(connection), max_state, + FALSE, out_all_matching); } @@ -1112,6 +1119,7 @@ _get_activatable_connections_filter(NMSettings * settings, sett_conn, NULL, NM_ACTIVE_CONNECTION_STATE_ACTIVATED, + FALSE, NULL); } @@ -2245,6 +2253,7 @@ connection_flags_changed(NMSettings *settings, NMSettingsConnection *connection, connection, NULL, NM_ACTIVE_CONNECTION_STATE_DEACTIVATED, + FALSE, NULL)) { /* the connection still has an active-connection. It will be purged * when the active connection(s) get(s) removed. */ @@ -2564,6 +2573,7 @@ new_activation_allowed_for_connection(NMManager *self, NMSettingsConnection *con connection, NULL, NM_ACTIVE_CONNECTION_STATE_ACTIVATED, + FALSE, NULL); } @@ -4181,6 +4191,7 @@ find_master(NMManager * self, master_connection, NULL, NM_ACTIVE_CONNECTION_STATE_DEACTIVATING, + FALSE, NULL); } @@ -5032,6 +5043,7 @@ _internal_activate_device(NMManager *self, NMActiveConnection *active, GError ** sett_conn, NULL, NM_ACTIVE_CONNECTION_STATE_ACTIVATED, + FALSE, &all_ac_arr); if (ac) { n_all = all_ac_arr ? all_ac_arr->len : ((guint) 1); From a3f35ea5ccebefbecc5c416e6b21a8f1c8a1388b Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 17 May 2021 13:54:49 +0200 Subject: [PATCH 2/2] ovs: block auto activation of ovs-interfaces until ovsdb is ready Otherwise the device tries to activate too early and fails. --- src/core/devices/ovs/nm-device-ovs-interface.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/devices/ovs/nm-device-ovs-interface.c b/src/core/devices/ovs/nm-device-ovs-interface.c index ec4de356be..46a612aca7 100644 --- a/src/core/devices/ovs/nm-device-ovs-interface.c +++ b/src/core/devices/ovs/nm-device-ovs-interface.c @@ -77,6 +77,15 @@ is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags) return nm_ovsdb_is_ready(priv->ovsdb); } +static gboolean +can_auto_connect(NMDevice *device, NMSettingsConnection *sett_conn, char **specific_object) +{ + NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device); + NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); + + return nm_ovsdb_is_ready(priv->ovsdb); +} + static gboolean check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error) { @@ -424,6 +433,7 @@ nm_device_ovs_interface_class_init(NMDeviceOvsInterfaceClass *klass) device_class->connection_type_check_compatible = NM_SETTING_OVS_INTERFACE_SETTING_NAME; device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_OPENVSWITCH); + device_class->can_auto_connect = can_auto_connect; device_class->can_update_from_platform_link = can_update_from_platform_link; device_class->deactivate = deactivate; device_class->deactivate_async = deactivate_async;