diff --git a/src/cntlr_map.c b/src/cntlr_map.c index a002943e2d1eb10c74d10e9c1824875f1b3c1bd9..fbda5b0b5a53fb2e6b62c9358f0a494635ad8454 100644 --- a/src/cntlr_map.c +++ b/src/cntlr_map.c @@ -1954,29 +1954,39 @@ int handle_sta_steer_btm_report(void *cntlr, struct cmdu_buff *cmdu) attempt = sta_lookup_steer_attempt(s, resp->bssid, resp->status ? NULL : resp->target_bssid[0]); - if (!attempt) + if (!attempt) { warn("|%s:%d| could not find an attempt matching this btm report\n", __func__, __LINE__); - else { - s->pending_btm_resp_num--; - attempt->answered = true; + return 0; } + attempt->answered = true; + if (resp->status != 0x00) { /* error code */ - s->failed_steer_attempts++; - /* Update Steering Summary Stats */ - s->stats.btm_failure_cnt++; + if (s->pending_btm_resp_num > 0) { + /* This is an expected btm response before btm timer + * expired. Hence update Steering Stats already. + */ + s->failed_steer_attempts++; + s->stats.btm_failure_cnt++; + } + /* else: counters already updated in cntlr_btm_req_timer_cb */ - if (attempt) - /* 'A failed steering attempt will leave this parameter 0' */ - attempt->duration = 0; - } else { + /* 'A failed steering attempt will leave this parameter 0' */ + attempt->duration = 0; + } else { /* success */ s->failed_steer_attempts = 0; /* Update Steering Summary Stats */ s->stats.btm_success_cnt++; - if (attempt) - attempt->duration = timestamp_elapsed_sec(&attempt->time); + if (s->pending_btm_resp_num == 0) + /* Received succesful btm report, after the btm timeout, + * meaning that failure counter have been increased + * in cntlr_btm__req_timer_cb and must be decreased. + */ + s->stats.btm_failure_cnt--; + + attempt->duration = timestamp_elapsed_sec(&attempt->time); } /* Number of asynchronous BTM Queries for which a BTM @@ -1984,6 +1994,10 @@ int handle_sta_steer_btm_report(void *cntlr, struct cmdu_buff *cmdu) */ s->stats.btm_query_resp_cnt++; + /* Decrease expected (pending) responses count */ + if (s->pending_btm_resp_num > 0) + s->pending_btm_resp_num--; + return ret; }