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: 02dbe670ca ('device: for available connections check whether they are available for user-request')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1496
This commit is contained in:
Thomas Haller 2023-01-10 23:39:58 +01:00
parent f930d55fea
commit 7af9562f28
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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))