From patchwork Sun Nov 9 16:50:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arik Nemtsov X-Patchwork-Id: 5261571 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 824B9C11AC for ; Sun, 9 Nov 2014 16:50:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FC3F20136 for ; Sun, 9 Nov 2014 16:50:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3E4820127 for ; Sun, 9 Nov 2014 16:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752021AbaKIQuf (ORCPT ); Sun, 9 Nov 2014 11:50:35 -0500 Received: from mail-wi0-f181.google.com ([209.85.212.181]:59596 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751922AbaKIQuc (ORCPT ); Sun, 9 Nov 2014 11:50:32 -0500 Received: by mail-wi0-f181.google.com with SMTP id n3so8461767wiv.2 for ; Sun, 09 Nov 2014 08:50:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OHhjx8ilPfMT8DxFFUiPj6JMIEocbcegIh2YYweMyOQ=; b=E4+dLBfFHRrkH/KVgOuiA8awAIXrg9P0mNr3EIl2rkjLPs5THpRTqO81fLS4E5kcl2 U1mp3g64juupGJxKNhvtoR8aIuLrDR4DXAVsi1kdLzZoYKj1fQwOwqEuKrvz5xHHe2LR VSx3AfZK2+a4WLYc9J32EAdUrjIMquFXQqVBZSj1kkJoabeWDZgtPfYNtVWihwY3xfR/ au5bAXbeLz6F1AKKFoYT+/RyA4GRWvkbNcHYoDId1aZWiLPMD3yeTTBck5wLwNTRr5CA jb2T1GdClFJ54wr/8Pw5GzFQ+VUjqs83NxyRfs3ZrKEAyq3X7JUoCjKjAoMM6tdiwndn lkyQ== X-Gm-Message-State: ALoCoQnl550Dky/a4kq4G1BsD6zsV7lIMlJl9htZJoShe5Fvkr8Wn3f+gbA0aD+Ngo34po+AByrg X-Received: by 10.180.109.100 with SMTP id hr4mr23363004wib.39.1415551831219; Sun, 09 Nov 2014 08:50:31 -0800 (PST) Received: from athena.amr.corp.intel.com (93-172-126-236.bb.netvision.net.il. [93.172.126.236]) by mx.google.com with ESMTPSA id r2sm9994037wif.23.2014.11.09.08.50.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 09 Nov 2014 08:50:30 -0800 (PST) From: Arik Nemtsov To: Cc: Johannes Berg , Johannes Berg , Arik Nemtsov Subject: [PATCH 05/16] mac80211: add function to create data frame template including key Date: Sun, 9 Nov 2014 18:50:11 +0200 Message-Id: <1415551822-20121-5-git-send-email-arik@wizery.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415551822-20121-1-git-send-email-arik@wizery.com> References: <1415551822-20121-1-git-send-email-arik@wizery.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_RHS_DOB autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg For some TDLS channel switch implementations data frames need to be sent by the firmware based on a template. This template should be created by mac80211, and thus needs to properly be built from an 802.3 frame into an 802.11 frame. In addition, the device will need the key information so the select_key handler needs to be run. However, the driver/device will be responsible for all of the crypto encapsulation, as the sequence numbers etc. cannot be built by the host anyway in this case since it's a template to be used multiple times. Signed-off-by: Johannes Berg Signed-off-by: Arik Nemtsov --- net/mac80211/ieee80211_i.h | 3 +++ net/mac80211/tx.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 00cda1e..53eb41f 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1634,6 +1634,9 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, u32 info_flags); void ieee80211_purge_tx_queue(struct ieee80211_hw *hw, struct sk_buff_head *skbs); +struct sk_buff * +ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata, + struct sk_buff *skb, u32 info_flags); /* HT */ void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index f67131a..54007ce 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -2277,6 +2277,37 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, return NETDEV_TX_OK; } +struct sk_buff * +ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata, + struct sk_buff *skb, u32 info_flags) +{ + struct ieee80211_hdr *hdr; + struct ieee80211_tx_data tx = { + .local = sdata->local, + .sdata = sdata, + }; + + rcu_read_lock(); + + skb = ieee80211_build_hdr(sdata, skb, info_flags); + if (IS_ERR(skb)) + goto out; + + hdr = (void *)skb->data; + tx.sta = sta_info_get(sdata, hdr->addr1); + tx.skb = skb; + + if (ieee80211_tx_h_select_key(&tx) != TX_CONTINUE) { + rcu_read_unlock(); + kfree_skb(skb); + return ERR_PTR(-EINVAL); + } + +out: + rcu_read_unlock(); + return skb; +} + /* * ieee80211_clear_tx_pending may not be called in a context where * it is possible that it packets could come in again.