p2p: support random interface address
To enhance privacy, generate a ramdom interface for each group.
This need additional qcom driver fix because MAC changing function of
P2P_GO won't work properly.
There are two configurations are introduced:
* p2p_interface_random_mac_addr
enable interface random MAC address feature, default disable.
Bug: 118904478
Test: manual test
* enable WiFi Direct in Settings.
* establish fresh connection between two peers.
* establish reinvoke connection between two peers.
* check interface addresses are random generated.
Test: CtsVerifier - WiFi Direct
* Two random device address enabled device.
* One random device address enabled device and
One random device address disabled device.
Change-Id: I519629eb8520a15e6f2d158cf3b9a4058f66e124
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 346326f..3d3296f 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2075,6 +2075,17 @@
return -1;
}
+ if (wpa_s->conf->p2p_interface_random_mac_addr) {
+ if (random_mac_addr(wpa_s->pending_interface_addr) < 0) {
+ wpa_printf(MSG_ERROR, "P2P: Failed to generate random MAC address "
+ "for the group interface");
+ return -1;
+ }
+ wpa_printf(MSG_DEBUG, "P2P: Generate random MAC address " MACSTR " for the group",
+ MAC2STR(wpa_s->pending_interface_addr));
+ }
+
+
if (force_ifname[0]) {
wpa_printf(MSG_DEBUG, "P2P: Driver forced interface name %s",
force_ifname);
@@ -2153,6 +2164,25 @@
wpas_p2p_clone_config(group_wpa_s, wpa_s);
+ if (wpa_s->conf->p2p_interface_random_mac_addr) {
+ if (wpa_drv_set_mac_addr(group_wpa_s, wpa_s->pending_interface_addr) < 0) {
+ wpa_msg(group_wpa_s, MSG_INFO,
+ "Failed to set random MAC address");
+ wpa_supplicant_remove_iface(wpa_s->global, group_wpa_s, 0);
+ return NULL;
+ }
+
+ if (wpa_supplicant_update_mac_addr(group_wpa_s) < 0) {
+ wpa_msg(group_wpa_s, MSG_INFO,
+ "Could not update MAC address information");
+ wpa_supplicant_remove_iface(wpa_s->global, group_wpa_s, 0);
+ return NULL;
+ }
+
+ wpa_printf(MSG_DEBUG, "P2P: Using random MAC address " MACSTR " for the group",
+ MAC2STR(wpa_s->pending_interface_addr));
+ }
+
return group_wpa_s;
}