From 4bd1efe07354db6f3f588281219320dc671cde9d Mon Sep 17 00:00:00 2001 From: Jintao Lin Date: Tue, 6 Dec 2022 17:41:58 +0000 Subject: [PATCH] dbus: Do not bring down primary interface when removing created AP interface If the CreateInterface command was used to create a virtual AP interface, deleting this interface using the RemoveInterface command was also bringing down the primary interface. wpa_supplicant never uses hostapd style multi-BSS setup with type=WPA_IF_AP_BSS and setup_ap=1 to if_add() when creating an AP interface in wpa_driver_nl80211_if_add(), so it should not go through the multi-BSS tear down procedure in wpa_driver_nl80211_if_remove(). The virtual AP resources init and deinit are well handled in wpa_driver_nl80211_init() and wpa_driver_nl80211_deinit(). Collapse the interface type to WPA_IF_STATION for the D-Bus interface to skip the multi-BSS cleanup procedure. This is inline with the control interface design. Add comments before the code to avoid confusion. Signed-off-by: Jintao Lin --- wpa_supplicant/ctrl_iface.c | 7 ++++++- wpa_supplicant/dbus/dbus_new_handlers.c | 16 ++++++++++------ wpa_supplicant/wpa_supplicant_i.h | 1 - 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index d34d4a777..e0b6e11bb 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -13070,8 +13070,11 @@ static int wpa_supplicant_global_iface_add(struct wpa_global *global, return 0; fail: - if (create_iface) + if (create_iface) { + /* wpa_supplicant does not create multi-BSS AP, so collapse to + * WPA_IF_STATION to avoid unwanted clean up in the driver. */ wpa_drv_if_remove(global->ifaces, WPA_IF_STATION, iface.ifname); + } return -1; } @@ -13093,6 +13096,8 @@ static int wpa_supplicant_global_iface_remove(struct wpa_global *global, if (!ret && delete_iface) { wpa_printf(MSG_DEBUG, "CTRL_IFACE deleting the interface '%s'", cmd); + /* wpa_supplicant does not create multi-BSS AP, so collapse to + * WPA_IF_STATION to avoid unwanted clean up in the driver. */ ret = wpa_drv_if_remove(global->ifaces, WPA_IF_STATION, cmd); } return ret; diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 83f46a9eb..67ce970d0 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -888,8 +888,6 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message, const char *path = wpa_s->dbus_new_path; wpa_s->added_vif = create_iface; - wpa_s->added_vif_type = create_iface ? if_type : - WPA_IF_MAX; reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); @@ -897,9 +895,13 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message, reply = wpas_dbus_error_unknown_error( message, "wpa_supplicant couldn't grab this interface."); - if (create_iface) - wpa_drv_if_remove(global->ifaces, if_type, - ifname); + if (create_iface) { + /* wpa_supplicant does not create multi-BSS AP, + * so collapse to WPA_IF_STATION to avoid + * unwanted clean up in the driver. */ + wpa_drv_if_remove(global->ifaces, + WPA_IF_STATION, ifname); + } } } @@ -958,7 +960,9 @@ DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message, if (delete_iface) { wpa_printf(MSG_DEBUG, "%s[dbus]: deleting the interface '%s'", __func__, wpa_s->ifname); - if (wpa_drv_if_remove(global->ifaces, wpa_s->added_vif_type, + /* wpa_supplicant does not create multi-BSS AP, so collapse to + * WPA_IF_STATION to avoid unwanted clean up in the driver. */ + if (wpa_drv_if_remove(global->ifaces, WPA_IF_STATION, wpa_s->ifname)) { reply = wpas_dbus_error_unknown_error( message, diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 0c044129c..dfe6ffd93 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -926,7 +926,6 @@ struct wpa_supplicant { unsigned int connection_he:1; unsigned int connection_eht:1; unsigned int disable_mbo_oce:1; - enum wpa_driver_if_type added_vif_type; struct os_reltime last_mac_addr_change; int last_mac_addr_style;