All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv6 0/2] mac80211: fix VLAN support on AP with ps-sta
@ 2013-02-13 15:49 Michael Braun
  2013-02-13 15:49 ` [PATCHv6 1/2] mac80211: free ps->bc_buf skbs on vlan device stop Michael Braun
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael Braun @ 2013-02-13 15:49 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, projekt-wlan, Michael Braun

When sending a broadcast while at least on of the connected stations is
sleeping, it gets queued and send after a DTIM beacon is sent.
If the packet was to be sent on a vlan interface, the vif used for dequeing
from the per-bss queue does not hold the per-vlan sdata. The correct sdata is
required to use the correct per-vlan broadcast/multicast key.

Users are affected by not receiving the broadcasts indended for them, which for
example breaks ipv6 autoconf and therefore ipv6 connectivity. Further, they
might be affected as packets might be disclosed to non-intended stas, though
mixing vlan and non-vlan stas might be rare.
This problem is triggered more often by smartphones (which enabled me to track
it down) as they power sleep more often (I guess), but a single sleeping sta on
the ap stops the packet for all connected stas of the ap.
The problem exists in older kernels (at least 3.3.7) as well.

The following patch fixes this by restoring the per-vlan sdata using the
skb->dev entry.

This patch works for me with the vlan-interface within a bridge.
Is the bc_buf cleanup safe this way or does it need locks?

Would it be better to maintain the power sleeping state of the stas on a
per-interface basis, as this would permit one group of non-sleeping stas to
receive while another group has sleeping stas? Of course this would not
prevent non-targetted groups of stas to be waked up, but implementing the
latter sounds difficult to me.

Thanks to Johannes Berg for his help with this patch series.

Example old backtrace:

Using good key:
[ 301.020467] ieee80211_subif_start_xmit:2000 wlan0_2.501: multicast packet to 33:33:00:00:00:01
[ 301.029146] ieee80211_tx_prepare:1174 wlan0_2.501: multicast packet to 33:33:00:00:00:01
[ 301.037249] ieee80211_tx:1442 wlan0_2.501: multicast packet to 33:33:00:00:00:01
[ 301.044688] wlan0_2.501: packet to 33:33:00:00:00:01 using key type CCMP idx 1 len 16 data de 46 7b 31 4f a3 13 8b 88 0b 4e fb 3f 77 d0 18

Using wrong key:
[ 305.000447] ieee80211_subif_start_xmit:2000 wlan0_2.501: multicast packet to 33:33:00:00:00:01
[ 305.009136] ieee80211_tx_prepare:1174 wlan0_2.501: multicast packet to 33:33:00:00:00:01
[ 305.017238] ieee80211_tx:1442 wlan0_2.501: multicast packet to 33:33:00:00:00:01
[ 305.171713] ieee80211_tx_prepare:1174 wlan0: multicast packet to 33:33:00:00:00:01
[ 305.179314] ieee80211_get_buffered_bc:2797 wlan0: multicast packet to 33:33:00:00:00:01
[ 305.187359] wlan0: packet to 33:33:00:00:00:01 using key type CCMP idx 1 len 16 data ca 85 0f 27 80 78 83 09 49 7a fb c8 c4 dc 45 aa

Example new backtrace:
[ 3157.866478] ieee80211_subif_start_xmit:2000 wlan0_2.501: multicast packet to 33:33:00:00:00:16
[ 3157.875129] ieee80211_tx_prepare:1174 wlan0_2.501: multicast packet to 33:33:00:00:00:16
[ 3157.883227] ieee80211_tx:1442 wlan0_2.501: multicast packet to 33:33:00:00:00:16
[ 3157.916991] ieee80211_tx_prepare:1174 wlan0_2.501: multicast packet to 33:33:00:00:00:16
[ 3157.925111] ieee80211_get_buffered_bc:2798 wlan0_2.501: multicast packet to 33:33:00:00:00:16
[ 3157.933667] wlan0_2.501: packet to 33:33:00:00:00:16 using key type CCMP idx 1 len 16 data  2d 06 89 89 27 74 3e e6 53 22 4b d4 5e 50 c0 39

Michael Braun (2):
  mac80211: free ps->bc_buf skbs on vlan device stop
  mac80211: fix WPA with VLAN on AP side with ps-sta

 net/mac80211/iface.c |   14 ++++++++++++++
 net/mac80211/tx.c    |    1 +
 2 files changed, 15 insertions(+)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv6 1/2] mac80211: free ps->bc_buf skbs on vlan device stop
  2013-02-13 15:49 [PATCHv6 0/2] mac80211: fix VLAN support on AP with ps-sta Michael Braun
@ 2013-02-13 15:49 ` Michael Braun
  2013-02-13 15:49 ` [PATCHv6 2/2] mac80211: fix WPA with VLAN on AP side with ps-sta Michael Braun
  2013-02-13 22:42 ` [PATCHv6 0/2] mac80211: fix VLAN support on AP " Johannes Berg
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Braun @ 2013-02-13 15:49 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, projekt-wlan, Michael Braun

