]> git.ipfire.org Git - thirdparty/hostap.git/commit
hostapd: Maintain single wpa_driver_nl80211_data (drv) object across interfaces
authorAditya Kumar Singh <quic_adisi@quicinc.com>
Wed, 13 Nov 2024 07:26:19 +0000 (12:56 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 10 Dec 2024 09:39:14 +0000 (11:39 +0200)
commit00c2c20d74ee94c149fb0b82feb416e642818f57
tree416b2c15fb996277a0328abd5455a19c3e5f23ba
parent54eeaa0757e638cfa3ee92a5226559f8a00dc82b
hostapd: Maintain single wpa_driver_nl80211_data (drv) object across interfaces

Currently, the first BSS of each hostapd interface (struct hostapd_iface)
creates a new driver data object (struct wpa_driver_nl80211_data, referred
to as drv). When a non-first BSS of an interface initializes, it copies the
drv_priv and thus uses the first BSS’s drv object. This can lead to
situations where multiple drv objects are maintained for the same
underlying hardware in hostapd.

Some of such situations are:

1. Two different configs for two different wlanX interface but on the
   same underlying radio. In this case, two drv objects will be
   maintained.

2. MLO case - 5 GHz config having two BSS. 6 GHz config having one BSS.
   5 GHz's second BSS is partnering with 6 GHz's BSS and forming MLD.
   And 6 GHz config is enabled first and then 5 GHz. In this case, two
   different driver instance will be maintained - one having 5 GHz BSS
   and other having 5 GHz + 6 GHz MLO BSS. To visualize this:

Assumption: Only 1 phy (say phy0 exist on system). On this phy, the driver
            has grouped both 5 GHz and 6 GHz underlying radio as a single
            radio.
Config:
     +--------------------+     +------------------+
     |     5 GHz config   |     |   6 GHz config   |
     |                    |     |                  |
     |                    |     |                  |
     | +----------------+ |     |                  |
     | |     BSS 1      | |     |                  |
     | | ssid: guest_ap | |     |                  |
     | +----------------+ |     |                  |
     |                    |     |                  |
   +------------------------------------------------------------------+
   | | +----------------+ |     | +--------------+ |                  |
   | | |     BSS 2      | |     | |     BSS 1    | |                  |
   | | | ssid: mlo_ap   | |     | | ssid: mlo_ap | |   2 Link MLO AP  |
   | | +----------------+ |     | +--------------+ |                  |
   | +--------------------+     +------------------+                  |
   +------------------------------------------------------------------+

Expectation:
+-----------------------------------+
|   wpa_driver_nl80211_data (drv)   |
|          (for the phy0)           |
|                                   |
|        +----------------+         |        +----------------+
|        |    first_bss   -------------------|   second_bss   |
|        |                |         |        |                |
|        | ssid: guest_ap |         |        | ssid: mlo_ap   |
|        +----------------+         |        +----------------+
+-----------------------------------+

Current situation (without this change):
+-----------------------------+   +-----------------------------+
|wpa_driver_nl80211_data (drv)|   |wpa_driver_nl80211_data (drv)|
|       (for the phy0)        |   |       (again for the phy0)  |
|                             |   |                             |
|     +----------------+      |   |     +----------------+      |
|     |    first_bss   |      |   |     |    first_bss   |      |
|     |                |      |   |     |                |      |
|     | ssid: guest_ap |      |   |     | ssid: mlo_ap   |      |
|     +----------------+      |   |     +----------------+      |
+-----------------------------+   +-----------------------------+

With this change, it will behave as per the expectation.

3. Three different underlying hardwares - 2.4 GHz, 5 GHz, 6 GHz, capable
   of three different bands and they are grouped together and advertised
   as single hardware supporting all bands to upper layer. In this case,
   if one interface (wlanX) is enabled in each hardware (three
   independent configs) three different drv will be maintained.

Because of this, at times during de-initialization, proper
deinitialization will not happen and WPA_TRACE could be seen:

nl80211: 1 interface(s) remain at nl80211_global_deinit
ELOOP: remaining socket: sock=12 eloop_data=0x5500292620 user_data=(nil) handler=0x55000f6cb0
WPA_TRACE: eloop unregistered socket handler: 0x55000f6cb0
     rfkill_receive() ../src/drivers/rfkill.c:56
WPA_TRACE: eloop sock - START
[0]: ../../hostapd/hostapd(+0x82fe1) [0x5500082fe1]
     eloop_sock_table_add_sock() ../src/utils/eloop.c:367
[1]: ../../hostapd/hostapd(rfkill_init+0x1ea) [0x55000f700a]
     rfkill_init() ../src/drivers/rfkill.c:200
[2]: ../../hostapd/hostapd(+0xe5325) [0x55000e5325]
     wpa_driver_nl80211_drv_init_rfkill() ../src/drivers/driver_nl80211.c:2276
     wpa_driver_nl80211_finish_drv_init() ../src/drivers/driver_nl80211.c:3036
[3]: ../../hostapd/hostapd(+0xe89f1) [0x55000e89f1]
     wpa_driver_nl80211_drv_init() ../src/drivers/driver_nl80211.c:2350
[4]: ../../hostapd/hostapd(+0xe8c6e) [0x55000e8c6e]
     i802_init() ../src/drivers/driver_nl80211.c:8714
[5]: ../../hostapd/hostapd(+0x32605) [0x5500032605]
     hostapd_driver_init() main.c:257
[6]: ../../hostapd/hostapd(main+0xd08) [0x5500031ad8]
     main() main.c:1021
[7]: /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x409acd90]
WPA_TRACE: eloop sock - EN

Also, for situation #3, during handling of incoming NL commands, the
above is causing issue in routing the events. This is because since all
underlying hardwares are part of same phy, phy index is same in all the
drv objects. Hence when the event comes, it will be given to the first
drv which might not be having the intended BSS. For example, 5 GHz DFS
events (which does not have if_idx). The event can be passed to driver
having 2.4 GHz's BSS or 6 GHz's depending upon which was enabled first.

Hence to avoid these situations, try to maintain single drv object as
much as possible.

Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
hostapd/main.c
src/ap/hostapd.c
src/drivers/driver.h
src/drivers/driver_nl80211.c
src/drivers/driver_nl80211.h
src/drivers/driver_nl80211_capa.c