Skip to contentSkip to conversation

mac80211: pass in PS_POLL frames

PATCH In review Ron Rindjunsky 3 participants 8 messages Dec 10, 2007 – Dec 18, 2007 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: pass in PS_POLL frames

This patch fixes should_drop_frame function to pass in ps poll control frames required for power save functioanlity. Interface types that do not have interest for PS POLL frames now drop it in handler.

---
 net/mac80211/rx.c   |   10 ++++++++--
 net/mac80211/util.c |    7 ++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
net/mac80211/rx.c +8 -2
index 50f99e7..5dbf5d6 100644
@@ -61,8 +61,10 @@ static inline int should_drop_frame(struct ieee80211_rx_status *status,
 		return 1;
 	if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len))
 		return 1;
-	if ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
-			cpu_to_le16(IEEE80211_FTYPE_CTL))
+	if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
+			cpu_to_le16(IEEE80211_FTYPE_CTL)) &&
+	    ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
+			cpu_to_le16(IEEE80211_STYPE_PSPOLL)))
 		return 1;
 	return 0;
 }
@@ -880,6 +882,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
 static ieee80211_txrx_result
 ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
 {
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
 	struct sk_buff *skb;
 	int no_pending_pkts;
 	DECLARE_MAC_BUF(mac);
@@ -890,6 +893,9 @@ ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
 		   !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)))
 		return TXRX_CONTINUE;
 
+	if (sdata->type == IEEE80211_IF_TYPE_STA)
+		return TXRX_DROP;
+
 	skb = skb_dequeue(&rx->sta->tx_filtered);
 	if (!skb) {
 		skb = skb_dequeue(&rx->sta->ps_tx_buf);
net/mac80211/util.c +6 -1
index 7b278e9..fb7fd89 100644
@@ -135,13 +135,16 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
 {
 	u16 fc;
 
-	if (len < 24)
+	 /* drop ACK/CTS frames and incorrect hdr len (ctrl) */
+	if (len < 16)
 		return NULL;
 
 	fc = le16_to_cpu(hdr->frame_control);
 
 	switch (fc & IEEE80211_FCTL_FTYPE) {
 	case IEEE80211_FTYPE_DATA:
+		if (len < 24) /* drop incorrect hdr len (data) */
+			return NULL;
 		switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
 		case IEEE80211_FCTL_TODS:
 			return hdr->addr1;
@@ -154,6 +157,8 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
 		}
 		break;
 	case IEEE80211_FTYPE_MGMT:
+		if (len < 24) /* drop incorrect hdr len (mgmt) */
+			return NULL;
 		return hdr->addr3;
 	case IEEE80211_FTYPE_CTL:
 		if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
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.
maintainer
#1 lore raw

net/mac80211/rx.c static inline int should_drop_frame(struct ieee80211_rx_status *status, · line 67

Quoted 7 lines
net/mac80211/rx.c +4 -2
-	if ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
-			cpu_to_le16(IEEE80211_FTYPE_CTL))
+	if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
+			cpu_to_le16(IEEE80211_FTYPE_CTL)) &&
+	    ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
+			cpu_to_le16(IEEE80211_STYPE_PSPOLL)))

Hm. Don't we have macros for this?

johannes

#2 lore raw
Quoted 10 lines · Johannes Berg

net/mac80211/rx.c static inline int should_drop_frame(struct ieee80211_rx_status *status, · line 67

Quoted 7 lines
net/mac80211/rx.c +4 -2
-     if ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
-                     cpu_to_le16(IEEE80211_FTYPE_CTL))
+     if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
+                     cpu_to_le16(IEEE80211_FTYPE_CTL)) &&
+         ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
+                     cpu_to_le16(IEEE80211_STYPE_PSPOLL)))

Hm. Don't we have macros for this?

Not in mac80211 as far as I know. There were some in ieee80211. Iwlwifi have them in iwl-helpers.h as inline functions Tomas

#3 lore raw
In reply to Ron Rindjunsky

Hi folks, this patch is a V2 with fixes, and i haven't received any new comments nor Ack for it. I have another patch that depends on this one so i need to know the status for it.
thanks
ron

Quoted 76 lines

This patch fixes should_drop_frame function to pass in ps poll control frames required for power save functioanlity. Interface types that do not have interest for PS POLL frames now drop it in handler.

---
 net/mac80211/rx.c   |   10 ++++++++--
 net/mac80211/util.c |    7 ++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
net/mac80211/rx.c +8 -2
index 50f99e7..5dbf5d6 100644
@@ -61,8 +61,10 @@ static inline int should_drop_frame(struct ieee80211_rx_status *status,
               return 1;
       if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len))
               return 1;
