From patchwork Fri Nov 4 10:37:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 123588 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 EAE95B6F8C for ; Fri, 4 Nov 2011 21:40:01 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 46E8A9D2CA; Fri, 4 Nov 2011 06:39:58 -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 CbWbHKAnQnHC; Fri, 4 Nov 2011 06:39:58 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 145489D2E8; Fri, 4 Nov 2011 06:39:22 -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 6CDD59D2E8 for ; Fri, 4 Nov 2011 06:39:21 -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 Qta6kvXkWJJe for ; Fri, 4 Nov 2011 06:39:16 -0400 (EDT) Received: from sipsolutions.net (he.sipsolutions.net [78.46.109.217]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 7BE869D2CA for ; Fri, 4 Nov 2011 06:39:14 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1RMHB3-0001GZ-FQ for hostap@lists.shmoo.com; Fri, 04 Nov 2011 11:39:13 +0100 Message-Id: <20111104103808.827517680@sipsolutions.net> User-Agent: quilt/0.48-1 Date: Fri, 04 Nov 2011 11:37:52 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH 03/18] driver_nl80211: use non-receiving socket for eapol TX References: <20111104103749.617144560@sipsolutions.net> Content-Disposition: inline; filename=0003-driver_nl80211-use-non-receiving-socket-for-eapol-TX.patch Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 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 From: Johannes Berg The non-monitor TX currently uses a normal L2 abstraction socket, but that will also receive frames we don't want, so use a plain socket that isn't bound for RX. This might be possible using the L2 abstraction, but we need a plain socket later for getting TX status events here. Signed-hostap: Johannes Berg --- src/drivers/driver_nl80211.c | 45 +++++++++++++++++++---------------------- 1 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index c125646..51b65ba 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -237,7 +237,7 @@ struct wpa_driver_nl80211_data { struct i802_bss first_bss; #ifdef CONFIG_AP - struct l2_packet_data *l2; + int eapol_tx_sock; #endif /* CONFIG_AP */ #ifdef HOSTAPD @@ -2259,16 +2259,6 @@ static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv) } -#ifdef CONFIG_AP -static void nl80211_l2_read(void *ctx, const u8 *src_addr, const u8 *buf, - size_t len) -{ - wpa_printf(MSG_DEBUG, "nl80211: l2_packet read %u", - (unsigned int) len); -} -#endif /* CONFIG_AP */ - - /** * wpa_driver_nl80211_init - Initialize nl80211 driver interface * @ctx: context to be used when calling wpa_supplicant functions, @@ -2320,8 +2310,7 @@ static void * wpa_driver_nl80211_init(void *ctx, const char *ifname, goto failed; #ifdef CONFIG_AP - drv->l2 = l2_packet_init(ifname, NULL, ETH_P_EAPOL, - nl80211_l2_read, drv, 0); + drv->eapol_tx_sock = socket(PF_PACKET, SOCK_DGRAM, 0); #endif /* CONFIG_AP */ if (drv->global) { @@ -2540,8 +2529,7 @@ static void wpa_driver_nl80211_deinit(void *priv) struct wpa_driver_nl80211_data *drv = bss->drv; #ifdef CONFIG_AP - if (drv->l2) - l2_packet_deinit(drv->l2); + close(drv->eapol_tx_sock); #endif /* CONFIG_AP */ if (drv->nl_preq.handle) @@ -5128,17 +5116,27 @@ nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv) #ifdef CONFIG_AP static int nl80211_send_eapol_data(struct i802_bss *bss, const u8 *addr, const u8 *data, - size_t data_len, const u8 *own_addr) + size_t data_len) { - if (bss->drv->l2 == NULL) { - wpa_printf(MSG_DEBUG, "nl80211: No l2_packet to send EAPOL"); + struct sockaddr_ll ll; + int ret; + + if (bss->drv->eapol_tx_sock < 0) { + wpa_printf(MSG_DEBUG, "nl80211: No socket to send EAPOL"); return -1; } - if (l2_packet_send(bss->drv->l2, addr, ETH_P_EAPOL, data, data_len) < - 0) - return -1; - return 0; + os_memset(&ll, 0, sizeof(ll)); + ll.sll_family = AF_PACKET; + ll.sll_ifindex = bss->ifindex; + ll.sll_protocol = htons(ETH_P_PAE); + ll.sll_halen = ETH_ALEN; + os_memcpy(ll.sll_addr, addr, ETH_ALEN); + ret = sendto(bss->drv->eapol_tx_sock, data, data_len, 0, + (struct sockaddr *) &ll, sizeof(ll)); + if (ret < 0) + wpa_printf(MSG_ERROR, "nl80211 eapol tx: %s", strerror(errno)); + return ret; } #endif /* CONFIG_AP */ @@ -5159,8 +5157,7 @@ static int wpa_driver_nl80211_hapd_send_eapol( #ifdef CONFIG_AP if (drv->device_ap_sme) - return nl80211_send_eapol_data(bss, addr, data, data_len, - own_addr); + return nl80211_send_eapol_data(bss, addr, data, data_len); #endif /* CONFIG_AP */ len = sizeof(*hdr) + (qos ? 2 : 0) + sizeof(rfc1042_header) + 2 +