From patchwork Mon Aug 1 09:32:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 1025152 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p719X91K014403 for ; Mon, 1 Aug 2011 09:33:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753173Ab1HAJdH (ORCPT ); Mon, 1 Aug 2011 05:33:07 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:38914 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092Ab1HAJdF (ORCPT ); Mon, 1 Aug 2011 05:33:05 -0400 Received: by fxh19 with SMTP id 19so4380927fxh.19 for ; Mon, 01 Aug 2011 02:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=o1F/t4EG8JQKe7HOnhkp3YoG3bKEuw6ywtgkzENRgGQ=; b=dUUuTd4NrMGE86GzosBAen2T6J7g8SzWnnEuv7VQTKT58PDgfPPmVEkX7HEdpIKEFO qnfpVGXBb2pYZeuB/DVPEMtmvMVSxwaNbB1eodKC5zvSHTMvV3psMxbA58fjWDKWfIAl qjXhH85vKuAvqgwL9SJIDs9nmcIxxS+7YjqsU= Received: by 10.223.58.79 with SMTP id f15mr6126474fah.53.1312191184285; Mon, 01 Aug 2011 02:33:04 -0700 (PDT) Received: from localhost.localdomain (p5495D245.dip.t-dialin.net [84.149.210.69]) by mx.google.com with ESMTPS id f27sm595832fak.7.2011.08.01.02.33.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 01 Aug 2011 02:33:03 -0700 (PDT) From: Helmut Schaa To: John Linville , Felix Fietkau Cc: linux-wireless@vger.kernel.org, Johannes Berg , Helmut Schaa Subject: [PATCHv2 1/2] mac80211: Fill in skb->protocol information for injected frames Date: Mon, 1 Aug 2011 11:32:52 +0200 Message-Id: <1312191173-23963-1-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.7.3.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 01 Aug 2011 09:33:10 +0000 (UTC) Some drivers (ath9k for example) are using skb->protocol to treat EAPOL frames somehow special (disallow aggregation for example). When running in AP mode hostapd injects the EAPOL frames through a monitor interface and thus skb->protocol isn't set at all. Hence, if the injected frame is a data frame and carries a rfc1042 headaer update the skb->protocol field accordingly. Signed-off-by: Helmut Schaa --- Changes since v1: Use cpu_to_be16 instead of ntohs as done everywhere in mac80211. net/mac80211/tx.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index b83de4e..0499707 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1631,7 +1631,9 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, struct ieee80211_radiotap_header *prthdr = (struct ieee80211_radiotap_header *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr; u16 len_rthdr; + u8 *payload; /* * Frame injection is not allowed if beaconing is not allowed @@ -1682,6 +1684,24 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, skb_set_network_header(skb, len_rthdr); skb_set_transport_header(skb, len_rthdr); + /* + * Initialize skb->protocol if the injected frame is a data frame + * carrying a rfc1042 header + */ + if (skb->len > len_rthdr + 2) { + hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr); + if (ieee80211_is_data(hdr->frame_control) && + skb->len >= len_rthdr + + ieee80211_hdrlen(hdr->frame_control) + + sizeof(rfc1042_header) + 2) { + payload = (u8 *)hdr + + ieee80211_hdrlen(hdr->frame_control); + if (compare_ether_addr(payload, rfc1042_header) == 0) + skb->protocol = cpu_to_be16((payload[6] << 8) | + payload[7]); + } + } + memset(info, 0, sizeof(*info)); info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;