mac80211: restructuring data Rx handlers
PATCH 1/1 mac80211: restructuring data Rx handlers
This patch restructures the Rx handlers chain by incorporating previously handlers ieee80211_rx_h_802_1x_pae and ieee80211_rx_h_drop_unencrypted into ieee80211_rx_h_data, already in 802.3 form. this scheme follows more precisely after the IEEE802.11 data plane archituecture, and will prevent code duplication to IEEE8021.11n A-MSDU handler.
added function:
- ieee80211_data_to_8023: transfering 802.11 data frames to 802.3 frame
eliminated handlers:
- ieee80211_rx_h_drop_unencrypted: now function ieee80211_drop_unencrypted
- ieee80211_rx_h_802_1x_pae: now function ieee80211_802_1x_pae
changed handlers:
- ieee80211_rx_h_data: now contains calls to three above function
--- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/rx.c | 88 ++++++++++++++++++++++++++------------------ net/mac80211/tx.c | 12 +++-- net/mac80211/util.c | 14 +------ 4 files changed, 61 insertions(+), 55 deletions(-)
net/mac80211/ieee80211_i.h +1 -1
@@ -792,7 +792,7 @@ extern void *mac80211_wiphy_privid; /* for wiphy privid */extern const unsigned char rfc1042_header[6 ];extern const unsigned char bridge_tunnel_header[6 ];u8 *ieee80211_get_bssid (struct ieee80211_hdr *hdr,size_t len); -int ieee80211_is_eapol (const struct sk_buff *skb); +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen);int ieee80211_frame_duration (struct ieee80211_local *local,size_t len,int rate,int erp,int short_preamble); void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
net/mac80211/rx.c +52 -36
189 lines not on this page · raw message
net/mac80211/tx.c +7 -5
@@ -420,7 +420,6 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx)return TXRX_CONTINUE ; } -static ieee80211_txrx_result ieee80211_tx_h_ps_buf (struct ieee80211_txrx_data *tx) {
@@ -433,13 +432,15 @@ ieee80211_tx_h_ps_buf(struct ieee80211_txrx_data *tx)return ieee80211_tx_h_multicast_ps_buf (tx); } - - -static ieee80211_txrx_result ieee80211_tx_h_select_key (struct ieee80211_txrx_data *tx) {struct ieee80211_key *key; +const struct ieee80211_hdr *hdr; +u16 fc; + + hdr = (const struct ieee80211_hdr *) tx->skb->data; + fc =le16_to_cpu (hdr->frame_control);if (unlikely (tx->u.tx.control->flags &IEEE80211_TXCTL_DO_NOT_ENCRYPT )) tx->key =NULL ;
@@ -448,7 +449,8 @@ ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx)else if ((key =rcu_dereference (tx->sdata->default_key))) tx->key = key;else if (tx->sdata->drop_unencrypted && - !(tx->sdata->eapol &&ieee80211_is_eapol (tx->skb))) { + !(tx->sdata->eapol && +ieee80211_is_eapol (tx->skb,ieee80211_get_hdrlen (fc)))) {I802_DEBUG_INC (tx->local->tx_handlers_drop_unencrypted);return TXRX_DROP ; }else {
net/mac80211/util.c +1 -13
@@ -217,23 +217,11 @@ int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) }EXPORT_SYMBOL (ieee80211_get_hdrlen_from_skb); -int ieee80211_is_eapol (const struct sk_buff *skb) +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen) { -const struct ieee80211_hdr *hdr; -u16 fc; -int hdrlen; -if (unlikely (skb->len <10 ))return 0 ; - hdr = (const struct ieee80211_hdr *) skb->data; - fc =le16_to_cpu (hdr->frame_control); - -if (unlikely (!WLAN_FC_DATA_PRESENT (fc))) -return 0 ; - - hdrlen =ieee80211_get_hdrlen (fc); -if (unlikely (skb->len >= hdrlen +sizeof (eapol_header) &&memcmp (skb->data + hdrlen, eapol_header,sizeof (eapol_header)) ==0 ))
Signature · 8 lines
1.5.3.3 --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Johannes Berg
maintainerAfter seeing the corresponding a-msdu patch here are a few more questions.
Quoted 11 lines
net/mac80211/rx.c +11
-0+static ieee80211_txrx_result +ieee80211_rx_h_data (struct ieee80211_txrx_data *rx) +{ +struct net_device *dev = rx->dev; +struct ieee80211_local *local = rx->local; +u16 fc; +int err; +struct sk_buff *skb, *skb2; +struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); + + fc = rx->fc;
net/mac80211/rx.c ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) · line 1156
Quoted 10 lines
net/mac80211/rx.c +10
-0+if (unlikely ((fc &IEEE80211_FCTL_FTYPE ) !=IEEE80211_FTYPE_DATA )) +return TXRX_CONTINUE ; + + err =ieee80211_data_to_8023 (rx); +if (unlikely (err)) +return TXRX_DROP ; + +if ((ieee80211_drop_802_1x_pae (rx,sizeof (struct ethhdr ))) || + (ieee80211_drop_unencrypted (rx,sizeof (struct ethhdr )))) +return TXRX_DROP ;
I like this.
net/mac80211/rx.c ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) · line 1162
Quoted 5 lines
net/mac80211/rx.c +2
-0+ skb = rx->skb; + skb->dev = dev; skb2 =NULL ; dev->stats.rx_packets++;
Ok so the stuff that comes after this until the ned of the function is responsible for delivering the packet. Maybe that should be split out from the function too into something like ieee80211_deliver_skb()? In the A-MSDU code you've had to basically copy all this code into the loop as far as I can tell, something which I'd like to avoid very much.
johannes
Quoted 28 lines
Quoted 11 lines
net/mac80211/rx.c +11
-0+static ieee80211_txrx_result +ieee80211_rx_h_data (struct ieee80211_txrx_data *rx) +{ +struct net_device *dev = rx->dev; +struct ieee80211_local *local = rx->local; +u16 fc; +int err; +struct sk_buff *skb, *skb2; +struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); + + fc = rx->fc;net/mac80211/rx.c ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) · line 1156
Quoted 10 lines
net/mac80211/rx.c +10
-0+if (unlikely ((fc &IEEE80211_FCTL_FTYPE ) !=IEEE80211_FTYPE_DATA )) +return TXRX_CONTINUE ; + + err =ieee80211_data_to_8023 (rx); +if (unlikely (err)) +return TXRX_DROP ; + +if ((ieee80211_drop_802_1x_pae (rx,sizeof (struct ethhdr ))) || + (ieee80211_drop_unencrypted (rx,sizeof (struct ethhdr )))) +return TXRX_DROP ;I like this.
Quoted 4 lines
net/mac80211/rx.c +2
-0+ skb = rx->skb; + skb->dev = dev; skb2 =NULL ;
Quoted 7 lines
Quoted 1 line
dev->stats.rx_packets++;Ok so the stuff that comes after this until the ned of the function is responsible for delivering the packet. Maybe that should be split out from the function too into something like
ieee80211_deliver_skb()? In the A-MSDU code you've had to basically copy all this code into the loop as far as I can tell, something which I'd like to avoid very much.
I agree, it will be more readable that way. i'll do the needed changes.
Quoted 4 lines
johannes
Johannes Berg
maintainerHi Ron,
Sorry this will most likely in email crossing because I'm writing this as I haven't been able to check mail since yesterday afternoon.
Looking into the eapol handling in more detail, I found another bug with your patch. Namely, in the RX path, you have:
net/mac80211/rx.c ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx) · line 962
Quoted 2 lines
net/mac80211/rx.c +1
-1- if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb) && + if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb, hdrlen) &&
at which point the frame is already reframed to 802.3.
However,
net/mac80211/util.c int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) · line 227
Quoted 7 lines
net/mac80211/util.c +1
-1-int ieee80211_is_eapol (const struct sk_buff *skb) +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen) {if (unlikely (skb->len >= hdrlen +sizeof (eapol_header) &&memcmp (skb->data + hdrlen, eapol_header,sizeof (eapol_header)) ==0 ))
here checks the full 802.2 LLC header which was removed by the reframing, thus this check will always be false.
I think we should, instead, have the ieee80211_data_to_8023 function set skb->protocol correctly, and leave the skb's data pointer pointing to the payload rather than the ethernet header, like eth_type_trans() would do. In fact, I think we can just call it after we've reframed the frame. Then, we can check skb->protocol for EAPOL which is a much cheaper check too.
The thing I'm not entirely sure about is what happens with eth_type_trans() and the pulling of the ethernet header. Wouldn't that cause us problems with the skb->data[] accesses in ieee80211_subif_start_xmit() once the frame arrives back there?
johannes
Quoted 28 lines
Looking into the eapol handling in more detail, I found another bug with your patch. Namely, in the RX path, you have:
net/mac80211/rx.c ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx) · line 962
Quoted 2 lines
net/mac80211/rx.c +1
-1- if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb) && + if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb, hdrlen) &&at which point the frame is already reframed to 802.3.
However,
net/mac80211/util.c int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) · line 227
Quoted 7 lines
net/mac80211/util.c +1
-1-int ieee80211_is_eapol (const struct sk_buff *skb) +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen) {if (unlikely (skb->len >= hdrlen +sizeof (eapol_header) &&memcmp (skb->data + hdrlen, eapol_header,sizeof (eapol_header)) ==0 ))here checks the full 802.2 LLC header which was removed by the reframing, thus this check will always be false.
I think we should, instead, have the
ieee80211_data_to_8023function setskb->protocolcorrectly, and leave the skb's data pointer pointing to the payload rather than the ethernet header, likeeth_type_trans()would do. In fact, I think we can just call it after we've reframed the frame. Then, we can checkskb->protocolfor EAPOL which is a much cheaper check too.
Quoted 4 lines
The thing I'm not entirely sure about is what happens with
eth_type_trans()and the pulling of the ethernet header. Wouldn't that cause us problems with the skb->data[] accesses inieee80211_subif_start_xmit()once the frame arrives back there?
excellent catch, you are right.
let me suggest an alternative, which makes use of current ieee80211_is_eapol. in regular Rx data frames, code will look like this:
+ ieee80211_drop_802_1x_pae(rx, size of current 802.11 hdr);
+ ieee80211_drop_unencrypted(rx, size of current 802.11 hdr);
ieee80211_data_to_8023(rx)- ieee80211_drop_802_1x_pae(rx, size of 802.3 hdr);
- ieee80211_drop_unencrypted(rx, size of 802.3 hdr);
while in A-MSDU frames code will look like this:
ieee80211_data_to_8023(rx)
for each internal frame (that is any how in 802.2 form):
+ ieee80211_drop_802_1x_pae(rx, 0);
+ ieee80211_drop_unencrypted(rx, 0);
move from 802.2 to 802.3- ieee80211_drop_802_1x_pae(rx, size of 802.3 hdr);
- ieee80211_drop_unencrypted(rx, size of 802.3 hdr);
I thought it makes good use of the infrastructure we made so far, what do you think?
Quoted 3 lines
johannes
Johannes Berg
maintainerQuoted 20 lines
let me suggest an alternative, which makes use of current
ieee80211_is_eapol. in regular Rx data frames, code will look like this:(quoted diff) +2
-2+ ieee80211_drop_802_1x_pae(rx, size of current 802.11 hdr); + ieee80211_drop_unencrypted(rx, size of current 802.11 hdr); ieee80211_data_to_8023(rx) - ieee80211_drop_802_1x_pae(rx, size of 802.3 hdr); - ieee80211_drop_unencrypted(rx, size of 802.3 hdr);while in A-MSDU frames code will look like this:
ieee80211_data_to_8023(rx)for each internal frame (that is any how in 802.2 form):
(quoted diff) +2
-2+ ieee80211_drop_802_1x_pae(rx, 0); + ieee80211_drop_unencrypted(rx, 0); move from 802.2 to 802.3 - ieee80211_drop_802_1x_pae(rx, size of 802.3 hdr); - ieee80211_drop_unencrypted(rx, size of 802.3 hdr);
Quoted 2 lines
I thought it makes good use of the infrastructure we made so far, what do you think?
Yes, that would work too. I'm not entirely sure about the effect on eapol handling but I'll sort that out with that patch then. At worst I get to restructure the code instead of you :)
johannes
Johannes Berg
maintainerQuoted 4 lines
Yes, that would work too. I'm not entirely sure about the effect on eapol handling but I'll sort that out with that patch then. At worst I get to restructure the code instead of you :)
Actually, what I did in that patch is move the eapol decision out of the port control function which is probably better. Anyway, if you can do the restructuring and make it work as it is now, I'll do the rest.
johannes