mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-20 22:10:08 +01:00
manager: sort slaves to be autoconnected by device name
Autoconnect slaves based on device name order instead of activation timestamp.
This commit is contained in:
parent
826f510303
commit
529a0a1a7f
1 changed files with 20 additions and 0 deletions
|
|
@ -2967,6 +2967,22 @@ out:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_slaves (gconstpointer a, gconstpointer b, gpointer _unused)
|
||||
{
|
||||
const SlaveConnectionInfo *a_info = a;
|
||||
const SlaveConnectionInfo *b_info = b;
|
||||
|
||||
/* Slaves without a device at the end */
|
||||
if (!a_info->device)
|
||||
return 1;
|
||||
if (!b_info->device)
|
||||
return -1;
|
||||
|
||||
return g_strcmp0 (nm_device_get_iface (a_info->device),
|
||||
nm_device_get_iface (b_info->device));
|
||||
}
|
||||
|
||||
static void
|
||||
autoconnect_slaves (NMManager *self,
|
||||
NMSettingsConnection *master_connection,
|
||||
|
|
@ -2980,6 +2996,10 @@ autoconnect_slaves (NMManager *self,
|
|||
guint i, n_slaves = 0;
|
||||
|
||||
slaves = find_slaves (self, master_connection, master_device, &n_slaves);
|
||||
if (n_slaves > 1) {
|
||||
g_qsort_with_data (slaves, n_slaves, sizeof (slaves[0]),
|
||||
compare_slaves, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < n_slaves; i++) {
|
||||
SlaveConnectionInfo *slave = &slaves[i];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue