summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-03-02 16:14:18 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2017-03-02 16:40:51 +0100
commitbfaa338d46095d7884a581dbbe02979f4243f089 (patch)
treec33185d538dad03a64710abf8359aaaa545a3c04
parentb2112bb053f20e67f907054557f53b106d61ca2e (diff)
downloadNetworkManager-bg/slaves-order-rh1420708.tar.gz
manager: sort slaves to be autoconnected by device namebg/slaves-order-rh1420708
Autoconnect slaves based on device name order instead of activation timestamp.
-rw-r--r--src/nm-manager.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 9b3c5c0bde..b5cdd76ee4 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2897,6 +2897,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,
@@ -2910,6 +2926,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];