-       if ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
-                       cpu_to_le16(IEEE80211_FTYPE_CTL))
+       if (((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
+                       cpu_to_le16(IEEE80211_FTYPE_CTL)) &&
+           ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE)) !=
+                       cpu_to_le16(IEEE80211_STYPE_PSPOLL)))
               return 1;
       return 0;
 }
@@ -880,6 +882,7 @@ ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
 static ieee80211_txrx_result
 ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
 {
+       struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
       struct sk_buff *skb;
       int no_pending_pkts;
       DECLARE_MAC_BUF(mac);
@@ -890,6 +893,9 @@ ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
                  !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)))
               return TXRX_CONTINUE;
 
+       if (sdata->type == IEEE80211_IF_TYPE_STA)
+               return TXRX_DROP;
+
       skb = skb_dequeue(&rx->sta->tx_filtered);
       if (!skb) {
               skb = skb_dequeue(&rx->sta->ps_tx_buf);
net/mac80211/util.c +6 -1
index 7b278e9..fb7fd89 100644
@@ -135,13 +135,16 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
 {
       u16 fc;
 
-       if (len < 24)
+        /* drop ACK/CTS frames and incorrect hdr len (ctrl) */
+       if (len < 16)
               return NULL;
 
       fc = le16_to_cpu(hdr->frame_control);
 
       switch (fc & IEEE80211_FCTL_FTYPE) {
       case IEEE80211_FTYPE_DATA:
+               if (len < 24) /* drop incorrect hdr len (data) */
+                       return NULL;
               switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
               case IEEE80211_FCTL_TODS:
                       return hdr->addr1;
@@ -154,6 +157,8 @@ u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
               }
               break;
       case IEEE80211_FTYPE_MGMT:
+               if (len < 24) /* drop incorrect hdr len (mgmt) */
+                       return NULL;
               return hdr->addr3;
       case IEEE80211_FTYPE_CTL:
               if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
maintainer
#4 lore raw
In reply to Ron Rindjunsky

Ron, sorry, totally forgot about this patch after asking about the macro that doesn't seem to exist after all.

Quoted 3 lines · Ron Rindjunsky

This patch fixes should_drop_frame function to pass in ps poll control frames required for power save functioanlity. Interface types that do not have interest for PS POLL frames now drop it in handler.

Taking a closer look...

net/mac80211/rx.c ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) · line 897

Quoted 2 lines
net/mac80211/rx.c +2 -0
+	if (sdata->type == IEEE80211_IF_TYPE_STA)
+		return TXRX_DROP;

Should we maybe do the test explicitly for when we want it, i.e. AP/VLAN/IBSS cases? Just thinking of the mesh networking stuff etc. that's being added...

Other than that, looks fine.

johannes

#5 lore raw
Quoted 6 lines

net/mac80211/rx.c ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) · line 897

Quoted 2 lines
net/mac80211/rx.c +2 -0
+     if (sdata->type == IEEE80211_IF_TYPE_STA)
+             return TXRX_DROP;

Should we maybe do the test explicitly for when we want it, i.e. AP/VLAN/IBSS cases? Just thinking of the mesh networking stuff etc. that's being added...

no problem, i'll send it over. currently i see only AP mode as relevant.

Quoted 6 lines

Other than that, looks fine.

johannes

maintainer
#6 lore raw
Quoted 8 lines · Ron Rindjunsky
Quoted 6 lines

net/mac80211/rx.c ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) · line 897

Quoted 2 lines
net/mac80211/rx.c +2 -0
+     if (sdata->type == IEEE80211_IF_TYPE_STA)
+             return TXRX_DROP;

Should we maybe do the test explicitly for when we want it, i.e. AP/VLAN/IBSS cases? Just thinking of the mesh networking stuff etc. that's being added...

no problem, i'll send it over. currently i see only AP mode as relevant.

But I think that if we have a station in a VLAN then we'll have the VLAN interface at this point, no? I guess we really need to test that anyway, I wish hostapd could do VLANs without RADIUS.

johannes

#7 lore raw
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

net/mac80211/rx.c ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx) · line 897

Quoted 3 lines
net/mac80211/rx.c +2 -0
+     if (sdata->type == IEEE80211_IF_TYPE_STA)
+             return TXRX_DROP;

Should we maybe do the test explicitly for when we want it, i.e. AP/VLAN/IBSS cases? Just thinking of the mesh networking stuff etc. that's being added...

no problem, i'll send it over. currently i see only AP mode as

relevant.

Quoted 1 line

But I think that if we have a station in a VLAN then we'll have the

VLAN

Quoted 1 line

interface at this point, no? I guess we really need to test that

anyway,

Quoted 1 line

I wish hostapd could do VLANs without RADIUS.

Agree, I will add the VLAN as well.

---------------------------------------------------------------------
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.