diff options
author | Thomas Haller <thaller@redhat.com> | 2023-11-06 11:32:46 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-11-15 09:34:47 +0100 |
commit | a5f9f2fbfceb39b63aa3f652062bc130d46a2fed (patch) | |
tree | 210ba310651aeb2ab31fe7dae13529130bba1567 | |
parent | 8ccd1f7bfed399e236b78c29b1f9549fc92afb72 (diff) |
cli: sort external connections later in `nmcli connection|device`
EXTERNAL connections are special. Sort them later. This affects output
of `nmcli connection` and `nmcli device`.
-rw-r--r-- | src/nmcli/connections.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index b1db014069..3b97da76a4 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -300,21 +300,27 @@ active_connection_get_state_ord(NMActiveConnection *active) }; NMActiveConnectionState state; int i; + gboolean is_external; /* returns an integer related to @active's state, that can be used for sorting * active connections based on their activation state. */ if (!active) - return -2; + return -10; - state = nm_active_connection_get_state(active); + state = nm_active_connection_get_state(active); + is_external = NM_FLAGS_HAS(nm_active_connection_get_state_flags(active), + NM_ACTIVATION_STATE_FLAG_EXTERNAL); for (i = 0; i < (int) G_N_ELEMENTS(ordered_states); i++) { - if (state == ordered_states[i]) + if (state == ordered_states[i]) { + if (!is_external) + i += G_N_ELEMENTS(ordered_states); return i; + } } - return -1; + return is_external ? -2 : -1; } int |