[PATCH 20/20] wpa_s: fix l2_packet_init() call for P2P group interface

Arend van Spriel arend
Thu May 16 06:28:35 PDT 2013


The commit below skipped l2_packet_init() when driver flagged
P2P Device support.

commit 37fb3815801657c659c0237a440cf34db67e450b
Author: Arend van Spriel <arend at broadcom.com>
Date:   Thu May 9 16:30:50 2013 +0200

    wpa_s: fix wpa_supplicant_init_iface() for P2P Device interface

Instead l2_packet_init() should only be skipped for the
P2P Device interface.

Signed-hostap: Arend van Spriel <arend at broadcom.com>
---
 wpa_supplicant/events.c           |    4 ++--
 wpa_supplicant/wpa_supplicant.c   |   22 +++++++++++-----------
 wpa_supplicant/wpa_supplicant_i.h |    4 ++--
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 463c8e6..6728fd3 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2168,7 +2168,7 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
 			break;
 		wpa_s->interface_removed = 0;
 		wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added");
-		if (wpa_supplicant_driver_init(wpa_s) < 0) {
+		if (wpa_supplicant_driver_init(wpa_s, 1) < 0) {
 			wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the "
 				"driver after interface was added");
 		}
@@ -2909,7 +2909,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
 	case EVENT_INTERFACE_ENABLED:
 		wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled");
 		if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
-			wpa_supplicant_update_mac_addr(wpa_s);
+			wpa_supplicant_update_mac_addr(wpa_s, 1);
 #ifdef CONFIG_AP
 			if (!wpa_s->ap_iface) {
 				wpa_supplicant_set_state(wpa_s,
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 0f70fff..170d613 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2316,15 +2316,14 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
 }
 
 
-int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s)
+int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s, int l2_needed)
 {
 	if (wpa_s->driver->send_eapol) {
 		const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
 		if (addr)
 			os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
-	} else if (!(wpa_s->drv_flags &
-		     (WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE |
-		      WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE))) {
+	} else if (l2_needed && !(wpa_s->drv_flags &
+				  WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE)) {
 		l2_packet_deinit(wpa_s->l2);
 		wpa_s->l2 = l2_packet_init(wpa_s->ifname,
 					   wpa_drv_get_mac_addr(wpa_s),
@@ -2343,10 +2342,6 @@ int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s)
 		return -1;
 	}
 
-	wpa_dbg(wpa_s, MSG_DEBUG, "Own MAC address: " MACSTR,
-		MAC2STR(wpa_s->own_addr));
-	wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
-
 	return 0;
 }
 
@@ -2379,19 +2374,24 @@ static void wpa_supplicant_rx_eapol_bridge(void *ctx, const u8 *src_addr,
 /**
  * wpa_supplicant_driver_init - Initialize driver interface parameters
  * @wpa_s: Pointer to wpa_supplicant data
+ * @l2_needed: need call l2_packet_init() for this interface
  * Returns: 0 on success, -1 on failure
  *
  * This function is called to initialize driver interface parameters.
  * wpa_drv_init() must have been called before this function to initialize the
  * driver interface.
  */
-int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
+int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s, int l2_needed)
 {
 	static int interface_count = 0;
 
-	if (wpa_supplicant_update_mac_addr(wpa_s) < 0)
+	if (wpa_supplicant_update_mac_addr(wpa_s, l2_needed) < 0)
 		return -1;
 
+	wpa_dbg(wpa_s, MSG_DEBUG, "Own MAC address: " MACSTR,
+		MAC2STR(wpa_s->own_addr));
+	wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
+
 	if (wpa_s->bridge_ifname[0]) {
 		wpa_dbg(wpa_s, MSG_DEBUG, "Receiving packets from bridge "
 			"interface '%s'", wpa_s->bridge_ifname);
@@ -2955,7 +2955,7 @@ next_driver:
 	if (wpa_s->max_remain_on_chan == 0)
 		wpa_s->max_remain_on_chan = 1000;
 
-	if (wpa_supplicant_driver_init(wpa_s) < 0)
+	if (wpa_supplicant_driver_init(wpa_s, !iface->p2p_mgmt) < 0)
 		return -1;
 
 #ifdef CONFIG_TDLS
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 02e4bc6..eac9b8f 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -715,8 +715,8 @@ int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
 
 const char * wpa_supplicant_state_txt(enum wpa_states state);
-int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s);
-int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
+int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s, int l2_needed);
+int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s, int l2_needed);
 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
 			      struct wpa_bss *bss, struct wpa_ssid *ssid,
 			      u8 *wpa_ie, size_t *wpa_ie_len);
-- 
1.7.10.4





More information about the Hostap mailing list