mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 07:08:02 +02:00
core: various minor code cleanups around find_master()
(cherry picked from commit 44076802a9)
This commit is contained in:
parent
f81b6a6994
commit
8e0a61d4e2
1 changed files with 18 additions and 20 deletions
|
|
@ -2088,9 +2088,10 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||||
guint i;
|
guint i;
|
||||||
gs_free char *iface = NULL;
|
gs_free char *iface = NULL;
|
||||||
const char *parent_spec;
|
const char *parent_spec;
|
||||||
NMDevice *device = NULL, *parent = NULL;
|
NMDevice *device = NULL;
|
||||||
|
NMDevice *parent = NULL;
|
||||||
NMDevice *dev_candidate;
|
NMDevice *dev_candidate;
|
||||||
GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
NMLogLevel log_level;
|
NMLogLevel log_level;
|
||||||
|
|
||||||
g_return_val_if_fail(NM_IS_MANAGER(self), NULL);
|
g_return_val_if_fail(NM_IS_MANAGER(self), NULL);
|
||||||
|
|
@ -2099,7 +2100,6 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||||
iface = nm_manager_get_connection_iface(self, connection, &parent, &parent_spec, &error);
|
iface = nm_manager_get_connection_iface(self, connection, &parent, &parent_spec, &error);
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
_LOG3D(LOGD_DEVICE, connection, "can't get a name of a virtual device: %s", error->message);
|
_LOG3D(LOGD_DEVICE, connection, "can't get a name of a virtual device: %s", error->message);
|
||||||
g_error_free(error);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2137,7 +2137,6 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||||
device = nm_device_factory_create_device(factory, iface, NULL, connection, NULL, &error);
|
device = nm_device_factory_create_device(factory, iface, NULL, connection, NULL, &error);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
_LOG3W(LOGD_DEVICE, connection, "factory can't create the device: %s", error->message);
|
_LOG3W(LOGD_DEVICE, connection, "factory can't create the device: %s", error->message);
|
||||||
g_error_free(error);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2148,7 +2147,6 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||||
connection,
|
connection,
|
||||||
"can't register the device with manager: %s",
|
"can't register the device with manager: %s",
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free(error);
|
|
||||||
g_object_unref(device);
|
g_object_unref(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -2169,7 +2167,6 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||||
|
|
||||||
if (!find_master(self, connection, device, NULL, NULL, NULL, &error)) {
|
if (!find_master(self, connection, device, NULL, NULL, NULL, &error)) {
|
||||||
_LOG3D(LOGD_DEVICE, connection, "skip activation: %s", error->message);
|
_LOG3D(LOGD_DEVICE, connection, "skip activation: %s", error->message);
|
||||||
g_error_free(error);
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2183,7 +2180,6 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
s_con = nm_connection_get_setting_connection(candidate);
|
s_con = nm_connection_get_setting_connection(candidate);
|
||||||
g_assert(s_con);
|
|
||||||
if (!nm_setting_connection_get_autoconnect(s_con)
|
if (!nm_setting_connection_get_autoconnect(s_con)
|
||||||
|| nm_settings_connection_autoconnect_is_blocked(connections[i]))
|
|| nm_settings_connection_autoconnect_is_blocked(connections[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2199,7 +2195,6 @@ system_create_virtual_device(NMManager *self, NMConnection *connection)
|
||||||
connection,
|
connection,
|
||||||
"couldn't create the device: %s",
|
"couldn't create the device: %s",
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free(error);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4409,8 +4404,11 @@ find_master(NMManager *self,
|
||||||
NMSettingsConnection *const *connections;
|
NMSettingsConnection *const *connections;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
s_con = nm_connection_get_setting_connection(connection);
|
nm_assert(!out_master_connection || !*out_master_connection);
|
||||||
g_assert(s_con);
|
nm_assert(!out_master_device || !*out_master_device);
|
||||||
|
nm_assert(!out_master_ac || !*out_master_ac);
|
||||||
|
|
||||||
|
s_con = nm_connection_get_setting_connection(connection);
|
||||||
master = nm_setting_connection_get_master(s_con);
|
master = nm_setting_connection_get_master(s_con);
|
||||||
|
|
||||||
if (master == NULL)
|
if (master == NULL)
|
||||||
|
|
@ -4518,10 +4516,8 @@ find_master(NMManager *self,
|
||||||
nm_device_get_iface(master_device));
|
nm_device_get_iface(master_device));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out_master_connection)
|
NM_SET_OUT(out_master_connection, master_connection);
|
||||||
*out_master_connection = master_connection;
|
NM_SET_OUT(out_master_device, master_device);
|
||||||
if (out_master_device)
|
|
||||||
*out_master_device = master_device;
|
|
||||||
if (out_master_ac && master_connection) {
|
if (out_master_ac && master_connection) {
|
||||||
*out_master_ac = active_connection_find(self,
|
*out_master_ac = active_connection_find(self,
|
||||||
master_connection,
|
master_connection,
|
||||||
|
|
@ -4531,15 +4527,15 @@ find_master(NMManager *self,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (master_device || master_connection)
|
if (!master_device && !master_connection) {
|
||||||
return TRUE;
|
|
||||||
else {
|
|
||||||
g_set_error_literal(error,
|
g_set_error_literal(error,
|
||||||
NM_MANAGER_ERROR,
|
NM_MANAGER_ERROR,
|
||||||
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
NM_MANAGER_ERROR_UNKNOWN_DEVICE,
|
||||||
"Master connection not found or invalid");
|
"Master connection not found or invalid");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -4784,8 +4780,9 @@ find_slaves(NMManager *manager,
|
||||||
&n_all_connections);
|
&n_all_connections);
|
||||||
for (i = 0; i < n_all_connections; i++) {
|
for (i = 0; i < n_all_connections; i++) {
|
||||||
NMSettingsConnection *master_connection = NULL;
|
NMSettingsConnection *master_connection = NULL;
|
||||||
NMDevice *master_device = NULL, *slave_device;
|
NMDevice *master_device = NULL;
|
||||||
NMSettingsConnection *candidate = all_connections[i];
|
NMDevice *slave_device;
|
||||||
|
NMSettingsConnection *candidate = all_connections[i];
|
||||||
|
|
||||||
find_master(manager,
|
find_master(manager,
|
||||||
nm_settings_connection_get_connection(candidate),
|
nm_settings_connection_get_connection(candidate),
|
||||||
|
|
@ -5118,7 +5115,8 @@ active_connection_parent_active(NMActiveConnection *active,
|
||||||
static gboolean
|
static gboolean
|
||||||
_internal_activate_device(NMManager *self, NMActiveConnection *active, GError **error)
|
_internal_activate_device(NMManager *self, NMActiveConnection *active, GError **error)
|
||||||
{
|
{
|
||||||
NMDevice *device, *master_device = NULL;
|
NMDevice *device;
|
||||||
|
NMDevice *master_device = NULL;
|
||||||
NMConnection *applied;
|
NMConnection *applied;
|
||||||
NMSettingsConnection *sett_conn;
|
NMSettingsConnection *sett_conn;
|
||||||
NMSettingsConnection *master_connection = NULL;
|
NMSettingsConnection *master_connection = NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue