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 |
| | +----------------+ | | +--------------+ | |
| +--------------------+ +------------------+ |
+------------------------------------------------------------------+
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:
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.