From 74b5a4ae7ae30c8b4e4a891c9a39c80359ab5415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Thu, 7 Apr 2022 16:26:24 +0200 Subject: [PATCH] pc_wifi_drv: handle reauth silently In case we are instructed to reauthenticate and were already authenticated we ignore the request in the management layer and let 'wpa_supplicant' deal with that. Fixes #4488. --- repos/pc/src/drivers/wifi/pc/frontend.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/repos/pc/src/drivers/wifi/pc/frontend.h b/repos/pc/src/drivers/wifi/pc/frontend.h index 63ad6b8a2d..9cd9379ec8 100644 --- a/repos/pc/src/drivers/wifi/pc/frontend.h +++ b/repos/pc/src/drivers/wifi/pc/frontend.h @@ -1352,6 +1352,10 @@ struct Wifi::Frontend bool _connected_event { false }; bool _disconnected_event { false }; bool _disconnected_fail { false }; + bool _was_connected { false }; + + enum { MAX_REAUTH_ATTEMPTS = 1 }; + unsigned _reauth_attempts { 0 }; enum { MAX_ATTEMPTS = 3, }; unsigned _scan_attempts { 0 }; @@ -1360,6 +1364,10 @@ struct Wifi::Frontend void _handle_connection_events(char const *msg) { + _connected_event = false; + _disconnected_event = false; + _disconnected_fail = false; + bool const connected = check_recv_msg(msg, recv_table[Rmi::CONNECTED]); bool const disconnected = check_recv_msg(msg, recv_table[Rmi::DISCONNECTED]); bool const auth_failed = disconnected && _auth_failure(msg); @@ -1367,6 +1375,16 @@ struct Wifi::Frontend State state = connected ? State::CONNECTED : State::DISCONNECTED; Accesspoint::Bssid const &bssid = _extract_bssid(msg, state); + /* simplistic heuristic to ignore re-authentication requests */ + if (_connected_ap.bssid.valid() && auth_failed) { + if (_reauth_attempts < MAX_ATTEMPTS) { + Genode::log("ignore deauth from: ", _connected_ap.bssid); + _reauth_attempts++; + return; + } + } + _reauth_attempts = 0; + /* * Always reset the "global" connection state first */