Remove unnecessary copying of SSID and BSSID for external_auth

The external authentication command and event does not need to copy the
BSSID/SSID values into struct external_auth since those values are used
before returning from the call. Simplify this by using const u8 * to
external data instead of the array with a copy of the external data.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-04-12 20:38:08 +03:00 committed by Jouni Malinen
parent 4ffb0fefe4
commit dd1a8cef4c
5 changed files with 11 additions and 13 deletions

View file

@ -708,7 +708,7 @@ static void sae_sme_send_external_auth_status(struct hostapd_data *hapd,
os_memset(&params, 0, sizeof(params)); os_memset(&params, 0, sizeof(params));
params.status = status; params.status = status;
os_memcpy(params.bssid, sta->addr, ETH_ALEN); params.bssid = sta->addr;
if (status == WLAN_STATUS_SUCCESS && sta->sae) if (status == WLAN_STATUS_SUCCESS && sta->sae)
params.pmkid = sta->sae->pmkid; params.pmkid = sta->sae->pmkid;

View file

@ -2163,8 +2163,8 @@ struct external_auth {
EXT_AUTH_START, EXT_AUTH_START,
EXT_AUTH_ABORT, EXT_AUTH_ABORT,
} action; } action;
u8 bssid[ETH_ALEN]; const u8 *bssid;
u8 ssid[SSID_MAX_LEN]; const u8 *ssid;
size_t ssid_len; size_t ssid_len;
unsigned int key_mgmt_suite; unsigned int key_mgmt_suite;
u16 status; u16 status;

View file

@ -10820,11 +10820,12 @@ static int nl80211_send_external_auth_status(void *priv,
msg = nl80211_drv_msg(drv, 0, NL80211_CMD_EXTERNAL_AUTH); msg = nl80211_drv_msg(drv, 0, NL80211_CMD_EXTERNAL_AUTH);
if (!msg || if (!msg ||
nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, params->status) || nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, params->status) ||
(params->ssid_len && (params->ssid && params->ssid_len &&
nla_put(msg, NL80211_ATTR_SSID, params->ssid_len, params->ssid)) || nla_put(msg, NL80211_ATTR_SSID, params->ssid_len, params->ssid)) ||
(params->pmkid && (params->pmkid &&
nla_put(msg, NL80211_ATTR_PMKID, PMKID_LEN, params->pmkid)) || nla_put(msg, NL80211_ATTR_PMKID, PMKID_LEN, params->pmkid)) ||
nla_put(msg, NL80211_ATTR_BSSID, ETH_ALEN, params->bssid)) (params->bssid &&
nla_put(msg, NL80211_ATTR_BSSID, ETH_ALEN, params->bssid)))
goto fail; goto fail;
ret = send_and_recv_msgs(drv, msg, NULL, NULL); ret = send_and_recv_msgs(drv, msg, NULL, NULL);
msg = NULL; msg = NULL;

View file

@ -2269,11 +2269,9 @@ static void nl80211_external_auth(struct wpa_driver_nl80211_data *drv,
event.external_auth.ssid_len = nla_len(tb[NL80211_ATTR_SSID]); event.external_auth.ssid_len = nla_len(tb[NL80211_ATTR_SSID]);
if (event.external_auth.ssid_len > SSID_MAX_LEN) if (event.external_auth.ssid_len > SSID_MAX_LEN)
return; return;
os_memcpy(event.external_auth.ssid, nla_data(tb[NL80211_ATTR_SSID]), event.external_auth.ssid = nla_data(tb[NL80211_ATTR_SSID]);
event.external_auth.ssid_len);
os_memcpy(event.external_auth.bssid, nla_data(tb[NL80211_ATTR_BSSID]), event.external_auth.bssid = nla_data(tb[NL80211_ATTR_BSSID]);
ETH_ALEN);
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"nl80211: External auth action: %u, AKM: 0x%x", "nl80211: External auth action: %u, AKM: 0x%x",

View file

@ -965,10 +965,9 @@ static void sme_send_external_auth_status(struct wpa_supplicant *wpa_s,
os_memset(&params, 0, sizeof(params)); os_memset(&params, 0, sizeof(params));
params.status = status; params.status = status;
os_memcpy(params.ssid, wpa_s->sme.ext_auth.ssid, params.ssid = wpa_s->sme.ext_auth.ssid;
wpa_s->sme.ext_auth.ssid_len);
params.ssid_len = wpa_s->sme.ext_auth.ssid_len; params.ssid_len = wpa_s->sme.ext_auth.ssid_len;
os_memcpy(params.bssid, wpa_s->sme.ext_auth.bssid, ETH_ALEN); params.bssid = wpa_s->sme.ext_auth.bssid;
wpa_drv_send_external_auth_status(wpa_s, &params); wpa_drv_send_external_auth_status(wpa_s, &params);
} }
@ -978,7 +977,7 @@ static void sme_handle_external_auth_start(struct wpa_supplicant *wpa_s,
{ {
struct wpa_ssid *ssid; struct wpa_ssid *ssid;
size_t ssid_str_len = data->external_auth.ssid_len; size_t ssid_str_len = data->external_auth.ssid_len;
u8 *ssid_str = data->external_auth.ssid; const u8 *ssid_str = data->external_auth.ssid;
/* Get the SSID conf from the ssid string obtained */ /* Get the SSID conf from the ssid string obtained */
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {