summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-10-08 17:41:19 +0200
committerThomas Haller <thaller@redhat.com>2020-10-08 17:45:40 +0200
commit09b1cce523febd2f1e91b331523c3a5ef53b291c (patch)
tree6345d1f86051c17d85a74e6aae8a8dd81a0ee7b2
parent3cab307fa72b796eb9a61e7cfc22556bd9f6852a (diff)
downloadNetworkManager-th/cli-fix-con-show-active-field.tar.gz
cli: fix showing active state for `nmcli con show` with fieldsth/cli-fix-con-show-active-field
With "connection.multi-connect", a profile can be activated multiple times on a device with `nmcli connection show`. Also, a profile may be in the process of deactivating on one device, while activating on another one. So, in general it's possible that `nmcli connection show` lists the same profile on multiple lines (reflecting their multiple activation states). If the user requests no fields that are part of the activation state, then the active connections are ignored. For example with `nmcli -f UUID,NAME connection show`. In that case, each profile is listed only once. On the other hand, with `nmcli -g UUID,NAME,DEVICE connection show` the user again requested also to see the activation state, and a profile can appear multiple times. To handle that, we need to consider which fields were requested. There was a bug where the "ACTIVE" field was not treated as part of the activation state. That results in `nmcli -f UUID,NAME,ACTIVE connection show` always returning "no". Fix that. Fixes: a1b25a47b08c ('cli: rework printing of `nmcli connection` for multiple active connections')
-rw-r--r--clients/cli/connections.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 1fb87bce50..3714485a16 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -2180,6 +2180,7 @@ do_connections_show(const NMCCommand *cmd, NmCli *nmc, int argc, const char *con
if (NM_IN_SET(info->info_type,
NMC_GENERIC_INFO_TYPE_CON_SHOW_DEVICE,
NMC_GENERIC_INFO_TYPE_CON_SHOW_STATE,
+ NMC_GENERIC_INFO_TYPE_CON_SHOW_ACTIVE,
NMC_GENERIC_INFO_TYPE_CON_SHOW_ACTIVE_PATH)) {
show_active_fields = TRUE;
break;