From patchwork Thu Apr 18 21:41:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 237748 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1585F2C0207 for ; Fri, 19 Apr 2013 07:42:13 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4D3899C2E5; Thu, 18 Apr 2013 17:42:10 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2O-62cL6Ntw5; Thu, 18 Apr 2013 17:42:10 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4C4A99C137; Thu, 18 Apr 2013 17:42:06 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id BC0A79C134 for ; Thu, 18 Apr 2013 17:42:05 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16BR+fskoONV for ; Thu, 18 Apr 2013 17:42:02 -0400 (EDT) Received: from sipsolutions.net (he.sipsolutions.net [78.46.109.217]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 155E79C251 for ; Thu, 18 Apr 2013 17:42:01 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1USwac-00033r-SO; Thu, 18 Apr 2013 23:41:59 +0200 Message-ID: <1366321315.8336.9.camel@jlt4.sipsolutions.net> Subject: Re: [PATCH] p2p_supplicant: probe reporting should be from listen interface From: Johannes Berg To: Arend van Spriel Date: Thu, 18 Apr 2013 23:41:55 +0200 In-Reply-To: <1364481543-2636-1-git-send-email-arend@broadcom.com> References: <1364481543-2636-1-git-send-email-arend@broadcom.com> X-Mailer: Evolution 3.6.3-1 Mime-Version: 1.0 Cc: Greg Goldman , hostap@lists.shmoo.com X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com On Thu, 2013-03-28 at 15:39 +0100, Arend van Spriel wrote: > P2P listen phase is used to listen for P2P probe request messages > from peers. The probe reporting call should be done on the same > interface as the remain_on_channel. Conceptually, I agree with this patch. > This patch fixes it for my driver and it kind of makes sense to me that > the probe request reporting should be done on the same interface as the > on doing the LISTEN. Implementation wise, I'm surprised this even worked for you. It definitely seems to break P2P operation with hwsim with David's patches. I think we need to do something like this (on top of your patch) johannes diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index b74cf0b..e1d8e48 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -9808,7 +9808,7 @@ static void nl80211_deinit_p2p_dev(void *priv) { struct i802_bss *p2p_dev = priv; struct wpa_driver_nl80211_data *drv = p2p_dev->drv; - struct i802_bss *last; + struct i802_bss *tbss; if (p2p_dev->wdev_id == -1) return; @@ -9821,11 +9821,19 @@ static void nl80211_deinit_p2p_dev(void *priv) NL80211_CMD_DEL_INTERFACE, p2p_dev->wdev_id); - for (last = &drv->first_bss; last->next && last->next != p2p_dev; - last = last->next) - ; - if (last->next && last->next == p2p_dev) - last->next = p2p_dev->next; + for (tbss = &drv->first_bss; tbss; tbss = tbss->next) { + if (tbss->next == p2p_dev) { + tbss->next = p2p_dev->next; + break; + } + } + + if (p2p_dev->nl_mgmt) { + eloop_unregister_read_sock(nl_socket_get_fd(p2p_dev->nl_mgmt)); + nl_destroy_handles(&p2p_dev->nl_mgmt); + } + + nl80211_destroy_bss(p2p_dev); os_free(p2p_dev); } @@ -9833,15 +9841,16 @@ static void nl80211_deinit_p2p_dev(void *priv) static void *nl80211_init_p2p_dev(void *priv, const char *ifname, u8 *addr) { struct i802_bss *bss = priv; - struct i802_bss *last; struct wpa_driver_nl80211_data *drv = bss->drv; int ret; int type; struct i802_bss *p2p_dev = os_zalloc(sizeof(struct i802_bss)); + if (!p2p_dev) return NULL; - *p2p_dev = *bss; + p2p_dev->drv = drv; + p2p_dev->ctx = drv->ctx; os_strncpy(p2p_dev->ifname, ifname, IFNAMSIZ); p2p_dev->ifindex = nl80211_create_iface(drv, ifname, @@ -9857,6 +9866,17 @@ static void *nl80211_init_p2p_dev(void *priv, const char *ifname, u8 *addr) return NULL; } + ret = nl80211_init_bss(p2p_dev); + if (ret) { + nl80211_deinit_p2p_dev(p2p_dev); + return NULL; + } + + if (nl80211_alloc_mgmt_handle(p2p_dev)) { + nl80211_deinit_p2p_dev(p2p_dev); + return NULL; + } + ret = nl80211_p2p_device_exec_cmd(drv, ifname, NL80211_CMD_START_P2P_DEVICE, p2p_dev->wdev_id); @@ -9868,18 +9888,17 @@ static void *nl80211_init_p2p_dev(void *priv, const char *ifname, u8 *addr) return NULL; } - for (last = bss; last->next; last = last->next) - ; - last->next = p2p_dev; - os_memcpy(addr, p2p_dev->addr, ETH_ALEN); + p2p_dev->next = drv->first_bss.next; + drv->first_bss.next = p2p_dev; + /* Register P2P Public Action frame on the device interface */ type = (WLAN_FC_TYPE_MGMT << 2) | (WLAN_FC_STYPE_ACTION << 4); - nl80211_register_frame(p2p_dev, bss->nl_mgmt, type, + nl80211_register_frame(p2p_dev, p2p_dev->nl_mgmt, type, (u8 *) "\x04\x09\x50\x6f\x9a\x09", 6); /* Register P2P Action frame on the device interface */ - nl80211_register_frame(p2p_dev, bss->nl_mgmt, type, + nl80211_register_frame(p2p_dev, p2p_dev->nl_mgmt, type, (u8 *) "\x7f\x50\x6f\x9a\x09", 5); return p2p_dev; This works in hwsim now, with a mac80211 patch: diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 5b4492a..3290ce6 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2681,6 +2681,9 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) stype = mgmt->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); + if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) + return RX_CONTINUE; + if (!ieee80211_vif_is_mesh(&sdata->vif) && sdata->vif.type != NL80211_IFTYPE_ADHOC && sdata->vif.type != NL80211_IFTYPE_STATION) @@ -3030,7 +3033,8 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx, !ieee80211_is_probe_resp(hdr->frame_control) && !ieee80211_is_beacon(hdr->frame_control)) return 0; - if (!ether_addr_equal(sdata->vif.addr, hdr->addr1)) + if (!ether_addr_equal(sdata->vif.addr, hdr->addr1) && + !multicast) status->rx_flags &= ~IEEE80211_RX_RA_MATCH; break; default: