From patchwork Fri Feb 19 10:01:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 8359111 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 60F4B9F372 for ; Fri, 19 Feb 2016 10:02:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BCD72041C for ; Fri, 19 Feb 2016 10:02:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6ABA42041B for ; Fri, 19 Feb 2016 10:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1426981AbcBSKCO (ORCPT ); Fri, 19 Feb 2016 05:02:14 -0500 Received: from mail-lb0-f170.google.com ([209.85.217.170]:33126 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756806AbcBSKCK (ORCPT ); Fri, 19 Feb 2016 05:02:10 -0500 Received: by mail-lb0-f170.google.com with SMTP id x4so44565481lbm.0 for ; Fri, 19 Feb 2016 02:02:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id; bh=fIFO64ZMJ1Lqa4AaUsQaqJ+YMAJqE3ddOb48lLBdLDQ=; b=xerkzRhe7FZcaLkFcJ+KHrvVPh/k/M4qjSlmE3VSGmmg4WwQsVWu8BoJNPytUkmOoB MeYAhbgvJ/hal7F+PjnT36gEp63r/DBg5TLNmKwZnVXN9ar/+kcYTBFOnH172Ku/FaJk uk8WrDi1K7JaXfhVtair8UL7IKGImrcpVYLpY= 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; bh=fIFO64ZMJ1Lqa4AaUsQaqJ+YMAJqE3ddOb48lLBdLDQ=; b=ejacoEvMx5Ap1dDvKoBeg9HwgiKF9yQen/NIMmbHQP8EVMHLPNh2KeysnWkUHgFWZo uvAhsgzn7/iB5xyIxpTDum3JR6b165DVIDw9es3cTea5MmP96aPerkmchdJI6v+4BKTz S+IgLxXV+UlryquUY2G19KTSeSuacsBeUZ/YT8UH8OLdguOt8UWYr5e4phsHFAbErqMS bRt8c+Y1MxyLNL3JB7SurZXQ2wgOOzCaYlErRKkYbGEpBX07dV58etfYAu6G4Za6IT58 RQaIdJru+d9XsNqESQal/wbCf810XjLsRvX+hc9YEyvz1tuomzk5ud5RlrY6gp2DuObH yzOA== X-Gm-Message-State: AG10YOSdCgg+mswCTI4ZkO7/a7WpRwW62wCgIXZMRrMalwuSay1Lwhu2dszMjK6ItsIXl97BTGHJIA0+zQAy415z9jCbBdX4fOSZfQOrBUKOiLv8g2O6WQxC/XizVwTFuDRI6QR/9CTCmKzw39kq9G9uxONv97njFJ651O4XWgJeywZXWWGVt6VjOnU3drsQNYxlEPU0GA== X-Received: by 10.112.171.4 with SMTP id aq4mr4961659lbc.85.1455876128775; Fri, 19 Feb 2016 02:02:08 -0800 (PST) Received: from dell6430.guest.wifi ([91.198.246.8]) by smtp.gmail.com with ESMTPSA id 37sm1441279lfs.3.2016.02.19.02.02.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Feb 2016 02:02:07 -0800 (PST) From: Janusz Dziedzic To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Janusz Dziedzic Subject: [PATCH 1/2] mac80211: add hdrlen to ieee80211_tx_data Date: Fri, 19 Feb 2016 11:01:49 +0100 Message-Id: <1455876110-12758-1-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 X-DomainID: tieto.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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY 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 Add hdrlen to ieee80211_tx_data and use this when wep/ccmd/tkip. This is preparation for aligned4 code. Signed-off-by: Janusz Dziedzic --- net/mac80211/ieee80211_i.h | 1 + net/mac80211/tx.c | 6 +++--- net/mac80211/util.c | 5 ++++- net/mac80211/wep.c | 11 ++++++----- net/mac80211/wep.h | 1 + net/mac80211/wpa.c | 13 +++++-------- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index a29f61d..81a476a 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -172,6 +172,7 @@ struct ieee80211_tx_data { struct ieee80211_tx_rate rate; unsigned int flags; + unsigned int hdrlen; }; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 3311ce0..cd4c361 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -915,7 +915,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (void *)skb->data; int frag_threshold = tx->local->hw.wiphy->frag_threshold; - int hdrlen; + int hdrlen = tx->hdrlen; int fragnum; /* no matter what happens, tx->skb moves to tx->skbs */ @@ -936,8 +936,6 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) if (WARN_ON(info->flags & IEEE80211_TX_CTL_AMPDU)) return TX_DROP; - hdrlen = ieee80211_hdrlen(hdr->frame_control); - /* internal error, why isn't DONTFRAG set? */ if (WARN_ON(skb->len + FCS_LEN <= frag_threshold)) return TX_DROP; @@ -1165,6 +1163,8 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata, hdr = (struct ieee80211_hdr *) skb->data; + tx->hdrlen = ieee80211_hdrlen(hdr->frame_control); + if (likely(sta)) { if (!IS_ERR(sta)) tx->sta = sta; diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 54afbf4..b3c6515 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1225,6 +1225,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, struct ieee80211_local *local = sdata->local; struct sk_buff *skb; struct ieee80211_mgmt *mgmt; + unsigned int hdrlen; int err; /* 24 + 6 = header + auth_algo + auth_transaction + status_code */ @@ -1249,8 +1250,10 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, memcpy(skb_put(skb, extra_len), extra, extra_len); if (auth_alg == WLAN_AUTH_SHARED_KEY && transaction == 3) { + hdrlen = ieee80211_hdrlen(mgmt->frame_control); mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); - err = ieee80211_wep_encrypt(local, skb, key, key_len, key_idx); + err = ieee80211_wep_encrypt(local, skb, hdrlen, key, + key_len, key_idx); WARN_ON(err); } diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index efa3f48..d14bdb0 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c @@ -89,11 +89,11 @@ static void ieee80211_wep_get_iv(struct ieee80211_local *local, static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, struct sk_buff *skb, + unsigned int hdrlen, int keylen, int keyidx) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - unsigned int hdrlen; u8 *newhdr; hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); @@ -101,7 +101,6 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN)) return NULL; - hdrlen = ieee80211_hdrlen(hdr->frame_control); newhdr = skb_push(skb, IEEE80211_WEP_IV_LEN); memmove(newhdr, newhdr + IEEE80211_WEP_IV_LEN, hdrlen); @@ -160,6 +159,7 @@ int ieee80211_wep_encrypt_data(struct crypto_cipher *tfm, u8 *rc4key, */ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb, + unsigned int hdrlen, const u8 *key, int keylen, int keyidx) { u8 *iv; @@ -169,7 +169,7 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN)) return -1; - iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx); + iv = ieee80211_wep_add_iv(local, skb, hdrlen, keylen, keyidx); if (!iv) return -1; @@ -306,13 +306,14 @@ static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) struct ieee80211_key_conf *hw_key = info->control.hw_key; if (!hw_key) { - if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key, + if (ieee80211_wep_encrypt(tx->local, skb, tx->hdrlen, + tx->key->conf.key, tx->key->conf.keylen, tx->key->conf.keyidx)) return -1; } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) || (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { - if (!ieee80211_wep_add_iv(tx->local, skb, + if (!ieee80211_wep_add_iv(tx->local, skb, tx->hdrlen, tx->key->conf.keylen, tx->key->conf.keyidx)) return -1; diff --git a/net/mac80211/wep.h b/net/mac80211/wep.h index 9615749..ad0a52b 100644 --- a/net/mac80211/wep.h +++ b/net/mac80211/wep.h @@ -22,6 +22,7 @@ int ieee80211_wep_encrypt_data(struct crypto_cipher *tfm, u8 *rc4key, size_t klen, u8 *data, size_t data_len); int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb, + unsigned int hdrlen, const u8 *key, int keylen, int keyidx); int ieee80211_wep_decrypt_data(struct crypto_cipher *tfm, u8 *rc4key, size_t klen, u8 *data, size_t data_len); diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index d824c38..e8bfb13 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c @@ -42,7 +42,7 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_tx_data *tx) skb->len < 24 || !ieee80211_is_data_present(hdr->frame_control)) return TX_CONTINUE; - hdrlen = ieee80211_hdrlen(hdr->frame_control); + hdrlen = tx->hdrlen; if (skb->len < hdrlen) return TX_DROP; @@ -186,7 +186,6 @@ mic_fail_no_key: static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_key *key = tx->key; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); unsigned int hdrlen; @@ -200,7 +199,7 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) return 0; } - hdrlen = ieee80211_hdrlen(hdr->frame_control); + hdrlen = tx->hdrlen; len = skb->len - hdrlen; if (info->control.hw_key) @@ -424,7 +423,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb, return 0; } - hdrlen = ieee80211_hdrlen(hdr->frame_control); + hdrlen = tx->hdrlen; len = skb->len - hdrlen; if (info->control.hw_key) @@ -651,7 +650,7 @@ static int gcmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) return 0; } - hdrlen = ieee80211_hdrlen(hdr->frame_control); + hdrlen = tx->hdrlen; len = skb->len - hdrlen; if (info->control.hw_key) @@ -787,7 +786,6 @@ static ieee80211_tx_result ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx, struct sk_buff *skb) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_key *key = tx->key; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); int hdrlen; @@ -803,8 +801,7 @@ ieee80211_crypto_cs_encrypt(struct ieee80211_tx_data *tx, pskb_expand_head(skb, iv_len, 0, GFP_ATOMIC))) return TX_DROP; - hdrlen = ieee80211_hdrlen(hdr->frame_control); - + hdrlen = tx->hdrlen; pos = skb_push(skb, iv_len); memmove(pos, pos + iv_len, hdrlen);