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 | 56 +++++++++++++++++++++++++++---------------- net/mac80211/tx.c | 13 ++++++---- net/mac80211/util.c | 14 +---------- 4 files changed, 45 insertions(+), 40 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 +35 -21
126 lines not on this page · raw message
net/mac80211/tx.c +8 -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,17 @@ 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; +int hdrlen; + + hdr = (const struct ieee80211_hdr *) tx->skb->data; + fc =le16_to_cpu (hdr->frame_control); + hdrlen =ieee80211_get_hdrlen (fc);if (unlikely (tx->u.tx.control->flags &IEEE80211_TXCTL_DO_NOT_ENCRYPT )) tx->key =NULL ;
@@ -448,7 +451,7 @@ 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, hdrlen))) {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
maintainerQuoted 5 lines · Ron Rindjunsky
This patch restructures the Rx handlers chain by incorporating previously handlers
ieee80211_rx_h_802_1x_paeandieee80211_rx_h_drop_unencryptedintoieee80211_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.
Nice, thanks for doing this. Few comments and questions below.
net/mac80211/ieee80211_i.h extern void *mac80211_wiphy_privid; /* for wiphy privid */ · line 795
Quoted 2 lines
net/mac80211/ieee80211_i.h +1
-1-int ieee80211_is_eapol (const struct sk_buff *skb); +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen);
That's just an optimisation, right?
net/mac80211/rx.c ieee80211_rx_h_802_1x_pae(struct ieee80211_txrx_data *rx) · line 974
Quoted 9 lines
#ifdef
CONFIG_MAC80211_DEBUGnet/mac80211/rx.c +2
-6-struct ieee80211_hdr *hdr = - (struct ieee80211_hdr *) rx->skb->data; -DECLARE_MAC_BUF (mac); -printk (KERN_DEBUG "%s: dropped frame from %s" -" (unauthorized port)\n" , rx->dev->name, -print_mac (mac, hdr->addr2)); +printk (KERN_DEBUG "%s: dropped frame " +"(unauthorized port)\n" , rx->dev->name);
Any reason you're getting rid of the MAC printk? It's a debug-only message so whatever, just curious really.
net/mac80211/rx.c ieee80211_rx_h_drop_unencrypted(struct ieee80211_txrx_data *rx) · line 998
Quoted 3 lines
net/mac80211/rx.c +2
-1- (rx->sdata->eapol == 0 || !ieee80211_is_eapol(rx->skb)))) { + (rx->sdata->eapol == 0 || + !ieee80211_is_eapol(rx->skb, hdrlen)))) {
I guess you could make it look nicer by doing !rx->sdata->eapol || ...
net/mac80211/rx.c ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) · line 1154
Quoted 6 lines
net/mac80211/rx.c +6
-0+if (ieee80211_data_to_8023 (rx) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_802_1x_pae (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_drop_unencrypted (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ;
The sizeof() doesn't look right, shouldn't that get the hdrlen from the frame control? Ah, no, I see now, it's already converted at this point. Do we need to pass the hdrlen at all then? I think it would make sense to specify (in comments) that those functions get a converted (to 802.3 framing) skb instead. And then hardcode the frame offsets/header length.
Also, I think the return value of those functions shouldn't be the txrx_result but rather just a bool.
Quoted 15 lines
static
ieee80211_txrx_resultieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx){net/mac80211/tx.c +7
-0struct ieee80211_key *key; +const struct ieee80211_hdr *hdr; +u16 fc; +int hdrlen; + + hdr = (const struct ieee80211_hdr *) tx->skb->data; + fc =le16_to_cpu (hdr->frame_control); + hdrlen =ieee80211_get_hdrlen (fc);if (unlikely (tx->u.tx.control->flags &IEEE80211_TXCTL_DO_NOT_ENCRYPT )) tx->key =NULL ;
net/mac80211/tx.c ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx) · line 454
Quoted 5 lines
net/mac80211/tx.c +1
-1@@ -448,7 +451,7 @@ 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, hdrlen))) {
I think it would make sense to have another function ieee80211_is_eapol_checked(tx->skb) that does the hdrlen calculation to save doing it unconditionally here for the (common) case where we're using a sta or default key.
Overall, nice patch.
johannes
Quoted 6 lines
Quoted 5 lines
This patch restructures the Rx handlers chain by incorporating previously handlers
ieee80211_rx_h_802_1x_paeandieee80211_rx_h_drop_unencryptedintoieee80211_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.
Quoted 7 lines
Nice, thanks for doing this. Few comments and questions below.
net/mac80211/ieee80211_i.h extern void *mac80211_wiphy_privid; /* for wiphy privid */ · line 795
Quoted 2 lines
net/mac80211/ieee80211_i.h +1
-1-int ieee80211_is_eapol (const struct sk_buff *skb); +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen);That's just an optimisation, right?
main reason is that ieee80211_is_eapol is called both in Tx and Rx flows, so the caller is reaponsible for passing the header length (802.3 in Rx and 802.11 in Tx).
Quoted 11 lines
net/mac80211/rx.c ieee80211_rx_h_802_1x_pae(struct ieee80211_txrx_data *rx) · line 974
Quoted 10 lines
#ifdef
CONFIG_MAC80211_DEBUGnet/mac80211/rx.c +2
-6-struct ieee80211_hdr *hdr = - (struct ieee80211_hdr *) rx->skb->data; -DECLARE_MAC_BUF (mac); -printk (KERN_DEBUG "%s: dropped frame from %s" -" (unauthorized port)\n" , rx->dev->name, -print_mac (mac, hdr->addr2)); +printk (KERN_DEBUG "%s: dropped frame " +"(unauthorized port)\n" , rx->dev->name);
Quoted 3 lines
Any reason you're getting rid of the MAC printk? It's a debug-only message so whatever, just curious really.
as ieee80211_802_1x_pae is not a 802.11 specific any more, it has no knowledge about the header, therefore no knowledge about mac address. I could pass to it the mac address as well, but looks odd to do that only for debug printing.
Quoted 5 lines
net/mac80211/rx.c ieee80211_rx_h_drop_unencrypted(struct ieee80211_txrx_data *rx) · line 998
Quoted 3 lines
net/mac80211/rx.c +2
-1- (rx->sdata->eapol == 0 || !ieee80211_is_eapol(rx->skb)))) { + (rx->sdata->eapol == 0 || + !ieee80211_is_eapol(rx->skb, hdrlen)))) {I guess you could make it look nicer by doing !rx->sdata->eapol || ...
no problems, will do
Quoted 8 lines
net/mac80211/rx.c ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) · line 1154
Quoted 7 lines
net/mac80211/rx.c +6
-0+if (ieee80211_data_to_8023 (rx) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_802_1x_pae (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_drop_unencrypted (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ;
Quoted 5 lines
The
sizeof()doesn't look right, shouldn't that get the hdrlen from the frame control? Ah, no, I see now, it's already converted at this point. Do we need to pass the hdrlen at all then? I think it would make sense to specify (in comments) that those functions get a converted (to 802.3 framing) skb instead. And then hardcode the frame offsets/header length.
those functions can be used now for 802.11 or 802.3 frames so caller should pass header length for them
Quoted 4 lines
Also, I think the return value of those functions shouldn't be the
txrx_resultbut rather just a bool.
Hmmm... yes, it will probebly look better. i'll just do a slight change in function's names so it will be clearer to reader.
Quoted 12 lines
Quoted 12 lines
static
ieee80211_txrx_resultieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx){ struct ieee80211_key *key;net/mac80211/tx.c +7
-0+const struct ieee80211_hdr *hdr; +u16 fc; +int hdrlen; + + hdr = (const struct ieee80211_hdr *) tx->skb->data; + fc =le16_to_cpu (hdr->frame_control); + hdrlen =ieee80211_get_hdrlen (fc);
Quoted 13 lines
net/mac80211/tx.c ieee80211_tx_h_select_key(struct ieee80211_txrx_data *tx) · line 454
Quoted 8 lines
if (unlikely(tx->u.tx.control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)) tx->key = NULL;net/mac80211/tx.c +1
-1@@ -448,7 +451,7 @@ 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, hdrlen))) {I think it would make sense to have another function
ieee80211_is_eapol_checked(tx->skb)that does the hdrlen calculation to save doing it unconditionally here for the (common) case where we're using a sta or default key.
I agree, thanks for the remark.
Yet, i wouldn't like to add another function that does basically the same as ieee80211_is_eapol (or sending an indication for ieee80211_is_eapol about header type what will lessen its flexsibility)
I was thinking to move ieee80211_get_hdrlen to:ieee80211_is_eapol(tx->skb, ieee80211_get_hdrlen(fc))
this way i keep flexibility in ieee80211_is_eapol and won't calculate header length unless really needed.
Quoted 6 lines
Overall, nice patch.
johannes
Johannes Berg
maintainerQuoted 9 lines
Quoted 5 lines
net/mac80211/ieee80211_i.h extern void *mac80211_wiphy_privid; /* for wiphy privid */ · line 795
Quoted 3 lines
net/mac80211/ieee80211_i.h +1
-1-int ieee80211_is_eapol (const struct sk_buff *skb); +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen);That's just an optimisation, right?
main reason is that
ieee80211_is_eapolis called both in Tx and Rx flows, so the caller is reaponsible for passing the header length (802.3 in Rx and 802.11 in Tx).
Right. I noticed later but forgot to remove the comment.
Quoted 8 lines
Quoted 3 lines
Any reason you're getting rid of the MAC printk? It's a debug-only message so whatever, just curious really.
as
ieee80211_802_1x_paeis not a 802.11 specific any more, it has no knowledge about the header, therefore no knowledge about mac address. I could pass to it the mac address as well, but looks odd to do that only for debug printing.
Oh ok, right.
Quoted 17 lines
Quoted 7 lines
net/mac80211/rx.c ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) · line 1154
Quoted 6 lines
net/mac80211/rx.c +6
-0+if (ieee80211_data_to_8023 (rx) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_802_1x_pae (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_drop_unencrypted (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ;Quoted 5 lines
The
sizeof()doesn't look right, shouldn't that get the hdrlen from the frame control? Ah, no, I see now, it's already converted at this point. Do we need to pass the hdrlen at all then? I think it would make sense to specify (in comments) that those functions get a converted (to 802.3 framing) skb instead. And then hardcode the frame offsets/header length.those functions can be used now for 802.11 or 802.3 frames so caller should pass header length for them
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Also, I think the return value of those functions shouldn't be the
txrx_resultbut rather just a bool.Hmmm... yes, it will probebly look better. i'll just do a slight change in function's names so it will be clearer to reader.
Great, thanks.
Quoted 5 lines
Quoted 4 lines
I think it would make sense to have another function
ieee80211_is_eapol_checked(tx->skb)that does the hdrlen calculation to save doing it unconditionally here for the (common) case where we're using a sta or default key.
Quoted 9 lines
I agree, thanks for the remark.
Yet, i wouldn't like to add another function that does basically the same asieee80211_is_eapol(or sending an indication forieee80211_is_eapolabout header type what will lessen its flexsibility)
I was thinking to moveieee80211_get_hdrlento:ieee80211_is_eapol(tx->skb, ieee80211_get_hdrlen(fc))
this way i keep flexibility inieee80211_is_eapoland won't calculate header length unless really needed.
Oh sure, that works too. I guess you could inline all of it even ieee80211_is_eapol(tx->skb,
ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)))
But yeah, whatever, I'm not concerned about the byteswap.
johannes
Great, so needed changes are on their way, and i will issue tomorrow the A-MSDU patch that uses the new handlers scheme. thanks
ron
Quoted 72 lines
Quoted 8 lines
Quoted 4 lines
net/mac80211/ieee80211_i.h extern void *mac80211_wiphy_privid; /* for wiphy privid */ · line 795
Quoted 2 lines
net/mac80211/ieee80211_i.h +1
-1-int ieee80211_is_eapol (const struct sk_buff *skb); +int ieee80211_is_eapol (const struct sk_buff *skb,int hdrlen);That's just an optimisation, right?
main reason is that
ieee80211_is_eapolis called both in Tx and Rx flows, so the caller is reaponsible for passing the header length (802.3 in Rx and 802.11 in Tx).Right. I noticed later but forgot to remove the comment.
Quoted 8 lines
Quoted 3 lines
Any reason you're getting rid of the MAC printk? It's a debug-only message so whatever, just curious really.
as
ieee80211_802_1x_paeis not a 802.11 specific any more, it has no knowledge about the header, therefore no knowledge about mac address. I could pass to it the mac address as well, but looks odd to do that only for debug printing.Oh ok, right.
Quoted 17 lines
Quoted 7 lines
net/mac80211/rx.c ieee80211_rx_h_data(struct ieee80211_txrx_data *rx) · line 1154
Quoted 6 lines
net/mac80211/rx.c +6
-0+if (ieee80211_data_to_8023 (rx) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_802_1x_pae (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ; +if (ieee80211_drop_unencrypted (rx,sizeof (struct ethhdr )) ==TXRX_DROP ) +return TXRX_DROP ;Quoted 5 lines
The
sizeof()doesn't look right, shouldn't that get the hdrlen from the frame control? Ah, no, I see now, it's already converted at this point. Do we need to pass the hdrlen at all then? I think it would make sense to specify (in comments) that those functions get a converted (to 802.3 framing) skb instead. And then hardcode the frame offsets/header length.those functions can be used now for 802.11 or 802.3 frames so caller should pass header length for them
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Also, I think the return value of those functions shouldn't be the
txrx_resultbut rather just a bool.Hmmm... yes, it will probebly look better. i'll just do a slight change in function's names so it will be clearer to reader.
Great, thanks.
Quoted 5 lines
Quoted 4 lines
I think it would make sense to have another function
ieee80211_is_eapol_checked(tx->skb)that does the hdrlen calculation to save doing it unconditionally here for the (common) case where we're using a sta or default key.Quoted 9 lines
I agree, thanks for the remark.
Yet, i wouldn't like to add another function that does basically the same asieee80211_is_eapol(or sending an indication forieee80211_is_eapolabout header type what will lessen its flexsibility)
I was thinking to moveieee80211_get_hdrlento:ieee80211_is_eapol(tx->skb, ieee80211_get_hdrlen(fc))
this way i keep flexibility inieee80211_is_eapoland won't calculate header length unless really needed.Oh sure, that works too. I guess you could inline all of it even ieee80211_is_eapol(tx->skb,
ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)))But yeah, whatever, I'm not concerned about the byteswap.
johannes