]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Update own report in nr_db if SSID is changed
authorNikita Chernikov <ncherikov@maxlinear.com>
Thu, 1 Feb 2024 16:05:02 +0000 (18:05 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Mar 2024 19:33:46 +0000 (21:33 +0200)
short_ssid in the own neighbor report might get out of sync, causing
advertising RNR element based on the old SSID, when SSID is changed
either with control interface command SET or with SIGHUP. Therefore,
sync the own report entry by removing the old entry and setting own
report again if the short SSID value has changed.

Signed-off-by: Nikita Chernikov <nchernikov@maxlinear.com>
hostapd/ctrl_iface.c
src/ap/hostapd.c
src/ap/neighbor_db.c
src/ap/neighbor_db.h

index 23ede0c5a7bd2f151b2d163b8cf9834bebce256b..8a12fee886db040fc526743ca20b6ec661c9845e 100644 (file)
@@ -1309,6 +1309,8 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
                        hostapd_disassoc_deny_mac(hapd);
                } else if (os_strcasecmp(cmd, "accept_mac_file") == 0) {
                        hostapd_disassoc_accept_mac(hapd);
+               } else if (os_strcasecmp(cmd, "ssid") == 0) {
+                       hostapd_neighbor_sync_own_report(hapd);
                } else if (os_strncmp(cmd, "wme_ac_", 7) == 0 ||
                           os_strncmp(cmd, "wmm_ac_", 7) == 0) {
                        hapd->parameter_set_count++;
index ddbcabc49328e57dac55d0d65c2b4d37829bf339..0def1b918a015c26f9db0cfcc6c098f959cc1d26 100644 (file)
@@ -184,6 +184,8 @@ static void hostapd_reload_bss(struct hostapd_data *hapd)
                hostapd_set_generic_elem(hapd, (u8 *) "", 0);
        }
 
+       hostapd_neighbor_sync_own_report(hapd);
+
        ieee802_11_set_beacon(hapd);
        hostapd_update_wps(hapd);
 
index 2a25ae20ee061f5e547fc6f5d1691a965476926e..2eefef0225a886d64acaac0bd346644b3559f0cf 100644 (file)
@@ -325,3 +325,37 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd)
        wpabuf_free(nr);
 #endif /* NEED_AP_MLME */
 }
+
+
+static struct hostapd_neighbor_entry *
+hostapd_neighbor_get_diff_short_ssid(struct hostapd_data *hapd, const u8 *bssid)
+{
+       struct hostapd_neighbor_entry *nr;
+
+       dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
+                        list) {
+               if (ether_addr_equal(bssid, nr->bssid) &&
+                   nr->short_ssid != hapd->conf->ssid.short_ssid)
+                       return nr;
+       }
+       return NULL;
+}
+
+
+int hostapd_neighbor_sync_own_report(struct hostapd_data *hapd)
+{
+       struct hostapd_neighbor_entry *nr;
+
+       nr = hostapd_neighbor_get_diff_short_ssid(hapd, hapd->own_addr);
+       if (!nr)
+               return -1;
+
+       /* Clear old entry due to SSID change */
+       hostapd_neighbor_clear_entry(nr);
+       dl_list_del(&nr->list);
+       os_free(nr);
+
+       hostapd_neighbor_set_own_report(hapd);
+
+       return 0;
+}
index 992671b62608a8306f3ca4eef9362480313533ec..53f71420322b37f03d16104bcc1033566fbea011 100644 (file)
@@ -20,6 +20,7 @@ int hostapd_neighbor_set(struct hostapd_data *hapd, const u8 *bssid,
                         const struct wpabuf *civic, int stationary,
                         u8 bss_parameters);
 void hostapd_neighbor_set_own_report(struct hostapd_data *hapd);
+int hostapd_neighbor_sync_own_report(struct hostapd_data *hapd);
 int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid,
                            const struct wpa_ssid_value *ssid);
 void hostapd_free_neighbor_db(struct hostapd_data *hapd);