]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fix MESH-PEER-DISCONNECTED message logic on control iface
authorNicolas Escande <nico.escande@gmail.com>
Fri, 7 Jul 2023 13:37:18 +0000 (15:37 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 29 Oct 2023 08:43:10 +0000 (10:43 +0200)
When using mesh we have incoherent
MESH-PEER-CONNECTED/MESH-PEER-DISCONNECTED messages when we restart one
of the devices without disconnecting it first. Sometimes we have the
right behavior, a peer disconnect and then a peer connect, sometimes we
only have a a peer connected without a peer disconnected first, and
sometimes we have nothing at all.

As the plink count seem to be correctly tracked and because we only send
the connected event on plink count increase, lets send the peer
disconnected event on plink count decrease.

Signed-off-by: Nicolas Escande <nico.escande@gmail.com>
wpa_supplicant/mesh_mpm.c

index c9e14d5c2d61749f4e25fae807c3d1352a3a640d..643796672a5a4e926fc9945b983a313ce508a305 100644 (file)
@@ -561,8 +561,11 @@ static int mesh_mpm_plink_close(struct hostapd_data *hapd, struct sta_info *sta,
        int reason = WLAN_REASON_MESH_PEERING_CANCELLED;
 
        if (sta) {
-               if (sta->plink_state == PLINK_ESTAB)
+               if (sta->plink_state == PLINK_ESTAB) {
                        hapd->num_plinks--;
+                       wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
+                               MAC2STR(sta->addr));
+               }
                wpa_mesh_set_plink_state(wpa_s, sta, PLINK_HOLDING);
                mesh_mpm_send_plink_action(wpa_s, sta, PLINK_CLOSE, reason);
                wpa_printf(MSG_DEBUG, "MPM closing plink sta=" MACSTR,
@@ -1428,8 +1431,13 @@ void mesh_mpm_action_rx(struct wpa_supplicant *wpa_s,
 /* called by ap_free_sta */
 void mesh_mpm_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
 {
-       if (sta->plink_state == PLINK_ESTAB)
+       struct wpa_supplicant *wpa_s = hapd->iface->owner;
+
+       if (sta->plink_state == PLINK_ESTAB) {
                hapd->num_plinks--;
+               wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
+                       MAC2STR(sta->addr));
+       }
        eloop_cancel_timeout(plink_timer, ELOOP_ALL_CTX, sta);
        eloop_cancel_timeout(mesh_auth_timer, ELOOP_ALL_CTX, sta);
 }