Commit 172ba819 authored by Mark Cave-Ayland's avatar Mark Cave-Ayland Committed by Greg Kroah-Hartman

rtlwifi: Fix endian error in extracting packet type

commit 0c5d63f0 upstream.

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.

Based on suggestions by Joe Perches, the entire routine is rewritten.

One of the local headers contained duplicates of some of the ETH_P_XXX
definitions. These are deleted.
Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
[wujg: Backported to 3.4:
 - adjust context
 - remove rtlpriv->enter_ps = false
 - use schedule_work(&rtlpriv->works.lps_leave_work)]
Signed-off-by: default avatarJianguo Wu <wujianguo@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e87845b7
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/udp.h>
/* /*
*NOTICE!!!: This file will be very big, we should *NOTICE!!!: This file will be very big, we should
...@@ -957,61 +958,51 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) ...@@ -957,61 +958,51 @@ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx)
if (!ieee80211_is_data(fc)) if (!ieee80211_is_data(fc))
return false; return false;
ip = (const struct iphdr *)(skb->data + mac_hdr_len +
SNAP_SIZE + PROTOC_TYPE_SIZE);
ether_type = be16_to_cpup((__be16 *)
(skb->data + mac_hdr_len + SNAP_SIZE));
ip = (struct iphdr *)((u8 *) skb->data + mac_hdr_len + switch (ether_type) {
SNAP_SIZE + PROTOC_TYPE_SIZE); case ETH_P_IP: {
ether_type = *(u16 *) ((u8 *) skb->data + mac_hdr_len + SNAP_SIZE); struct udphdr *udp;
/* ether_type = ntohs(ether_type); */ u16 src;
u16 dst;
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))) {
/*
* 68 : UDP BOOTP client
* 67 : UDP BOOTP server
*/
RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV),
DBG_DMESG, "dhcp %s !!\n",
is_tx ? "Tx" : "Rx");
if (is_tx) {
schedule_work(&rtlpriv->
works.lps_leave_work);
ppsc->last_delaylps_stamp_jiffies =
jiffies;
}
return true; if (ip->protocol != IPPROTO_UDP)
} return false;
} udp = (struct udphdr *)((u8 *)ip + (ip->ihl << 2));
} else if (ETH_P_ARP == ether_type) { src = be16_to_cpu(udp->source);
if (is_tx) { dst = be16_to_cpu(udp->dest);
schedule_work(&rtlpriv->works.lps_leave_work);
ppsc->last_delaylps_stamp_jiffies = jiffies;
}
return true; /* If this case involves port 68 (UDP BOOTP client) connecting
} else if (ETH_P_PAE == ether_type) { * with port 67 (UDP BOOTP server), then return true so that
* the lowest speed is used.
*/
if (!((src == 68 && dst == 67) || (src == 67 && dst == 68)))
return false;
RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
"dhcp %s !!\n", is_tx ? "Tx" : "Rx");
break;
}
case ETH_P_ARP:
break;
case ETH_P_PAE:
RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG, RT_TRACE(rtlpriv, (COMP_SEND | COMP_RECV), DBG_DMESG,
"802.1X %s EAPOL pkt!!\n", is_tx ? "Tx" : "Rx"); "802.1X %s EAPOL pkt!!\n", is_tx ? "Tx" : "Rx");
break;
if (is_tx) { case ETH_P_IPV6:
schedule_work(&rtlpriv->works.lps_leave_work); /* TODO: Is this right? */
ppsc->last_delaylps_stamp_jiffies = jiffies; return false;
} default:
return false;
return true;
} else if (ETH_P_IPV6 == ether_type) {
/* IPv6 */
return true;
} }
if (is_tx) {
return false; schedule_work(&rtlpriv->works.lps_leave_work);
ppsc->last_delaylps_stamp_jiffies = jiffies;
}
return true;
} }
/********************************************************* /*********************************************************
......
...@@ -77,11 +77,7 @@ ...@@ -77,11 +77,7 @@
#define RTL_SLOT_TIME_9 9 #define RTL_SLOT_TIME_9 9
#define RTL_SLOT_TIME_20 20 #define RTL_SLOT_TIME_20 20
/*related with tcp/ip. */ /*related to 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 */
#define SNAP_SIZE 6 #define SNAP_SIZE 6
#define PROTOC_TYPE_SIZE 2 #define PROTOC_TYPE_SIZE 2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment