adhoc: wait for both handshakes before adding peer

Adhoc was not waiting for BOTH handshakes to complete before adding the
new peer to the ConnectedPeers property. Actually waiting for the gtk/igtk
(in a previous commit) helps with this, but adhoc also needed to keep track
of which handshakes had completed, and only add the peer once BOTH were done.
This required a small change in netdev, where we memcmp the addresses from
both handshakes and only set the PTK on one.
This commit is contained in:
James Prestwood 2018-10-26 09:44:59 -07:00 committed by Denis Kenzior
parent e678d6655f
commit b9029aaf65
2 changed files with 13 additions and 3 deletions

View File

@ -67,7 +67,8 @@ struct sta_state {
struct eapol_sm *sm_a;
struct handshake_state *hs_auth;
uint32_t gtk_query_cmd_id;
bool hs_sta_done : 1;
bool hs_auth_done : 1;
bool authenticated : 1;
};
@ -183,7 +184,13 @@ static void adhoc_handshake_event(struct handshake_state *hs,
return;
case HANDSHAKE_EVENT_COMPLETE:
if ((sta->hs_auth == hs || sta->hs_sta == hs) &&
if (sta->hs_auth == hs)
sta->hs_auth_done = true;
if (sta->hs_sta == hs)
sta->hs_sta_done = true;
if ((sta->hs_auth_done && sta->hs_sta_done) &&
!sta->authenticated) {
sta->authenticated = true;
l_dbus_property_changed(dbus_get_bus(),

View File

@ -1425,8 +1425,11 @@ static void netdev_set_tk(struct handshake_state *hs,
* by the STA Authenticator with the higher MAC address...
*/
if (netdev->type == NL80211_IFTYPE_ADHOC &&
memcmp(nhs->super.aa, nhs->super.spa, 6) < 0)
memcmp(nhs->super.aa, nhs->super.spa, 6) < 0) {
nhs->ptk_installed = true;
try_handshake_complete(nhs);
return;
}
l_debug("%d", netdev->index);