Support fallback if FT fails
cover Support fallback if FT fails
Its explained as well in the commit description, but we have run into several cases where IWD continually fails to FT due to the (only) AP rejecting it with "Invalid PMKID". It appears to be due to APs failing to communicate current associations e.g. after one is rebooted.
If IWD can manage to see another AP it will roam, but in cases of poor coverage eventually the link gets so bad IWD will disconnect and then successfully associate to the AP that was rejecting it. This can take some time though and results in many dropped frames and/or virtually no connectivity.
To try and remedy this we can instead fall back to reassociation if FT fails with a specific status (53).
One caveat I can think of is there may be additional BSS to FT to which this logic won't consider until the fallback/reassoc also fails. This leaves out potential BSS's that could very well have worked fine. I do think this is a tradeoff though, since the first/best candidate likely still has the best signal/link quailty. In addition reassociation is certainly better than getting disconnected.
An alternative would be to attempt FT to all BSS's, then fall back to reassociation although I could see this backfiring with IWD connecting to a better but still poor BSS rather than a good BSS that just hasn't gotten its act together quite yet.
James Prestwood (3):
ft: track FT auth/action response status
station: fall back to reassociation under certain FT failures
auto-t: add fallback to reassociate test
autotests/testPSK-roam/failed_roam_test.py | 70 ++++++++++- autotests/testPSK-roam/ft-psk-ccmp-1.conf | 1 + autotests/testPSK-roam/ft-psk-ccmp-2.conf | 1 + autotests/testPSK-roam/ft-psk-ccmp-3.conf | 1 + src/ft.c | 37 ++++-- src/station.c | 129 +++++++++++++-------- 6 files changed, 180 insertions(+), 59 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 ft: track FT auth/action response status
Certain return codes, though failures, can indicate that the AP is just confused or booting up and treating it as a full failure may not be the best route.
For example in some production deployments if an AP is rebooted it may take some time for neighboring APs to exchange keys for current associations. If a client roams during that time it will reject saying the PMKID is invalid.
Use the ft_associate call to relay this information to station to handle it rather than acting like there was no response. For now this is being hard coded to status=53, but more could be added, or the status itself could be returned if there are other specific status codes that need to be handled.
--- src/ft.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)
src/ft.c +28 -9
@@ -58,6 +58,7 @@ struct ft_info {uint32_t frequency;uint32_t ds_frequency;uint32_t offchannel_id; +uint16_t status;struct l_timeout *timeout;struct wiphy_radio_work_item work;
@@ -155,6 +156,7 @@ static bool ft_parse_authentication_resp_frame(const uint8_t *data, size_t len,if (memcmp (data +16 , addr3,6 ))return false; +/* Check Authentication algorithm number is FT (2) */ if (l_get_le16 (data +24 ) !=2 )return false;
@@ -527,8 +529,6 @@ static int ft_over_ds_parse_action_response(const uint8_t *frame,return -EINVAL ; status =l_get_le16 (frame +14 ); -if (status !=0 ) -return (int )status;if (spa_out) *spa_out = spa;
@@ -541,7 +541,7 @@ static int ft_over_ds_parse_action_response(const uint8_t *frame, *ies_len = frame_len -16 ; } -return 0 ; +return (int )status; }int __ft_rx_associate (uint32_t ifindex,const uint8_t *frame,size_t frame_len)
@@ -825,7 +825,7 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len) ret =ft_over_ds_parse_action_response (frame, frame_len, &spa, &aa, &ies, &ies_len); -if (ret !=0 ) { +if (ret <0 ) {l_debug ("Could not parse action response" );return ; }
@@ -836,6 +836,14 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len)return ; } + info->status = ret; + +if (info->status !=0 ) { +l_debug ("BSS " MAC " rejected FT action with status=%u" , +MAC_STR (info->aa), info->status); + goto done; + } +if (!ft_parse_ies (info, hs, ies, ies_len)) {l_debug ("Could not parse action response IEs" ); goto ft_error;
@@ -843,6 +851,7 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len) info->parsed = true; +done:l_timeout_remove (info->timeout); info->timeout =NULL ;
@@ -872,6 +881,7 @@ static struct ft_info *ft_info_new(struct handshake_state *hs, target_bss->rsne[1] + 2);l_getrandom (info->snonce,32 ); + info->status =0xffff ;return info; }
@@ -998,7 +1008,6 @@ void __ft_rx_authenticate(uint32_t ifindex, const uint8_t *frame,struct netdev *netdev =netdev_find (ifindex);struct handshake_state *hs =netdev_get_handshake (netdev);struct ft_info *info; -uint16_t status;const uint8_t *ies;size_t ies_len;
@@ -1008,14 +1017,14 @@ void __ft_rx_authenticate(uint32_t ifindex, const uint8_t *frame,if (!ft_parse_authentication_resp_frame (frame, frame_len, info->spa, info->aa, info->aa,2 , - &status, &ies, &ies_len)) { + &info->status, &ies, &ies_len)) {l_debug ("Could not parse auth response" );return ; } -if (status !=0 ) { +if (info->status !=0 ) {l_debug ("BSS " MAC " rejected FT auth with status=%u" , -MAC_STR (info->aa), status); +MAC_STR (info->aa), info->status); goto cancel; }
@@ -1165,10 +1174,20 @@ int ft_associate(uint32_t ifindex, const uint8_t *addr)* attempt so clear out the entry so FT-over-Air can try again. */ if (!info->parsed) { +uint16_t status = info->status; +l_queue_remove (info_list, info);ft_info_destroy (info); -return -ENOENT ; +/* +* The status may have been successful but the IEs were invalid, +* treat this the same as no response. +*/ +if (status ==0xffff || status ==0 ) +return -ENOENT ; + +/* If the AP rejected for some reason, relay this to station */ +return (int )status; }ft_prepare_handshake (info, hs);
Signature · 1 line
2.25.1
Re: [PATCH 1/3] ft: track FT auth/action response status
Quoted 9 lines · James Prestwood
Certain return codes, though failures, can indicate that the AP is just confused or booting up and treating it as a full failure may not be the best route.
For example in some production deployments if an AP is rebooted it may take some time for neighboring APs to exchange keys for current associations. If a client roams during that time it will reject saying the PMKID is invalid.
Quoted 5 lines
Use the
ft_associatecall to relay this information to station to handle it rather than acting like there was no response. For now this is being hard coded to status=53, but more could be added, or the status itself could be returned if there are other specific status codes that need to be handled.
This part is wrong, I instead made ft_associate return the status directly, and station can sort out how it wants to proceed.
Quoted 130 lines
--- src/ft.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)src/ft.c +28
-9@@ -58,6 +58,7 @@ struct ft_info {uint32_t frequency;uint32_t ds_frequency;uint32_t offchannel_id; +uint16_t status;struct l_timeout *timeout;struct wiphy_radio_work_item work;@@ -155,6 +156,7 @@ static bool ft_parse_authentication_resp_frame(const uint8_t *data, size_t len,if (memcmp (data +16 , addr3,6 ))return false; +/* Check Authentication algorithm number is FT (2) */ if (l_get_le16 (data +24 ) !=2 )return false;@@ -527,8 +529,6 @@ static int ft_over_ds_parse_action_response(const uint8_t *frame,return -EINVAL ; status =l_get_le16 (frame +14 ); -if (status !=0 ) -return (int )status;if (spa_out) *spa_out = spa;@@ -541,7 +541,7 @@ static int ft_over_ds_parse_action_response(const uint8_t *frame, *ies_len = frame_len -16 ; } -return 0 ; +return (int )status; }int __ft_rx_associate (uint32_t ifindex,const uint8_t *frame,size_t frame_len)@@ -825,7 +825,7 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len) ret =ft_over_ds_parse_action_response (frame, frame_len, &spa, &aa, &ies, &ies_len); -if (ret !=0 ) { +if (ret <0 ) {l_debug ("Could not parse action response" );return ; }@@ -836,6 +836,14 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len)return ; } + info->status = ret; + +if (info->status !=0 ) { +l_debug ("BSS " MAC " rejected FT action with status=%u" , +MAC_STR (info->aa), info->status); + goto done; + } +if (!ft_parse_ies (info, hs, ies, ies_len)) {l_debug ("Could not parse action response IEs" ); goto ft_error;@@ -843,6 +851,7 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len) info->parsed = true; +done:l_timeout_remove (info->timeout); info->timeout =NULL ;@@ -872,6 +881,7 @@ static struct ft_info *ft_info_new(struct handshake_state *hs, target_bss->rsne[1] + 2);l_getrandom (info->snonce,32 ); + info->status =0xffff ;return info; }@@ -998,7 +1008,6 @@ void __ft_rx_authenticate(uint32_t ifindex, const uint8_t *frame,struct netdev *netdev =netdev_find (ifindex);struct handshake_state *hs =netdev_get_handshake (netdev);struct ft_info *info; -uint16_t status;const uint8_t *ies;size_t ies_len;@@ -1008,14 +1017,14 @@ void __ft_rx_authenticate(uint32_t ifindex, const uint8_t *frame,if (!ft_parse_authentication_resp_frame (frame, frame_len, info->spa, info->aa, info->aa,2 , - &status, &ies, &ies_len)) { + &info->status, &ies, &ies_len)) {l_debug ("Could not parse auth response" );return ; } -if (status !=0 ) { +if (info->status !=0 ) {l_debug ("BSS " MAC " rejected FT auth with status=%u" , -MAC_STR (info->aa), status); +MAC_STR (info->aa), info->status); goto cancel; }@@ -1165,10 +1174,20 @@ int ft_associate(uint32_t ifindex, const uint8_t *addr)* attempt so clear out the entry so FT-over-Air can try again. */ if (!info->parsed) { +uint16_t status = info->status; +l_queue_remove (info_list, info);ft_info_destroy (info); -return -ENOENT ; +/* +* The status may have been successful but the IEs were invalid, +* treat this the same as no response. +*/ +if (status ==0xffff || status ==0 ) +return -ENOENT ; + +/* If the AP rejected for some reason, relay this to station */ +return (int )status; }ft_prepare_handshake (info, hs);
Re: [PATCH 1/3] ft: track FT auth/action response status
In reply to James PrestwoodHi James,
Quoted 9 lines · James Prestwood
Certain return codes, though failures, can indicate that the AP is just confused or booting up and treating it as a full failure may not be the best route.
For example in some production deployments if an AP is rebooted it may take some time for neighboring APs to exchange keys for current associations. If a client roams during that time it will reject saying the PMKID is invalid.
Quoted 5 lines
Use the
ft_associatecall to relay this information to station to handle it rather than acting like there was no response. For now this is being hard coded to status=53, but more could be added, or the status itself could be returned if there are other specific status codes that need to be handled.
Please update the description per reply to this thread.
src/ft.c struct ft_info { · line 61
Quoted 13 lines
--- src/ft.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)src/ft.c +1
-0@@ -58,6 +58,7 @@ struct ft_info {uint32_t frequency;uint32_t ds_frequency;uint32_t offchannel_id; +uint16_t status;
Might want to indicate that this status is for the first step (authenticate/action)
src/ft.c static bool ft_parse_authentication_resp_frame(const uint8_t *data, size_t len, · line 159
Quoted 8 lines
src/ft.c +1
-0struct l_timeout *timeout;struct wiphy_radio_work_item work;@@ -155,6 +156,7 @@ static bool ft_parse_authentication_resp_frame(const uint8_t *data, size_t len,if (memcmp (data +16 , addr3,6 ))return false; +
This is spurious?
Quoted 3 lines
src/ft.c +0
-0/* Check Authentication algorithm number is FT (2) */ if (l_get_le16 (data +24 ) !=2 )return false;
<snip>
Quoted 5 lines
src/ft.c +1
-0@@ -836,6 +836,14 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len)return ; } + info->status = ret;
src/ft.c void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len) · line 849
Quoted 10 lines
src/ft.c +7
-0+ +if (info->status !=0 ) { +l_debug ("BSS " MAC " rejected FT action with status=%u" , +MAC_STR (info->aa), info->status); + goto done; + } +if (!ft_parse_ies (info, hs, ies, ies_len)) {l_debug ("Could not parse action response IEs" ); goto ft_error;
Should the status be set only once ft_parse_ies succeeded?
src/ft.c static struct ft_info *ft_info_new(struct handshake_state *hs, · line 884
Quoted 13 lines
src/ft.c +2
-0@@ -843,6 +851,7 @@ void __ft_rx_action(uint32_t ifindex, const uint8_t *frame, size_t frame_len) info->parsed = true; +done:l_timeout_remove (info->timeout); info->timeout =NULL ;@@ -872,6 +881,7 @@ static struct ft_info *ft_info_new(struct handshake_state *hs, target_bss->rsne[1] + 2);l_getrandom (info->snonce,32 ); + info->status =0xffff ;
Why is this needed?
Quoted 3 lines
src/ft.c +0
-0return info; }
<snip>
Quoted 9 lines
src/ft.c +2
-0@@ -1165,10 +1174,20 @@ int ft_associate(uint32_t ifindex, const uint8_t *addr)* attempt so clear out the entry so FT-over-Air can try again. */ if (!info->parsed) { +uint16_t status = info->status; +l_queue_remove (info_list, info);ft_info_destroy (info);
src/ft.c int ft_associate(uint32_t ifindex, const uint8_t *addr) · line 1190
Quoted 10 lines
src/ft.c +9
-1-return -ENOENT ; +/* +* The status may have been successful but the IEs were invalid, +* treat this the same as no response. +*/ +if (status ==0xffff || status ==0 ) +return -ENOENT ; + +/* If the AP rejected for some reason, relay this to station */ +return (int )status;
I think this entire step can be dropped if you make sure status == 0 is set only if parsing succeeded.
src/ft.c int ft_associate(uint32_t ifindex, const uint8_t *addr) · line 1193
Quoted 3 lines
src/ft.c +0
-0}ft_prepare_handshake (info, hs);
Regards,
-Denis
PATCH 2/3 station: fall back to reassociation under certain FT failures
In reply to James PrestwoodThe auth/action status is now tracked in ft.c. If an AP rejects the FT attempt with "Invalid PMKID" we can now assume this AP is either mis-configured for FT or is lagging behind getting the proper keys from neighboring APs (e.g. was just rebooted).
If we see this condition IWD can now fall back to reassociation in an attempt to still roam to the best candidate.
The motivation behind this isn't necissarily to always force a roam, but instead to handle the case where there are no other BSS's around. Currently IWD can get into a situation where the current BSS link is very poor but the only cadidate is stuck in this state where its rejecting the PMKID. When this happens it eventually leads to a disconnect due to packet/beacon loss. Its a much better approach to at least try reassociation.
--- src/station.c | 129 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 47 deletions(-)
src/station.c +82 -47
@@ -147,15 +147,49 @@ struct roam_bss {uint8_t addr[6 ];uint16_t rank;int32_t signal_strength; + bool reassoc: 1; }; -static struct roam_bss *roam_bss_from_scan_bss (const struct scan_bss *bss) +static bool station_can_fast_transition (struct handshake_state *hs, +const struct scan_bss *bss) +{ +uint16_t mdid; + +if (!hs->mde) +return false; + +if (ie_parse_mobility_domain_from_data (hs->mde, hs->mde[1 ] +2 , + &mdid,NULL ,NULL ) <0 ) +return false; + +if (!(bss->mde_present &&l_get_le16 (bss->mde) == mdid)) +return false; + +if (hs->supplicant_ie !=NULL ) { +struct ie_rsn_info rsn_info; + +if (!IE_AKM_IS_FT (hs->akm_suite)) +return false; + +if (scan_bss_get_rsn_info (bss, &rsn_info) <0 ) +return false; + +if (!IE_AKM_IS_FT (rsn_info.akm_suites)) +return false; + } + +return true; +} + +static struct roam_bss *roam_bss_from_scan_bss (struct handshake_state *hs, +const struct scan_bss *bss) { struct roam_bss *rbss = l_new(struct roam_bss, 1);memcpy (rbss->addr, bss->addr,6 ); rbss->rank = bss->rank; rbss->signal_strength = bss->signal_strength; + rbss->reassoc = !station_can_fast_transition (hs, bss);return rbss; }
@@ -1942,37 +1976,6 @@ static void station_early_neighbor_report_cb(struct netdev *netdev, int err, &station->roam_freqs); } -static bool station_can_fast_transition (struct handshake_state *hs, -struct scan_bss *bss) -{ -uint16_t mdid; - -if (!hs->mde) -return false; - -if (ie_parse_mobility_domain_from_data (hs->mde, hs->mde[1 ] +2 , - &mdid,NULL ,NULL ) <0 ) -return false; - -if (!(bss->mde_present &&l_get_le16 (bss->mde) == mdid)) -return false; - -if (hs->supplicant_ie !=NULL ) { -struct ie_rsn_info rsn_info; - -if (!IE_AKM_IS_FT (hs->akm_suite)) -return false; - -if (scan_bss_get_rsn_info (bss, &rsn_info) <0 ) -return false; - -if (!IE_AKM_IS_FT (rsn_info.akm_suites)) -return false; - } - -return true; -} -static void station_disconnect_on_error_cb (struct netdev *netdev,bool success,void *user_data) {
@@ -2169,10 +2172,14 @@ static int station_transition_reassociate(struct station *station,if (ret <0 )return ret; +l_debug ("" ); + station->connected_bss = bss; station->preparing_roam = false;station_enter_state (station,STATION_STATE_ROAMING ); +station_debug_event (station,"reassoc-roam" ); +return 0 ; }
@@ -2259,27 +2266,51 @@ static void station_preauthenticate_cb(struct netdev *netdev, } } -static void station_transition_start (struct station *station); +static void station_transition_start (struct station *station,bool no_ft);static bool station_ft_work_ready (struct wiphy_radio_work_item *item) { struct station *station = l_container_of(item, struct station, ft_work); -struct roam_bss *rbss =l_queue_pop_head (station->roam_bss_list); -struct scan_bss *bss =network_bss_find_by_addr ( - station->connected_network, rbss->addr); + L_AUTO_FREE_VAR(struct roam_bss *, rbss) = l_queue_pop_head( + station->roam_bss_list); +struct scan_bss *bss;int ret; -l_free (rbss); +/* Already failed FT, then failed reassociation, disregard this BSS */ +if (rbss->reassoc) { +l_free (l_steal_ptr (rbss)); + + rbss =l_queue_pop_head (station->roam_bss_list); +if (!rbss) + goto assoc_failed; + }/* Very unlikely, but the BSS could have gone away */ + bss =network_bss_find_by_addr (station->connected_network, rbss->addr);if (!bss) goto try_next; ret =ft_associate (netdev_get_ifindex (station->netdev), bss->addr); -if (ret == -ENOENT ) { +if (ret >0 ) { +if (ret !=MMPDU_STATUS_CODE_INVALID_PMKID ) { +station_debug_event (station,"ft-roam-failed" ); + goto try_next; + } + + rbss->reassoc = true; + +l_queue_push_head (station->roam_bss_list, rbss); + +station_debug_event (station,"ft-fallback-to-reassoc" ); + +/* FT failed, attempt reassociation as a last resort */ +station_transition_start (station, true); +l_steal_ptr (rbss); +return true; + }else if (ret == -ENOENT ) {station_debug_event (station,"ft-roam-failed" ); try_next: -station_transition_start (station); +station_transition_start (station, false);return true; }else if (ret <0 ) goto assoc_failed;
@@ -2288,6 +2319,8 @@ try_next: station->preparing_roam = false;station_enter_state (station,STATION_STATE_FT_ROAMING ); +station_debug_event (station,"ft-roam" ); +return true; assoc_failed:
@@ -2349,7 +2382,8 @@ done: }static bool station_try_next_transition (struct station *station, -struct scan_bss *bss) +struct scan_bss *bss, +bool no_ft) {struct handshake_state *hs =netdev_get_handshake (station->netdev);struct network *connected = station->connected_network;
@@ -2364,7 +2398,7 @@ static bool station_try_next_transition(struct station *station, station->ap_directed_roaming = false;/* Can we use Fast Transition? */ -if (station_can_fast_transition (hs, bss)) +if (station_can_fast_transition (hs, bss) && !no_ft)return station_fast_transition (station, bss);/* Non-FT transition */
@@ -2412,7 +2446,7 @@ static bool station_try_next_transition(struct station *station,return true; } -static void station_transition_start (struct station *station) +static void station_transition_start (struct station *station,bool no_ft) {struct roam_bss *rbss;bool roaming = false;
@@ -2425,7 +2459,7 @@ static void station_transition_start(struct station *station)struct scan_bss *bss =network_bss_find_by_addr ( station->connected_network, rbss->addr); - roaming =station_try_next_transition (station, bss); + roaming =station_try_next_transition (station, bss, no_ft);if (roaming)break ;
@@ -2581,7 +2615,7 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list,*/ station_update_roam_bss (station, bss); - rbss =roam_bss_from_scan_bss (bss); + rbss =roam_bss_from_scan_bss (hs, bss);l_queue_insert (station->roam_bss_list, rbss, roam_bss_rank_compare,NULL );
@@ -2600,7 +2634,7 @@ next: goto fail; } -station_transition_start (station); +station_transition_start (station, false);return true;
@@ -4584,6 +4618,7 @@ static bool station_force_roam_scan_notify(int err, struct l_queue *bss_list, {struct station_roam_data *data = user_data;struct station *station = data->station; +struct handshake_state *hs =netdev_get_handshake (station->netdev);struct scan_bss *target;struct l_dbus_message *reply;
@@ -4603,11 +4638,11 @@ static bool station_force_roam_scan_notify(int err, struct l_queue *bss_list,/* The various roam routines expect this to be set from scanning */ station->preparing_roam = true;l_queue_push_tail (station->roam_bss_list, -roam_bss_from_scan_bss (target)); +roam_bss_from_scan_bss (hs, target));station_update_roam_bss (station, target); -station_transition_start (station); +station_transition_start (station, false); reply =l_dbus_message_new_method_return (data->pending);
Signature · 1 line
2.25.1
Re: [PATCH 2/3] station: fall back to reassociation under certain FT failures
Hi James,
Quoted 9 lines · James Prestwood
The auth/action status is now tracked in
ft.c. If an AP rejects the FT attempt with "Invalid PMKID" we can now assume this AP is either mis-configured for FT or is lagging behind getting the proper keys from neighboring APs (e.g. was just rebooted).If we see this condition IWD can now fall back to reassociation in an attempt to still roam to the best candidate.
The motivation behind this isn't necissarily to always force a roam,
typo, 'necessarily'
Quoted 3 lines
but instead to handle the case where there are no other BSS's around. Currently IWD can get into a situation where the current BSS link is very poor but the only cadidate is stuck in this state
typo, 'candidate'
Quoted 3 lines
where its rejecting the PMKID. When this happens it eventually leads to a disconnect due to packet/beacon loss. Its a much better approach to at least try reassociation.
Okay, but you should really explain that what is the strategy if IWD has multiple FT candidates and the first (or many) reject the FT authentication step.
Quoted 15 lines
--- src/station.c | 129 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 47 deletions(-)src/station.c +1
-0@@ -147,15 +147,49 @@ struct roam_bss {uint8_t addr[6 ];uint16_t rank;int32_t signal_strength; + bool reassoc: 1; };
<snip>
src/station.c static void station_preauthenticate_cb(struct netdev *netdev, · line 2275
Quoted 11 lines
src/station.c +3
-4-static void station_transition_start (struct station *station); +static void station_transition_start (struct station *station,bool no_ft);static bool station_ft_work_ready (struct wiphy_radio_work_item *item) { struct station *station = l_container_of(item, struct station, ft_work); -struct roam_bss *rbss =l_queue_pop_head (station->roam_bss_list); -struct scan_bss *bss =network_bss_find_by_addr ( - station->connected_network, rbss->addr); + L_AUTO_FREE_VAR(struct roam_bss *, rbss) = l_queue_pop_head( + station->roam_bss_list);
_auto_(l_free) is prefered to L_AUTO_FREE_VAR
Quoted 26 lines
src/station.c +16
-2+struct scan_bss *bss;int ret; -l_free (rbss); +/* Already failed FT, then failed reassociation, disregard this BSS */ +if (rbss->reassoc) { +l_free (l_steal_ptr (rbss)); + + rbss =l_queue_pop_head (station->roam_bss_list); +if (!rbss) + goto assoc_failed; + }/* Very unlikely, but the BSS could have gone away */ + bss =network_bss_find_by_addr (station->connected_network, rbss->addr);if (!bss) goto try_next; ret =ft_associate (netdev_get_ifindex (station->netdev), bss->addr); -if (ret == -ENOENT ) { +if (ret >0 ) { +if (ret !=MMPDU_STATUS_CODE_INVALID_PMKID ) { +station_debug_event (station,"ft-roam-failed" ); + goto try_next; + } +
src/station.c static void station_preauthenticate_cb(struct netdev *netdev, · line 2309
Quoted 10 lines
src/station.c +10
-0+ rbss->reassoc = true; + +l_queue_push_head (station->roam_bss_list, rbss); + +station_debug_event (station,"ft-fallback-to-reassoc" ); + +/* FT failed, attempt reassociation as a last resort */ +station_transition_start (station, true); +l_steal_ptr (rbss); +return true;
So shouldn't you prefer FT over associate? If there are multiple FT candidates, then should iwd try those first?
src/station.c static void station_preauthenticate_cb(struct netdev *netdev, · line 2316
Quoted 8 lines
src/station.c +2
-1+ }else if (ret == -ENOENT ) {station_debug_event (station,"ft-roam-failed" ); try_next: -station_transition_start (station); +station_transition_start (station, false);return true; }else if (ret <0 ) goto assoc_failed;
Regards,
-Denis
Re: [PATCH 2/3] station: fall back to reassociation under certain FT failures
Hi Denis,
<snip>
Quoted 6 lines
Quoted 4 lines
where its rejecting the PMKID. When this happens it eventually leads to a disconnect due to packet/beacon loss. Its a much better approach to at least try reassociation.
Okay, but you should really explain that what is the strategy if IWD has multiple FT candidates and the first (or many) reject the FT authentication step.
In this patch the strategy is to always try the first candidate: try FT, and if failed with status=53, try reassociate.
There are drawbacks and benefits to this:
- The drawback is if reassociate also fails we have to disconnect, and
can't FT to any other candidates. This would mainly hurt if there are other good candidates to connect to.
- The benefit is if there is only one available BSS to roam to and we
failed FT but reassociation succeeded. This prevents us from trying and failing FT over and over. In addition if there are additional FT candidates but poor ranking we would still connect to the best candidate even if we do so via reassociation.
The decision to retry with reassociation mainly boils down to if there are other "good" candidates. If yes we should try FT on those since its faster and failure tolerant. But if all the other candidates or lack thereof are poor, we should reassociate to the one that failed FT, since its the best. Doing this logically is hard because we need to define whats "good" and whats "bad".
One option to make this better would be to recompute the BSS rank after FT fails, without RANK_FT_FACTOR, and re-insert into the queue. Although a 1.3x factor likely won't make a huge difference. The idea here being that if other candidates are closely ranked we try those via FT before falling back to reassociation.
Another option is to introduce some cutoff RSSI or rank value that determines if we retry with reassociation or move on to the next BSS with FT.
At the very least (mostly applicable to 1 roam candidate) we should keep track that all FT attempts failed and try reassociation on the next round.
Thanks,
James
Quoted 80 lines
Quoted 14 lines
---
src/station.c| 129 ++++++++++++++++++++++++++++++++------------------1 file changed, 82 insertions(+), 47 deletions(-)src/station.c +1
-0@@ -147,15 +147,49 @@ struct roam_bss { uint8_t addr[6]; uint16_t rank; int32_t signal_strength; + bool reassoc: 1; };<snip>
Quoted 11 lines
src/station.c +1
-1-static void station_transition_start (struct station *station); +static void station_transition_start(struct station *station, bool
no_ft);
static boolstation_ft_work_ready(struct wiphy_radio_work_item *item){
struct station *station =l_container_of(item, struct station, ft_work); - structroam_bss*rbss =l_queue_pop_head(station->roam_bss_list); - structscan_bss*bss = network_bss_find_by_addr(
-station->connected_network,rbss->addr);
+L_AUTO_FREE_VAR(struct roam_bss *, rbss)=l_queue_pop_head( + station->roam_bss_list);
_auto_(l_free)is prefered toL_AUTO_FREE_VARQuoted 25 lines
+ struct
scan_bss*bss;
int ret;
-l_free(rbss);
+ /* Already failed FT, then failed reassociation, disregard this BSS */
+ if (rbss->reassoc) {
+ l_free(l_steal_ptr(rbss));
+
+ rbss =l_queue_pop_head(station->roam_bss_list);
+ if (!rbss)
+ gotoassoc_failed;
+ }
/* Very unlikely, but the BSS could have gone away */
+ bss =network_bss_find_by_addr(station->connected_network, rbss->addr);
if (!bss)
gototry_next;
ret =ft_associate(netdev_get_ifindex(station->netdev), bss->addr); - if (ret ==-ENOENT) {
+ if (ret > 0) {
+ if (ret !=MMPDU_STATUS_CODE_INVALID_PMKID) {
+station_debug_event(station, "ft-roam-failed"); + gototry_next;
+ }src/station.c +1
-0+src/station.c static void station_preauthenticate_cb(struct netdev *netdev, · line 2309
Quoted 10 lines
src/station.c +10
-0+ rbss->reassoc = true; + + l_queue_push_head(station->roam_bss_list, rbss); + + station_debug_event(station, "ft-fallback-to-reassoc"); + + /* FT failed, attempt reassociation as a last resort */ + station_transition_start(station, true); + l_steal_ptr(rbss); + return true;So shouldn't you prefer FT over associate? If there are multiple FT candidates, then should iwd try those first? >
Quoted 8 lines
+ } else if (ret ==
-ENOENT) {station_debug_event(station, "ft-roam-failed");try_next:
-station_transition_start(station);
+station_transition_start(station, false); return true;
} else if (ret < 0)
gotoassoc_failed;Regards,
-Denis
Re: [PATCH 2/3] station: fall back to reassociation under certain FT failures
Hi James,
Quoted 5 lines
In this patch the strategy is to always try the first candidate: try FT, and if failed with status=53, try reassociate.
There are drawbacks and benefits to this:
- The drawback is if reassociate also fails we have to disconnect, and can't
FT to any other candidates. This would mainly hurt if there are other good candidates to connect to.
So that is a pretty significant drawback in my opinion. There's really no guarantee that the behavior you're seeing is the same for every vendor. As you point out, trying FT first has very little drawback. Falling back to the slow re-associate path does, especially on 802.1X networks.
Quoted 2 lines
- The benefit is if there is only one available BSS to roam to and we failed
FT but reassociation succeeded. This prevents us from trying and failing FT over and over. In addition if there are additional FT candidates but poor ranking we would still connect to the best candidate even if we do so via reassociation.
If there's only a single candidate, there's no difference between the two approaches. I'm not following the argument in the second sentence?
Quoted 2 lines
The decision to retry with reassociation mainly boils down to if there are other "good" candidates. If yes we should try FT on those since its faster and failure tolerant. But if all the other candidates or lack thereof are poor, we should reassociate to the one that failed FT, since its the best. Doing this logically is hard because we need to define whats "good" and whats "bad".
That sounds like an argument for trying all FT candidates first.
Doesn't iwd only consider candidates that have a higher rank than the current BSS?
Another possibility would be to insert the BSS twice (or reinsert once FT fails), once with FT and once without FT and try them in rank order. Still, there's almost no penalty to trying all FT candidates, so unless the ranking calculation is really off, I think that is a better approach.
Quoted 2 lines
One option to make this better would be to recompute the BSS rank after FT fails, without
RANK_FT_FACTOR, and re-insert into the queue. Although a 1.3x factor likely won't make a huge difference. The idea here being that if other candidates are closely ranked we try those via FT before falling back to reassociation.
Right.
Quoted 2 lines
Another option is to introduce some cutoff RSSI or rank value that determines if we retry with reassociation or move on to the next BSS with FT.
I doubt any absolute RSSI or rank cutoff will work. These are very hardware dependent. Better to refine the ranking calculation, but in the end the information we base the rank off of is imperfect, so sub-optimal decisions are going to be a fact of life.
Quoted 2 lines
At the very least (mostly applicable to 1 roam candidate) we should keep track that all FT attempts failed and try reassociation on the next round.
Or better yet, have the vendor fix the network.
Regards,
-Denis
Re: [PATCH 2/3] station: fall back to reassociation under certain FT failures
Hi Denis,
Quoted 8 lines · Denis Kenzior
Hi James,
Quoted 4 lines
In this patch the strategy is to always try the first candidate: try FT, and if failed with status=53, try reassociate.
There are drawbacks and benefits to this:
- The drawback is if reassociate also fails we have to disconnect, and can't FT to any other candidates. This would mainly hurt if there are other good candidates to connect to.So that is a pretty significant drawback in my opinion. There's really no guarantee that the behavior you're seeing is the same for every vendor. As you point out, trying FT first has very little drawback. Falling back to the slow re-associate path does, especially on 802.1X networks.
There isn't a guarantee about this behavior, but it is how hostapd behaves if the FT key pull mechanism is slow or not working yet. Either if the AP backend DHCP server is slow, or some other network issue. I really have no visibility into why it happens, its hidden behind their proprietary backend. Anyways handling this specific error code, if we can minimize the drawbacks, shouldn't hurt clients in other network deployments who's vendors don't have this behavior.
Quoted 4 lines
Quoted 2 lines
- The benefit is if there is only one available BSS to roam to and we failed FT but reassociation succeeded. This prevents us from trying and failing FT over and over. In addition if there are additional FT candidates but poor ranking we would still connect to the best candidate even if we do so via reassociation.
If there's only a single candidate, there's no difference between the two approaches. I'm not following the argument in the second sentence?
Yes a single candidate won't make a difference. What I was talking about is if you have the following:
Current BSS: -85dbm
Candidate A: -55dbm
Candidate B: -84dbm
If candidate A failed FT as described we would then FT to candidate B which would then immediately trigger another roam. I know its a very specific scenario but definitely can happen.
Quoted 9 lines
Quoted 3 lines
The decision to retry with reassociation mainly boils down to if there are other "good" candidates. If yes we should try FT on those since its faster and failure tolerant. But if all the other candidates or lack thereof are poor, we should reassociate to the one that failed FT, since its the best. Doing this logically is hard because we need to define whats "good" and whats "bad".
That sounds like an argument for trying all FT candidates first.
Doesn't iwd only consider candidates that have a higher rank than the current BSS?
Another possibility would be to insert the BSS twice (or reinsert once FT fails), once with FT and once without FT and try them in rank order. Still, there's almost no penalty to trying all FT candidates, so unless the ranking calculation is really off, I think that is a better approach.
Ok, I'd rather go this route then, re-insert the BSS without FT after this specific failure.
Would you want me to put this behind a config option? Or you think reassociation based on ranking is ok? Again, it would only be with status=53 so I think the impact is minimal.
Quoted 7 lines
Quoted 3 lines
One option to make this better would be to recompute the BSS rank after FT fails, without
RANK_FT_FACTOR, and re-insert into the queue. Although a 1.3x factor likely won't make a huge difference. The idea here being that if other candidates are closely ranked we try those via FT before falling back to reassociation.Right.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Another option is to introduce some cutoff RSSI or rank value that determines if we retry with reassociation or move on to the next BSS with FT.
I doubt any absolute RSSI or rank cutoff will work. These are very hardware dependent. Better to refine the ranking calculation, but in the end the information we base the rank off of is imperfect, so sub-optimal decisions are going to be a fact of life.
Quoted 2 lines
At the very least (mostly applicable to 1 roam candidate) we should keep track that all FT attempts failed and try reassociation on the next round.
Or better yet, have the vendor fix the network.
Agreed... but easier said than done. This is just one of several issues we're trying to work around on the client side that we shouldn't have to :(
Quoted 3 lines
Regards,
-Denis
Re: [PATCH 2/3] station: fall back to reassociation under certain FT failures
Hi James,
Quoted 3 lines
Quoted 1 line
Another possibility would be to insert the BSS twice (or reinsert once FT fails), once with FT and once without FT and try them in rank order. Still, there's almost no penalty to trying all FT candidates, so unless the ranking calculation is really off, I think that is a better approach.
Ok, I'd rather go this route then, re-insert the BSS without FT after this specific failure.
Ok, lets do that then.
Quoted 3 lines
Would you want me to put this behind a config option? Or you think reassociation based on ranking is ok? Again, it would only be with status=53 so I think the impact is minimal.
Make it the default behavior.
Regards,
-Denis
PATCH 3/3 auto-t: add fallback to reassociate test
In reply to James PrestwoodTests that IWD falls back to reassociation if FT fails with status 53.
--- autotests/testPSK-roam/failed_roam_test.py | 70 +++++++++++++++++++++- autotests/testPSK-roam/ft-psk-ccmp-1.conf | 1 + autotests/testPSK-roam/ft-psk-ccmp-2.conf | 1 + autotests/testPSK-roam/ft-psk-ccmp-3.conf | 1 + 4 files changed, 70 insertions(+), 3 deletions(-)
autotests/testPSK-roam/failed_roam_test.py +67 -3
@@ -41,18 +41,22 @@ class Test(unittest.TestCase): self.assertRaises(Exception, testutil.test_ifaces_connected, (prev.ifname, device.name, True, True)) - # FT-over-Air failure, should stay connected def test_ft_over_air_failure(self): + self.rule2.enabled = True + self.rule3.enabled = True + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK') self.bss_hostapd[0].set_value('ft_over_ds', '0') self.bss_hostapd[0].reload() self.bss_hostapd[0].wait_for_event("AP-ENABLED") + self.bss_hostapd[0].set_value('ft_psk_generate_local', '1') self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK') self.bss_hostapd[1].set_value('ft_over_ds', '0') self.bss_hostapd[1].reload() self.bss_hostapd[1].wait_for_event("AP-ENABLED") + self.bss_hostapd[1].set_value('ft_psk_generate_local', '1') wd = IWD(True)
@@ -70,9 +74,60 @@ class Test(unittest.TestCase): self.rule0.enabled = False # IWD should then try BSS 2, and succeed + device.wait_for_event('ft-roam', timeout=60) self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[2]) self.bss_hostapd[2].deauthenticate(device.address) + + # FT-over-Air failure, should stay connected + def test_ft_over_air_fallback(self): + self.rule_bss0.signal = -8000 + self.rule_bss0.enabled = True + self.rule_bss1.signal = -7500 + self.rule_bss1.enabled = True + self.rule_bss2.signal = -6000 + self.rule_bss2.enabled = True + + self.bss_hostapd[0].set_value('wpa_key_mgmt', 'FT-PSK') + self.bss_hostapd[0].set_value('ft_over_ds', '0') + self.bss_hostapd[0].reload() + self.bss_hostapd[0].wait_for_event("AP-ENABLED") + self.bss_hostapd[0].set_value('ft_psk_generate_local', '1') + + self.bss_hostapd[1].set_value('wpa_key_mgmt', 'FT-PSK') + self.bss_hostapd[1].set_value('ft_over_ds', '0') + self.bss_hostapd[1].reload() + self.bss_hostapd[1].wait_for_event("AP-ENABLED") + self.bss_hostapd[1].set_value('ft_psk_generate_local', '1') + + # This will cause this BSS to reject any FT roams as its unable to + # get keys from other APs + self.bss_hostapd[2].set_value('ft_psk_generate_local', '0') + self.bss_hostapd[2].reload() + + wd = IWD(True) + + device = wd.list_devices(1)[0] + + self.connect(wd, device, self.bss_hostapd[0]) + + # IWD should connect, then attempt a roam to BSS 1, which should + # fail and cause a fallback to reassociation + device.wait_for_event('ft-fallback-to-reassoc', timeout=60) + + self.assertTrue(device.state == DeviceState.connected) + + self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[2]) + + # Trigger another roam + self.rule_bss2.signal = -8000 + + device.wait_for_event('ft-roam', timeout=60) + + # Ensure an FT roam back to a properly configured AP works. + self.verify_roam(wd, device, self.bss_hostapd[2], self.bss_hostapd[1]) + + self.bss_hostapd[1].deauthenticate(device.address) condition = 'obj.state == DeviceState.disconnected' wd.wait_for_object_condition(device, condition)
@@ -85,6 +140,10 @@ class Test(unittest.TestCase): self.rule0.enabled = False self.rule1.enabled = False self.rule2.enabled = False + self.rule3.enabled = False + self.rule_bss0.enabled = False + self.rule_bss1.enabled = False + self.rule_bss2.enabled = False @classmethod def setUpClass(cls):
@@ -116,13 +175,18 @@ class Test(unittest.TestCase): cls.rule2 = hwsim.rules.create() cls.rule2.source = hwsim.get_radio('rad0').addresses[0] cls.rule2.signal = -8000 - cls.rule2.enabled = True # Causes IWD to first prefer BSS 1 to roam, then BSS 2. cls.rule3 = hwsim.rules.create() cls.rule3.source = hwsim.get_radio('rad2').addresses[0] cls.rule3.signal = -7000 - cls.rule3.enabled = True + + cls.rule_bss0 = hwsim.rules.create() + cls.rule_bss0.source = hwsim.get_radio('rad0').addresses[0] + cls.rule_bss1 = hwsim.rules.create() + cls.rule_bss1.source = hwsim.get_radio('rad1').addresses[0] + cls.rule_bss2 = hwsim.rules.create() + cls.rule_bss2.source = hwsim.get_radio('rad2').addresses[0] @classmethod def tearDownClass(cls):
autotests/testPSK-roam/ft-psk-ccmp-1.conf +1 -0
@@ -33,6 +33,7 @@ pmk_r1_push=0 # case. Only works with FT-PSK, otherwise brctl needs to be installed and # CONFIG_BRIDGE enabled in the kernel. ft_psk_generate_local=1 +rkh_pull_timeout=50 ft_over_ds=0 ap_table_expiration_time=36000 ap_table_max_size=10
autotests/testPSK-roam/ft-psk-ccmp-2.conf +1 -0
@@ -33,6 +33,7 @@ pmk_r1_push=0 # case. Only works with FT-PSK, otherwise brctl needs to be installed and # CONFIG_BRIDGE enabled in the kernel. ft_psk_generate_local=1 +rkh_pull_timeout=50 ft_over_ds=0 ap_table_expiration_time=36000 ap_table_max_size=10
autotests/testPSK-roam/ft-psk-ccmp-3.conf +1 -0
@@ -33,6 +33,7 @@ pmk_r1_push=0 # case. Only works with FT-PSK, otherwise brctl needs to be installed and # CONFIG_BRIDGE enabled in the kernel. ft_psk_generate_local=1 +rkh_pull_timeout=50 ft_over_ds=0 ap_table_expiration_time=36000 ap_table_max_size=10
Signature · 1 line
2.25.1