From f2cba54cb325d11f0350756eb0c2364a85117f72 Mon Sep 17 00:00:00 2001 From: Aditya Kumar Singh Date: Wed, 18 Oct 2023 14:47:26 +0530 Subject: [PATCH 2/4] hostpad: nl80211: remove links while removing or de-initializing the interface Currently, when interface is removed or is de-initialized, the links added are not removed. While removing the interface/or via ifconfig down, kernel removed the stale links. This is wrong since hostapd should remove and do the clean ups properly while going down. Hence add changes to remove links when interface is removed or de-initialized. Signed-off-by: Aditya Kumar Singh --- src/drivers/driver_nl80211.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 2713c716ac42..109ae6f6d21e 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -197,6 +197,8 @@ static int nl80211_put_mesh_config(struct nl_msg *msg, static int i802_sta_disassoc(void *priv, const u8 *own_addr, const u8 *addr, u16 reason); +static int nl80211_remove_link(struct i802_bss *bss, int link_id); +static void nl80211_remove_links(struct i802_bss *bss); /* Converts nl80211_chan_width to a common format */ enum chan_width convert2width(int width) @@ -3090,8 +3092,10 @@ static void wpa_driver_nl80211_deinit(struct i802_bss *bss) nl80211_remove_monitor_interface(drv); - if (is_ap_interface(drv->nlmode)) + if (is_ap_interface(drv->nlmode)) { wpa_driver_nl80211_del_beacon_all(bss); + nl80211_remove_links(bss); + } if (drv->eapol_sock >= 0) { eloop_unregister_read_sock(drv->eapol_sock); @@ -8977,6 +8981,7 @@ static int wpa_driver_nl80211_if_remove(struct i802_bss *bss, tbss->next = bss->next; /* Unsubscribe management frames */ nl80211_teardown_ap(bss); + nl80211_remove_links(bss); nl80211_destroy_bss(bss); if (!bss->added_if) i802_set_iface_flags(bss, 0); @@ -8991,6 +8996,7 @@ static int wpa_driver_nl80211_if_remove(struct i802_bss *bss, } else { wpa_printf(MSG_DEBUG, "nl80211: First BSS - reassign context"); nl80211_teardown_ap(bss); + nl80211_remove_links(bss); nl80211_destroy_bss(bss); if (!bss->added_if) i802_set_iface_flags(bss, 0); -- 2.17.1