From 7af9562f28f2e80fed41262e0f82510be7cf8c8e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 10 Jan 2023 23:39:58 +0100 Subject: [PATCH] device: fix available-connections for a device for user-request There are two callers of available_connections_add(). One from cp_connection_added_or_updated() (which is when a connection gets added/modified) and one from nm_device_recheck_available_connections(). They both call first nm_device_check_connection_available() to see whether the profile is available on the device. They certainly need to pass the same check flags, otherwise a profile might be available in some cases, and not in others. I didn't actually test this, but I think this could result in a profile wrongly not being listed as an available-connection. Moreover, that might mean, that `nmcli connection up $PROFILE` might work to find the device/profile, but `nmcli device up $DEVICE` couldn't find the suitable profile (because the latter calls nm_device_get_best_connection(), which iterates the available-connections). I didn't test this, because regardless of that, it seems obvious that the conditions for when we call available_connections_add() must be the same from both places. So the only question is what is the right condition, and it would seem that _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST is the right flag. Fixes: 02dbe670ca0a ('device: for available connections check whether they are available for user-request') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1496 --- src/core/devices/nm-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index c4e163d1b7..93399cafb2 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -15096,7 +15096,7 @@ nm_device_recheck_available_connections(NMDevice *self) if (nm_device_check_connection_available(self, nm_settings_connection_get_connection(sett_conn), - NM_DEVICE_CHECK_CON_AVAILABLE_NONE, + _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST, NULL, NULL)) { if (available_connections_add(self, sett_conn))