From patchwork Fri Nov 1 00:43:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 287688 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B92E62C03EB for ; Fri, 1 Nov 2013 11:44:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753909Ab3KAAoM (ORCPT ); Thu, 31 Oct 2013 20:44:12 -0400 Received: from mail-oa0-f43.google.com ([209.85.219.43]:60073 "EHLO mail-oa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752397Ab3KAAoK (ORCPT ); Thu, 31 Oct 2013 20:44:10 -0400 Received: by mail-oa0-f43.google.com with SMTP id m1so3925304oag.16 for ; Thu, 31 Oct 2013 17:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=5aXxoCKxhLduLZecgPq7wF6nxXY+6hZp4meYv5aMI4U=; b=D0hp6P8EWCW3g6vKlMBxnErVOqRLIJu03MNerq2Ee3fDsJRuUQeUmH2l32qPWoI+jF dTboqJMiOZTrLFaK3QMbNviitdjvS97Bu5ZpCu5qHHj5Z5JciAkSul3BvvMMywfkKnQq JjXqf39kbOirynyUDju4om87YD63qE2I1XaSuRf+BIX2KXaHPRBQR5czYBQN/AtAhRLO Ixt/1MBaNbpPXI9BJF0mTRc7Fe2s6Khh4v4r72kDOBtO57mATnzpb1hSH+sr0pMiac0X 7iKNI08bxcIC9OKnLxSfuZxVqGchSteqHSEcqR6iNNjjZxV7GDFO7CNa40bekGRj2a7Q RW5w== X-Received: by 10.182.125.65 with SMTP id mo1mr370183obb.40.1383266649190; Thu, 31 Oct 2013 17:44:09 -0700 (PDT) Received: from larrylap.lan (cpe-75-81-36-251.kc.res.rr.com. [75.81.36.251]) by mx.google.com with ESMTPSA id z5sm9909230obg.13.2013.10.31.17.44.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Oct 2013 17:44:08 -0700 (PDT) From: Larry Finger To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Mark Cave-Ayland , netdev@vger.kernel.org, Larry Finger , Stable Subject: [PATCH NEXT V2] rtlwifi: Fix endian error in extracting packet type Date: Thu, 31 Oct 2013 19:43:58 -0500 Message-Id: <1383266638-4813-1-git-send-email-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 1.8.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mark Cave-Ayland All of the rtlwifi drivers have an error in the routine that tests if the data is "special". If it is, the subsequant transmission will be at the lowest rate to enhance reliability. The 16-bit quantity is big-endian, but was being extracted in native CPU mode. One of the effects of this bug is to inhibit association under some conditions as the TX rate is too high. A statement that would have made the code correct had been changed to a comment. Rather than just reinstating that code, the fix here passes sparse tests. A side effect of fixing this problem would have been to force all IPv6 frames to run at the lowest rate. The test for that frame type is removed. The original code only checked the lower-order byte of UDP ports for BOOTP protocol. That is extended to the full 16-bit source and destination ports. One of the local headers contained duplicates of some of the ETH_P_XXX definitions. These are deleted. Signed-off-by: Larry Finger Cc: Mark Cave-Ayland Cc: Stable [2.6.38+] --- V2 - Addresses comments by Ben Hutchings and Bjorn Mork. drivers/net/wireless/rtlwifi/base.c | 15 ++++++--------- drivers/net/wireless/rtlwifi/wifi.h | 6 +----- 2 files changed, 7 insertions(+), 14 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: wireless-testing-save/drivers/net/wireless/rtlwifi/base.c =================================================================== --- wireless-testing-save.orig/drivers/net/wireless/rtlwifi/base.c +++ wireless-testing-save/drivers/net/wireless/rtlwifi/base.c @@ -1077,17 +1077,17 @@ u8 rtl_is_special_data(struct ieee80211_ ip = (struct iphdr *)((u8 *) skb->data + mac_hdr_len + SNAP_SIZE + PROTOC_TYPE_SIZE); - ether_type = *(u16 *) ((u8 *) skb->data + mac_hdr_len + SNAP_SIZE); - /* ether_type = ntohs(ether_type); */ + ether_type = be16_to_cpu(*(__be16 *)((u8 *)skb->data + mac_hdr_len + + SNAP_SIZE)); if (ETH_P_IP == ether_type) { if (IPPROTO_UDP == ip->protocol) { struct udphdr *udp = (struct udphdr *)((u8 *) ip + (ip->ihl << 2)); - if (((((u8 *) udp)[1] == 68) && - (((u8 *) udp)[3] == 67)) || - ((((u8 *) udp)[1] == 67) && - (((u8 *) udp)[3] == 68))) { + if (((((u16 *) udp)[0] == 68) && + (((u16 *) udp)[2] == 67)) || + ((((u16 *) udp)[0] == 67) && + (((u16 *) udp)[2] == 68))) { /* * 68 : UDP BOOTP client * 67 : UDP BOOTP server @@ -1126,9 +1126,6 @@ u8 rtl_is_special_data(struct ieee80211_ } return true; - } else if (ETH_P_IPV6 == ether_type) { - /* IPv6 */ - return true; } return false; Index: wireless-testing-save/drivers/net/wireless/rtlwifi/wifi.h =================================================================== --- wireless-testing-save.orig/drivers/net/wireless/rtlwifi/wifi.h +++ wireless-testing-save/drivers/net/wireless/rtlwifi/wifi.h @@ -77,11 +77,7 @@ #define RTL_SLOT_TIME_9 9 #define RTL_SLOT_TIME_20 20 -/*related with tcp/ip. */ -/*if_ehther.h*/ -#define ETH_P_PAE 0x888E /*Port Access Entity (IEEE 802.1X) */ -#define ETH_P_IP 0x0800 /*Internet Protocol packet */ -#define ETH_P_ARP 0x0806 /*Address Resolution packet */ +/*related to tcp/ip. */ #define SNAP_SIZE 6 #define PROTOC_TYPE_SIZE 2