From patchwork Wed Jul 4 16:10:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Cavallari X-Patchwork-Id: 1156761 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C74583FC36 for ; Wed, 4 Jul 2012 16:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753584Ab2GDQLj (ORCPT ); Wed, 4 Jul 2012 12:11:39 -0400 Received: from smtp2.u-psud.fr ([129.175.33.42]:13169 "EHLO smtp2.u-psud.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750986Ab2GDQLj (ORCPT ); Wed, 4 Jul 2012 12:11:39 -0400 Received: from smtp2.u-psud.fr (localhost [127.0.0.1]) by localhost (MTA) with SMTP id E47FA34D63F; Wed, 4 Jul 2012 18:11:37 +0200 (CEST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by smtp2.u-psud.fr (MTA) with ESMTP id C36FD34D601; Wed, 4 Jul 2012 18:11:37 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id C2EE54097B; Wed, 4 Jul 2012 18:11:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gvEszygYvmCV; Wed, 4 Jul 2012 18:11:37 +0200 (CEST) Received: from smtp-ng.lri.fr (smtp [129.175.3.73]) by ext.lri.fr (Postfix) with ESMTP id A699F40512; Wed, 4 Jul 2012 18:11:37 +0200 (CEST) Received: from lowerbit.lri.fr (lri25-36 [129.175.25.36]) by smtp-ng.lri.fr (Postfix) with ESMTP id 9850060D67; Wed, 4 Jul 2012 18:11:37 +0200 (CEST) From: Nicolas Cavallari To: "John W. Linville" , Johannes Berg Cc: linux-wireless@vger.kernel.org Subject: [PATCH 1/2] mac80211: restructure key selection Date: Wed, 4 Jul 2012 18:10:07 +0200 Message-Id: <1341418208-28663-1-git-send-email-cavallar@lri.fr> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1341408545.12432.10.camel@jlt3.sipsolutions.net> References: <1341408545.12432.10.camel@jlt3.sipsolutions.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg The "no key" case in key selection that decides whether to drop the frame or not is impossible to understand, restructure the code. Signed-off-by: Johannes Berg [cavallar@lri.fr: removed blank line and restructured action frame clause] Signed-off-by: Nicolas Cavallari --- net/mac80211/tx.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 4990f4f..cdd4ac6 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -523,7 +523,7 @@ ieee80211_tx_h_check_control_port_protocol(struct ieee80211_tx_data *tx) static ieee80211_tx_result debug_noinline ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) { - struct ieee80211_key *key = NULL; + struct ieee80211_key *key; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; @@ -542,16 +542,20 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) else if (!is_multicast_ether_addr(hdr->addr1) && (key = rcu_dereference(tx->sdata->default_unicast_key))) tx->key = key; - else if (tx->sdata->drop_unencrypted && - (tx->skb->protocol != tx->sdata->control_port_protocol) && - !(info->flags & IEEE80211_TX_CTL_INJECTED) && - (!ieee80211_is_robust_mgmt_frame(hdr) || - (ieee80211_is_action(hdr->frame_control) && - tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))) { + else if (info->flags & IEEE80211_TX_CTL_INJECTED) + tx->key = NULL; + else if (!tx->sdata->drop_unencrypted) + tx->key = NULL; + else if (tx->skb->protocol == tx->sdata->control_port_protocol) + tx->key = NULL; + else if (ieee80211_is_robust_mgmt_frame(hdr) && + !(ieee80211_is_action(hdr->frame_control) && + tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP))) + tx->key = NULL; + else { I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); return TX_DROP; - } else - tx->key = NULL; + } if (tx->key) { bool skip_hw = false;