wifi: remove the MAC address check from complete_connection()

nm_device_complete_connection() now calls check_connection_compatible()
which has a redundant check.
This commit is contained in:
Lubomir Rintel 2019-05-07 11:51:16 +02:00
parent 48710fbf8d
commit 3f5064371a
2 changed files with 10 additions and 42 deletions

View file

@ -780,7 +780,6 @@ complete_connection (NMDevice *device,
NMDeviceIwd *self = NM_DEVICE_IWD (device);
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
NMSettingWireless *s_wifi;
const char *setting_mac;
gs_free char *ssid_utf8 = NULL;
NMWifiAP *ap;
GBytes *ssid;
@ -878,30 +877,17 @@ complete_connection (NMDevice *device,
TRUE);
perm_hw_addr = nm_device_get_permanent_hw_address (device);
if (perm_hw_addr) {
setting_mac = nm_setting_wireless_get_mac_address (s_wifi);
if (setting_mac) {
/* Make sure the setting MAC (if any) matches the device's permanent MAC */
if (!nm_utils_hwaddr_matches (setting_mac, -1, perm_hw_addr, -1)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
"connection does not match device");
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS);
return FALSE;
}
} else {
guint8 tmp[ETH_ALEN];
if (perm_hw_addr && !nm_setting_wireless_get_mac_address (s_wifi))
guint8 tmp[ETH_ALEN];
/* Lock the connection to this device by default if it uses a
* permanent MAC address (ie not a 'locally administered' one)
*/
nm_utils_hwaddr_aton (perm_hw_addr, tmp, ETH_ALEN);
if (!(tmp[0] & 0x02)) {
g_object_set (G_OBJECT (s_wifi),
NM_SETTING_WIRELESS_MAC_ADDRESS, perm_hw_addr,
NULL);
}
/* Lock the connection to this device by default if it uses a
* permanent MAC address (ie not a 'locally administered' one)
*/
nm_utils_hwaddr_aton (perm_hw_addr, tmp, ETH_ALEN);
if (!(tmp[0] & 0x02)) {
g_object_set (G_OBJECT (s_wifi),
NM_SETTING_WIRELESS_MAC_ADDRESS, perm_hw_addr,
NULL);
}
}

View file

@ -778,13 +778,11 @@ complete_connection (NMDevice *device,
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMSettingWireless *s_wifi;
const char *setting_mac;
gs_free char *ssid_utf8 = NULL;
NMWifiAP *ap;
GBytes *ssid = NULL;
GBytes *setting_ssid = NULL;
gboolean hidden = FALSE;
const char *perm_hw_addr;
const char *mode;
s_wifi = nm_connection_get_setting_wireless (connection);
@ -913,22 +911,6 @@ complete_connection (NMDevice *device,
if (hidden)
g_object_set (s_wifi, NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL);
perm_hw_addr = nm_device_get_permanent_hw_address (device);
if (perm_hw_addr) {
setting_mac = nm_setting_wireless_get_mac_address (s_wifi);
if (setting_mac) {
/* Make sure the setting MAC (if any) matches the device's permanent MAC */
if (!nm_utils_hwaddr_matches (setting_mac, -1, perm_hw_addr, -1)) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("connection does not match device"));
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME, NM_SETTING_WIRELESS_MAC_ADDRESS);
return FALSE;
}
}
}
return TRUE;
}