提交 2a8a9a88 编写于 作者: J Johannes Berg 提交者: David S. Miller

[MAC80211]: avoid copying packets to interfaces that are down

David Woodhouse noticed that under some circumstances the number of slab
allocations kept growing. After looking a bit, this seemed to happen
when you had a management mode interface that was *down*.

The reason for this is that when the device is down, all management
frames get queued to the in-kernel MLME (via ieee80211_sta_rx_mgmt) but
then the sta work is invoked but doesn't run when the netif is down.
When you then bring the interface up, all such frames are freed, but if
you change the mode all of them are lost because the skb queue is
reinitialised as soon as you go back to managed mode. The skb queue is
correctly cleared when the interface is brought down, but the code
doesn't account for the fact that it may be filled while it is not up.

This patch should fix the issue by simply ignoring all interfaces that
are down when going through the RX handlers.
Signed-off-by: NJohannes Berg <johannes@sipsolutions.net>
Acked-by: NMichael Wu <flamingice@sourmilk.net>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 4b6aa599
...@@ -493,7 +493,16 @@ static void ieee80211_if_shutdown(struct net_device *dev) ...@@ -493,7 +493,16 @@ static void ieee80211_if_shutdown(struct net_device *dev)
case IEEE80211_IF_TYPE_IBSS: case IEEE80211_IF_TYPE_IBSS:
sdata->u.sta.state = IEEE80211_DISABLED; sdata->u.sta.state = IEEE80211_DISABLED;
del_timer_sync(&sdata->u.sta.timer); del_timer_sync(&sdata->u.sta.timer);
/*
* Holding the sub_if_lock for writing here blocks
* out the receive path and makes sure it's not
* currently processing a packet that may get
* added to the queue.
*/
write_lock_bh(&local->sub_if_lock);
skb_queue_purge(&sdata->u.sta.skb_queue); skb_queue_purge(&sdata->u.sta.skb_queue);
write_unlock_bh(&local->sub_if_lock);
if (!local->ops->hw_scan && if (!local->ops->hw_scan &&
local->scan_dev == sdata->dev) { local->scan_dev == sdata->dev) {
local->sta_scanning = 0; local->sta_scanning = 0;
......
...@@ -1380,6 +1380,9 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -1380,6 +1380,9 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
list_for_each_entry(sdata, &local->sub_if_list, list) { list_for_each_entry(sdata, &local->sub_if_list, list) {
rx.u.rx.ra_match = 1; rx.u.rx.ra_match = 1;
if (!netif_running(sdata->dev))
continue;
prepres = prepare_for_handlers(sdata, bssid, &rx, hdr); prepres = prepare_for_handlers(sdata, bssid, &rx, hdr);
/* prepare_for_handlers can change sta */ /* prepare_for_handlers can change sta */
sta = rx.sta; sta = rx.sta;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册