When the vlan device is removed, ps->bc_buf processing can no longer
send its frames.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
---
V4: Add this patch.
V5: add spin_lock, switch order of patches
V6: use ieee80211_free_txskb

 net/mac80211/iface.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 40ff030..c1411f0 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -680,6 +680,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
 	struct sk_buff *skb, *tmp;
 	u32 hw_reconf_flags = 0;
 	int i, flushed;
+	struct ps_data *ps;
 
 	clear_bit(SDATA_STATE_RUNNING, &sdata->state);
 
@@ -758,6 +759,19 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
 					 u.vlan.list)
 			dev_close(vlan->dev);
 		WARN_ON(!list_empty(&sdata->u.ap.vlans));
+	} else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
+		/* remove all packets in parent bc_buf pointing to this dev */
+		ps = &sdata->bss->ps;
+
+		spin_lock_irqsave(&ps->bc_buf.lock, flags);
+		skb_queue_walk_safe(&ps->bc_buf, skb, tmp) {
+			if (skb->dev == sdata->dev) {
+				__skb_unlink(skb, &ps->bc_buf);
+				local->total_ps_buffered--;
+				ieee80211_free_txskb(&local->hw, skb);
+			}
+		}
+		spin_unlock_irqrestore(&ps->bc_buf.lock, flags);
 	} else if (sdata->vif.type == NL80211_IFTYPE_STATION) {
 		ieee80211_mgd_stop(sdata);
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCHv6 2/2] mac80211: fix WPA with VLAN on AP side with ps-sta
  2013-02-13 15:49 [PATCHv6 0/2] mac80211: fix VLAN support on AP with ps-sta Michael Braun
  2013-02-13 15:49 ` [PATCHv6 1/2] mac80211: free ps->bc_buf skbs on vlan device stop Michael Braun
@ 2013-02-13 15:49 ` Michael Braun
  2013-02-13 22:42 ` [PATCHv6 0/2] mac80211: fix VLAN support on AP " Johannes Berg
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Braun @ 2013-02-13 15:49 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, projekt-wlan, Michael Braun

When sending a broadcast while at least on of the connected stations is
sleeping, it gets queued and send after a DTIM beacon is sent.
If the packet was to be sent on a vlan interface, the vif used for dequeing
from the per-bss queue does not hold the per-vlan sdata. The correct sdata is
required to use the correct per-vlan broadcast/multicast key.

This patch fixes this by restoring the per-vlan sdata using the skb->dev entry.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
---
V2: fix compile warning
V3: simplify change
 net/mac80211/tx.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index f476aa6..71385bf 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2785,6 +2785,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
 				cpu_to_le16(IEEE80211_FCTL_MOREDATA);
 		}
 
+		sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev);
 		if (!ieee80211_tx_prepare(sdata, &tx, skb))
 			break;
 		dev_kfree_skb_any(skb);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCHv6 0/2] mac80211: fix VLAN support on AP with ps-sta
  2013-02-13 15:49 [PATCHv6 0/2] mac80211: fix VLAN support on AP with ps-sta Michael Braun
  2013-02-13 15:49 ` [PATCHv6 1/2] mac80211: free ps->bc_buf skbs on vlan device stop Michael Braun
  2013-02-13 15:49 ` [PATCHv6 2/2] mac80211: fix WPA with VLAN on AP side with ps-sta Michael Braun
@ 2013-02-13 22:42 ` Johannes Berg
  2 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2013-02-13 22:42 UTC (permalink / raw)
  To: Michael Braun; +Cc: linville, linux-wireless, projekt-wlan

On Wed, 2013-02-13 at 16:49 +0100, Michael Braun wrote:

> Michael Braun (2):
>   mac80211: free ps->bc_buf skbs on vlan device stop
>   mac80211: fix WPA with VLAN on AP side with ps-sta

Applied both, thanks.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-13 22:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-13 15:49 [PATCHv6 0/2] mac80211: fix VLAN support on AP with ps-sta Michael Braun
2013-02-13 15:49 ` [PATCHv6 1/2] mac80211: free ps->bc_buf skbs on vlan device stop Michael Braun
2013-02-13 15:49 ` [PATCHv6 2/2] mac80211: fix WPA with VLAN on AP side with ps-sta Michael Braun
2013-02-13 22:42 ` [PATCHv6 0/2] mac80211: fix VLAN support on AP " Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.