core: unblock OVS interfaces when the ovsdb is ready

OVS system interfaces can start to connect even before the ovsdb is
ready. However, the connection attempt is doomed to fail and the
NMSettingsConnection gets blocked with reason FAILED.

Unblock them once the ovsdb is ready.

Ideally, NMPolicy should subscribe to the NMOvsdb::ready signal,
however NMOvsdb is in a plugin, so it's easier if NMOvsdb directly
calls a function of the core.
This commit is contained in:
Beniamino Galvani 2021-01-25 15:02:35 +01:00
parent c3cb177b7d
commit e2b4417570
5 changed files with 38 additions and 0 deletions

View file

@ -15,6 +15,7 @@
#include "nm-core-utils.h"
#include "nm-core-internal.h"
#include "devices/nm-device.h"
#include "nm-manager.h"
#include "nm-setting-ovs-external-ids.h"
/*****************************************************************************/
@ -2268,6 +2269,7 @@ _check_ready(NMOvsdb *self)
if (priv->num_pending_deletions == 0) {
priv->ready = TRUE;
g_signal_emit(self, signals[READY], 0);
nm_manager_unblock_failed_ovs_interfaces(nm_manager_get());
}
}

View file

@ -7582,6 +7582,14 @@ periodic_update_active_connection_timestamps(gpointer user_data)
return G_SOURCE_CONTINUE;
}
void
nm_manager_unblock_failed_ovs_interfaces(NMManager *self)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
nm_policy_unblock_failed_ovs_interfaces(priv->policy);
}
/*****************************************************************************/
void

View file

@ -209,4 +209,6 @@ void nm_manager_device_auth_request(NMManager * self,
NMManagerDeviceAuthRequestFunc callback,
gpointer user_data);
void nm_manager_unblock_failed_ovs_interfaces(NMManager *self);
#endif /* __NETWORKMANAGER_MANAGER_H__ */

View file

@ -1541,6 +1541,30 @@ hostname_changed(NMHostnameManager *hostname_manager, GParamSpec *pspec, gpointe
update_system_hostname(self, "hostname changed");
}
void
nm_policy_unblock_failed_ovs_interfaces(NMPolicy *self)
{
NMPolicyPrivate * priv = NM_POLICY_GET_PRIVATE(self);
NMSettingsConnection *const *connections = NULL;
guint i;
_LOGT(LOGD_DEVICE, "unblocking failed OVS interfaces");
connections = nm_settings_get_connections(priv->settings, NULL);
for (i = 0; connections[i]; i++) {
NMSettingsConnection *sett_conn = connections[i];
NMConnection * connection = nm_settings_connection_get_connection(sett_conn);
if (nm_connection_get_setting_ovs_interface(connection)) {
nm_settings_connection_autoconnect_retries_reset(sett_conn);
nm_settings_connection_autoconnect_blocked_reason_set(
sett_conn,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED,
FALSE);
}
}
}
static gboolean
reset_autoconnect_all(
NMPolicy *self,

View file

@ -32,6 +32,8 @@ NMActiveConnection *nm_policy_get_default_ip6_ac(NMPolicy *policy);
NMActiveConnection *nm_policy_get_activating_ip4_ac(NMPolicy *policy);
NMActiveConnection *nm_policy_get_activating_ip6_ac(NMPolicy *policy);
void nm_policy_unblock_failed_ovs_interfaces(NMPolicy *self);
/**
* NMPolicyHostnameMode
* @NM_POLICY_HOSTNAME_MODE_NONE: never update the transient hostname.