The NAN Management Interface (NMI) address in the NAN Discovery Engine
(nan_de) was only set during initialization. This address would become
stale if the interface's MAC address changed later, for example, due to
MAC address randomization.
When `wpa_supplicant_update_mac_addr()` updated `wpa_s->own_addr`, the
corresponding `wpa_s->nan_de->nmi` field was not updated. This could
lead to failures in Wi-Fi Aware USD operations as they would be using
an incorrect source MAC address.
This commit fixes this by:
1. Introducing a new function, `nan_de_update_nmi()`, to allow the NMI
to be updated after initialization.
2. Calling this new function from `wpa_supplicant_update_mac_addr()` to
ensure the NMI is always synchronized with the interface's current
MAC address.
This ensures the NAN Discovery Engine operates with the correct MAC
address, improving the reliability of Wi-Fi Aware USD functionality.
Test: Manual - USD Transmit message
Subscriber:
> NAN_SUBSCRIBE service_name=_test srv_proto_type=3 ssi=
1122334455
1
<3>NAN-DISCOVERY-RESULT subscribe_id=1 publish_id=1 address=12:a1:99:2a:68:94 fsd=1 fsd_gas=0 srv_proto_type=3 ssi=6677
>
> NAN_TRANSMIT handle=1 req_instance_id=1 address=12:a1:99:2a:68:94 ssi=8899
OK
<3>NAN-RECEIVE id=1 peer_instance_id=1 address=12:a1:99:2a:68:94 ssi=
aabbccdd
Publisher:
> NAN_PUBLISH service_name=_test srv_proto_type=3 ssi=6677
1
<3>NAN-RECEIVE id=1 peer_instance_id=1 address=d6:e1:2e:be:2d:62 ssi=
>
<3>NAN-RECEIVE id=1 peer_instance_id=1 address=d6:e1:2e:be:2d:62 ssi=8899
>
> NAN_TRANSMIT handle=1 req_instance_id=1 address=d6:e1:2e:be:2d:62 ssi=
aabbccdd
OK
Signed-off-by: sunilravi <sunilravi@google.com>
}
+void nan_de_update_nmi(struct nan_de *de, const u8 *nmi)
+{
+ if (de)
+ os_memcpy(de->nmi, nmi, ETH_ALEN);
+}
+
+
void nan_de_tx_status(struct nan_de *de, unsigned int freq, const u8 *dst)
{
if (freq == de->tx_wait_status_freq)
void nan_de_listen_started(struct nan_de *de, unsigned int freq,
unsigned int duration);
void nan_de_listen_ended(struct nan_de *de, unsigned int freq);
+void nan_de_update_nmi(struct nan_de *de, const u8 *nmi);
void nan_de_tx_status(struct nan_de *de, unsigned int freq, const u8 *dst);
void nan_de_tx_wait_ended(struct nan_de *de);
wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
wpas_wps_update_mac_addr(wpa_s);
+#ifdef CONFIG_NAN_USD
+ if (wpa_s->nan_de)
+ nan_de_update_nmi(wpa_s->nan_de, wpa_s->own_addr);
+#endif /* CONFIG_NAN_USD */
+
#ifdef CONFIG_FST
if (wpa_s->fst)
fst_update_mac_addr(wpa_s->fst, wpa_s->own_addr);