RX data improvements
Johannes Berg
maintainercover RX data improvements
These two patches improve some of the rx_data
handling in mac80211 and remove cludges for HT
support there.
johannes
Johannes Berg
maintainerPATCH 1/2 mac80211: trim RX data
The RX data contains the netdev, which is duplicated since we have the sdata, and the RX status pointer, which is duplicate since we have the skb. Remove those two fields to have fewer fields that depend on each other and simply load them as necessary.
--- net/mac80211/ieee80211_i.h | 2 - net/mac80211/rx.c | 80 +++++++++++++++++++++++---------------------- net/mac80211/wep.c | 8 ++-- net/mac80211/wpa.c | 25 +++++++------- 4 files changed, 61 insertions(+), 54 deletions(-)
net/mac80211/ieee80211_i.h +0 -2
@@ -167,12 +167,10 @@ typedef unsigned __bitwise__ ieee80211_rstruct ieee80211_rx_data {struct sk_buff *skb; -struct net_device *dev;struct ieee80211_local *local;struct ieee80211_sub_if_data *sdata;struct sta_info *sta;struct ieee80211_key *key; -struct ieee80211_rx_status *status;struct ieee80211_rate *rate;unsigned int flags;
net/mac80211/rx.c +42 -38
252 lines not on this page · raw message
net/mac80211/wep.c +5 -3
@@ -281,16 +281,18 @@ bool ieee80211_wep_is_weak_iv(struct sk_ieee80211_rx_result ieee80211_crypto_wep_decrypt (struct ieee80211_rx_data *rx) { -struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; +struct sk_buff *skb = rx->skb; +struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;if (!ieee80211_is_data (hdr->frame_control) && !ieee80211_is_auth (hdr->frame_control))return RX_CONTINUE ; -if (!(rx->status->flag &RX_FLAG_DECRYPTED )) { +if (!(status->flag &RX_FLAG_DECRYPTED )) {if (ieee80211_wep_decrypt (rx->local, rx->skb, rx->key))return RX_DROP_UNUSABLE ; - }else if (!(rx->status->flag &RX_FLAG_IV_STRIPPED )) { + }else if (!(status->flag &RX_FLAG_IV_STRIPPED )) {ieee80211_wep_remove_iv (rx->local, rx->skb, rx->key);/* remove ICV */ skb_trim (rx->skb, rx->skb->len -WEP_ICV_LEN );
net/mac80211/wpa.c +14 -11
@@ -85,16 +85,16 @@ ieee80211_rx_h_michael_mic_verify(structu8 *data, *key =NULL , key_offset;size_t data_len;unsigned int hdrlen; -struct ieee80211_hdr *hdr;u8 mic[MICHAEL_MIC_LEN ];struct sk_buff *skb = rx->skb; +struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;int authenticator =1 , wpa_test =0 ;/* No way to verify the MIC if the hardware stripped it */ -if (rx->status->flag &RX_FLAG_MMIC_STRIPPED ) +if (status->flag &RX_FLAG_MMIC_STRIPPED )return RX_CONTINUE ; - hdr = (struct ieee80211_hdr *)skb->data;if (!rx->key || rx->key->conf.alg !=ALG_TKIP || !ieee80211_has_protected (hdr->frame_control) || !ieee80211_is_data_present (hdr->frame_control))
@@ -216,6 +216,7 @@ ieee80211_crypto_tkip_decrypt(struct ieeint hdrlen, res, hwaccel =0 , wpa_test =0 ;struct ieee80211_key *key = rx->key;struct sk_buff *skb = rx->skb; +struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb); hdrlen =ieee80211_hdrlen (hdr->frame_control);
@@ -225,8 +226,8 @@ ieee80211_crypto_tkip_decrypt(struct ieeif (!rx->sta || skb->len - hdrlen <12 )return RX_DROP_UNUSABLE ; -if (rx->status->flag &RX_FLAG_DECRYPTED ) { -if (rx->status->flag &RX_FLAG_IV_STRIPPED ) { +if (status->flag &RX_FLAG_DECRYPTED ) { +if (status->flag &RX_FLAG_IV_STRIPPED ) {/* * Hardware took care of all processing, including * replay protection, and stripped the ICV/IV so
@@ -442,6 +443,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieeint hdrlen;struct ieee80211_key *key = rx->key;struct sk_buff *skb = rx->skb; +struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb);u8 pn[CCMP_PN_LEN ];int data_len;
@@ -455,8 +457,8 @@ ieee80211_crypto_ccmp_decrypt(struct ieeif (!rx->sta || data_len <0 )return RX_DROP_UNUSABLE ; -if ((rx->status->flag &RX_FLAG_DECRYPTED ) && - (rx->status->flag &RX_FLAG_IV_STRIPPED )) +if ((status->flag &RX_FLAG_DECRYPTED ) && + (status->flag &RX_FLAG_IV_STRIPPED ))return RX_CONTINUE ;ccmp_hdr2pn (pn, skb->data + hdrlen);
@@ -466,7 +468,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieereturn RX_DROP_UNUSABLE ; } -if (!(rx->status->flag &RX_FLAG_DECRYPTED )) { +if (!(status->flag &RX_FLAG_DECRYPTED )) {/* hardware didn't decrypt/verify MIC */ ccmp_special_blocks (skb, pn, key->u.ccmp.rx_crypto_buf,1 );
@@ -563,6 +565,7 @@ ieee80211_rx_result ieee80211_crypto_aes_cmac_decrypt(struct ieee80211_rx_data *rx) {struct sk_buff *skb = rx->skb; +struct ieee80211_rx_status *status =IEEE80211_SKB_RXCB (skb);struct ieee80211_key *key = rx->key;struct ieee80211_mmie *mmie;u8 aad[20 ], mic[8 ], ipn[6 ];
@@ -571,8 +574,8 @@ ieee80211_crypto_aes_cmac_decrypt(structif (!ieee80211_is_mgmt (hdr->frame_control))return RX_CONTINUE ; -if ((rx->status->flag &RX_FLAG_DECRYPTED ) && - (rx->status->flag &RX_FLAG_IV_STRIPPED )) +if ((status->flag &RX_FLAG_DECRYPTED ) && + (status->flag &RX_FLAG_IV_STRIPPED ))return RX_CONTINUE ;if (skb->len <24 +sizeof (*mmie))
@@ -591,7 +594,7 @@ ieee80211_crypto_aes_cmac_decrypt(structreturn RX_DROP_UNUSABLE ; } -if (!(rx->status->flag &RX_FLAG_DECRYPTED )) { +if (!(status->flag &RX_FLAG_DECRYPTED )) {/* hardware didn't decrypt/verify MIC */ bip_aad (skb, aad); ieee80211_aes_cmac(key->u.aes_cmac.tfm,
Johannes Berg
maintainerPATCH 2/2 mac80211: improve rate handling
In reply to Johannes BergSome code currently assumes that there's a valid rate pointer even in the HT case, but there can't be. To reduce reliance on that, remove the rate pointer from the RX data struct and pass it where it's needed.
Also, for now, in radiotap announce HT frames as having a DYN channel type, and remove their rate from cooked monitor radiotap completely (it isn't present in the regular monitor radiotap either.)
--- net/mac80211/ieee80211_i.h | 1 - net/mac80211/rx.c | 35 ++++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-)
net/mac80211/ieee80211_i.h +0 -1
@@ -171,7 +171,6 @@ struct ieee80211_rx_data {struct ieee80211_sub_if_data *sdata;struct sta_info *sta;struct ieee80211_key *key; -struct ieee80211_rate *rate;unsigned int flags;int queue;
net/mac80211/rx.c +18 -17
@@ -163,6 +163,9 @@ ieee80211_add_rx_radiotap_header(structif (status->band ==IEEE80211_BAND_5GHZ )put_unaligned_le16 (IEEE80211_CHAN_OFDM |IEEE80211_CHAN_5GHZ , pos); +else if (status->flag &RX_FLAG_HT ) +put_unaligned_le16 (IEEE80211_CHAN_DYN |IEEE80211_CHAN_2GHZ , + pos);else if (rate->flags &IEEE80211_RATE_ERP_G )put_unaligned_le16 (IEEE80211_CHAN_OFDM |IEEE80211_CHAN_2GHZ , pos);
@@ -1845,14 +1848,15 @@ static void ieee80211_rx_michael_mic_rep }/* TODO: use IEEE80211_RX_FRAGMENTED */ -static void ieee80211_rx_cooked_monitor (struct ieee80211_rx_data *rx) +static void ieee80211_rx_cooked_monitor (struct ieee80211_rx_data *rx, +struct ieee80211_rate *rate) {struct ieee80211_sub_if_data *sdata;struct ieee80211_local *local = rx->local;struct ieee80211_rtap_hdr {struct ieee80211_radiotap_header hdr;u8 flags; -u8 rate; +u8 rate_or_pad;__le16 chan_freq;__le16 chan_flags; } __attribute__ ((packed)) *rthdr;
@@ -1872,10 +1876,13 @@ static void ieee80211_rx_cooked_monitor( rthdr->hdr.it_len =cpu_to_le16 (sizeof (*rthdr)); rthdr->hdr.it_present =cpu_to_le32 ((1 <<IEEE80211_RADIOTAP_FLAGS ) | - (1 <<IEEE80211_RADIOTAP_RATE ) | (1 <<IEEE80211_RADIOTAP_CHANNEL )); - rthdr->rate = rx->rate->bitrate /5 ; +if (rate) { + rthdr->rate_or_pad = rate->bitrate /5 ; + rthdr->hdr.it_present |= +cpu_to_le32 (1 <<IEEE80211_RADIOTAP_RATE ); + } rthdr->chan_freq =cpu_to_le16 (status->freq);if (status->band ==IEEE80211_BAND_5GHZ )
@@ -1928,7 +1935,8 @@ static void ieee80211_rx_cooked_monitor(static void ieee80211_invoke_rx_handlers (struct ieee80211_sub_if_data *sdata,struct ieee80211_rx_data *rx, -struct sk_buff *skb) +struct sk_buff *skb, +struct ieee80211_rate *rate) {ieee80211_rx_result res =RX_DROP_MONITOR ;
@@ -1972,7 +1980,7 @@ static void ieee80211_invoke_rx_handlers rx->sta->rx_dropped++;/* fall through */ case RX_CONTINUE : -ieee80211_rx_cooked_monitor (rx); +ieee80211_rx_cooked_monitor (rx, rate);break ;case RX_DROP_UNUSABLE :I802_DEBUG_INC (sdata->local->rx_handlers_drop);
@@ -2095,7 +2103,6 @@ static void __ieee80211_rx_handle_packetmemset (&rx,0 ,sizeof (rx)); rx.skb = skb; rx.local = local; - rx.rate = rate;if (ieee80211_is_data (hdr->frame_control) ||ieee80211_is_mgmt (hdr->frame_control)) local->dot11ReceivedFragmentCount++;
@@ -2167,11 +2174,11 @@ static void __ieee80211_rx_handle_packet prev->dev->name);continue ; } -ieee80211_invoke_rx_handlers (prev, &rx, skb_new); +ieee80211_invoke_rx_handlers (prev, &rx, skb_new, rate); prev = sdata; }if (prev) -ieee80211_invoke_rx_handlers (prev, &rx, skb); +ieee80211_invoke_rx_handlers (prev, &rx, skb, rate);else dev_kfree_skb (skb); }
@@ -2200,7 +2207,7 @@ static void ieee80211_release_reorder_fr int index) {struct ieee80211_supported_band *sband; -struct ieee80211_rate *rate; +struct ieee80211_rate *rate =NULL ;struct sk_buff *skb = tid_agg_rx->reorder_buf[index];struct ieee80211_rx_status *status;
@@ -2211,9 +2218,7 @@ static void ieee80211_release_reorder_fr/* release the reordered frames to stack */ sband = hw->wiphy->bands[status->band]; -if (status->flag &RX_FLAG_HT ) - rate = sband->bitrates;/* TODO: HT rates */ -else +if (!(status->flag &RX_FLAG_HT )) rate = &sband->bitrates[status->rate_idx];__ieee80211_rx_handle_packet (hw, skb, rate); tid_agg_rx->stored_mpdu_num--;
@@ -2460,10 +2465,6 @@ void ieee80211_rx(struct ieee80211_hw *h status->rate_idx, status->rate_idx)) goto drop; -/* HT rates are not in the table - use the highest legacy rate -* for now since other parts of mac80211 may not yet be fully -* MCS aware. */ - rate = &sband->bitrates[sband->n_bitrates -1 ]; }else {if (WARN_ON (status->rate_idx <0 || status->rate_idx >= sband->n_bitrates))