mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 14:10:08 +01:00
cli: improve devices vs connection compatibility check
report error message on device compatibility failures
This commit is contained in:
parent
e7bd55afdd
commit
65771b80a6
2 changed files with 14 additions and 9 deletions
|
|
@ -1927,17 +1927,22 @@ find_device_for_connection (NmCli *nmc,
|
|||
|
||||
if (iface) {
|
||||
const char *dev_iface = nm_device_get_iface (dev);
|
||||
if ( !g_strcmp0 (dev_iface, iface)
|
||||
&& nm_device_connection_compatible (dev, connection, NULL)) {
|
||||
found_device = dev;
|
||||
if (!nm_streq0 (dev_iface, iface))
|
||||
continue;
|
||||
|
||||
if (!nm_device_connection_compatible (dev, connection, error)) {
|
||||
g_prefix_error (error, _("device '%s' not compatible with connection '%s':"),
|
||||
iface, nm_setting_connection_get_id (s_con));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (nm_device_connection_compatible (dev, connection, NULL)) {
|
||||
found_device = dev;
|
||||
}
|
||||
if (!nm_device_connection_compatible (dev, connection, NULL))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (found_device && ap && !strcmp (con_type, NM_SETTING_WIRELESS_SETTING_NAME) && NM_IS_DEVICE_WIFI (dev)) {
|
||||
found_device = dev;
|
||||
if (ap && !strcmp (con_type, NM_SETTING_WIRELESS_SETTING_NAME) && NM_IS_DEVICE_WIFI (dev)) {
|
||||
char *bssid_up = g_ascii_strup (ap, -1);
|
||||
const GPtrArray *aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (dev));
|
||||
found_device = NULL; /* Mark as not found; set to the device again later, only if AP matches */
|
||||
|
|
|
|||
|
|
@ -228,8 +228,8 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
s_mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (perm_addr) {
|
||||
if (!nm_utils_hwaddr_valid (perm_addr, ETH_ALEN)) {
|
||||
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||
_("Invalid device MAC address."));
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||
_("Invalid device MAC address %s."), perm_addr);
|
||||
return FALSE;
|
||||
}
|
||||
if (try_mac && s_mac && !nm_utils_hwaddr_matches (s_mac, -1, perm_addr, -1)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue