wifi/iwd: return existing connection from mirror_8021x_connection

interface_added expects mirror_8021x_connection() to return the pointer to
the existing connection if one exists, and NULL on error, rather than
NULL if a conneciton exists.  While touching that, add logic to return
specifically a connection with EAP method set to 'external' if one
exists even though this should not affect any other logic we have
currently.
This commit is contained in:
Andrew Zaborowski 2018-10-18 17:41:04 +02:00 committed by Thomas Haller
parent a9d1aaf090
commit ba52c4ea0a

View file

@ -376,7 +376,7 @@ mirror_8021x_connection (NMIwdManager *self,
NMSettings *settings = NM_SETTINGS_GET;
NMSettingsConnection *const*iter;
gs_unref_object NMConnection *connection = NULL;
NMSettingsConnection *settings_connection;
NMSettingsConnection *settings_connection = NULL;
char uuid[37];
NMSetting *setting;
GError *error = NULL;
@ -388,6 +388,9 @@ mirror_8021x_connection (NMIwdManager *self,
NMIwdNetworkSecurity security;
gs_free char *ssid_name = NULL;
NMSettingWireless *s_wifi;
NMSetting8021x *s_8021x;
gboolean external = FALSE;
guint i;
security = nm_wifi_connection_get_iwd_security (conn, NULL);
if (security != NM_IWD_NETWORK_SECURITY_8021X)
@ -399,14 +402,29 @@ mirror_8021x_connection (NMIwdManager *self,
ssid_name = _nm_utils_ssid_to_utf8 (nm_setting_wireless_get_ssid (s_wifi));
/* We already have an NMSettingsConnection matching this
* KnownNetwork, whether it's saved or an in-memory connection
* potentially created by ourselves. Nothing to do here.
*/
if (nm_streq (ssid_name, name))
return NULL;
if (!nm_streq (ssid_name, name))
continue;
s_8021x = nm_connection_get_setting_802_1x (conn);
for (i = 0; i < nm_setting_802_1x_get_num_eap_methods (s_8021x); i++) {
if (nm_streq (nm_setting_802_1x_get_eap_method (s_8021x, i), "external")) {
external = TRUE;
break;
}
}
/* Prefer returning connections for EAP method "external" */
if (!settings_connection || external)
settings_connection = sett_conn;
}
/* We already have an NMSettingsConnection matching this
* KnownNetwork, whether it's saved or an in-memory connection
* potentially created by ourselves. Nothing to do here.
*/
if (settings_connection)
return settings_connection;
connection = nm_simple_connection_new ();
setting = NM_SETTING (g_object_new (NM_TYPE_SETTING_CONNECTION,