diff options
author | Ujjal Roy <royujjal@gmail.com> | 2013-11-05 18:01:45 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-11-11 14:42:45 -0500 |
commit | 8d93f1f309d38b65fce0b9f0de91ba6c96990c07 (patch) | |
tree | 47856082cb75220ec8e693ef9c172a24d1e8a11c | |
parent | d03b4aa77e1187b77dfe37d14a923547f00baa66 (diff) |
mwifiex: fix wrong eth_hdr usage for bridged packets in AP mode
The eth_hdr is never defined in this driver but it gets compiled
without any warning/error because kernel has defined eth_hdr.
Fix it by defining our own p_ethhdr and use it instead of eth_hdr.
Cc: <stable@vger.kernel.org> # 3.7+
Signed-off-by: Ujjal Roy <royujjal@gmail.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/mwifiex/uap_txrx.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/net/wireless/mwifiex/uap_txrx.c b/drivers/net/wireless/mwifiex/uap_txrx.c index 1cfe5a738c47..92f76d655e6c 100644 --- a/drivers/net/wireless/mwifiex/uap_txrx.c +++ b/drivers/net/wireless/mwifiex/uap_txrx.c | |||
@@ -97,6 +97,7 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, | |||
97 | struct mwifiex_txinfo *tx_info; | 97 | struct mwifiex_txinfo *tx_info; |
98 | int hdr_chop; | 98 | int hdr_chop; |
99 | struct timeval tv; | 99 | struct timeval tv; |
100 | struct ethhdr *p_ethhdr; | ||
100 | u8 rfc1042_eth_hdr[ETH_ALEN] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; | 101 | u8 rfc1042_eth_hdr[ETH_ALEN] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; |
101 | 102 | ||
102 | uap_rx_pd = (struct uap_rxpd *)(skb->data); | 103 | uap_rx_pd = (struct uap_rxpd *)(skb->data); |
@@ -112,14 +113,36 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, | |||
112 | } | 113 | } |
113 | 114 | ||
114 | if (!memcmp(&rx_pkt_hdr->rfc1042_hdr, | 115 | if (!memcmp(&rx_pkt_hdr->rfc1042_hdr, |
115 | rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr))) | 116 | rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr))) { |
117 | /* Replace the 803 header and rfc1042 header (llc/snap) with | ||
118 | * an Ethernet II header, keep the src/dst and snap_type | ||
119 | * (ethertype). | ||
120 | * | ||
121 | * The firmware only passes up SNAP frames converting all RX | ||
122 | * data from 802.11 to 802.2/LLC/SNAP frames. | ||
123 | * | ||
124 | * To create the Ethernet II, just move the src, dst address | ||
125 | * right before the snap_type. | ||
126 | */ | ||
127 | p_ethhdr = (struct ethhdr *) | ||
128 | ((u8 *)(&rx_pkt_hdr->eth803_hdr) | ||
129 | + sizeof(rx_pkt_hdr->eth803_hdr) | ||
130 | + sizeof(rx_pkt_hdr->rfc1042_hdr) | ||
131 | - sizeof(rx_pkt_hdr->eth803_hdr.h_dest) | ||
132 | - sizeof(rx_pkt_hdr->eth803_hdr.h_source) | ||
133 | - sizeof(rx_pkt_hdr->rfc1042_hdr.snap_type)); | ||
134 | memcpy(p_ethhdr->h_source, rx_pkt_hdr->eth803_hdr.h_source, | ||
135 | sizeof(p_ethhdr->h_source)); | ||
136 | memcpy(p_ethhdr->h_dest, rx_pkt_hdr->eth803_hdr.h_dest, | ||
137 | sizeof(p_ethhdr->h_dest)); | ||
116 | /* Chop off the rxpd + the excess memory from | 138 | /* Chop off the rxpd + the excess memory from |
117 | * 802.2/llc/snap header that was removed. | 139 | * 802.2/llc/snap header that was removed. |
118 | */ | 140 | */ |
119 | hdr_chop = (u8 *)eth_hdr - (u8 *)uap_rx_pd; | 141 | hdr_chop = (u8 *)p_ethhdr - (u8 *)uap_rx_pd; |
120 | else | 142 | } else { |
121 | /* Chop off the rxpd */ | 143 | /* Chop off the rxpd */ |
122 | hdr_chop = (u8 *)&rx_pkt_hdr->eth803_hdr - (u8 *)uap_rx_pd; | 144 | hdr_chop = (u8 *)&rx_pkt_hdr->eth803_hdr - (u8 *)uap_rx_pd; |
145 | } | ||
123 | 146 | ||
124 | /* Chop off the leading header bytes so the it points | 147 | /* Chop off the leading header bytes so the it points |
125 | * to the start of either the reconstructed EthII frame | 148 | * to the start of either the reconstructed EthII frame |