diff mbox

[2/2] mac80211: put upper bound on txqi queue length.

Message ID 1480442753-6830-2-git-send-email-greearb@candelatech.com (mailing list archive)
State Not Applicable
Delegated to: Johannes Berg
Headers show

Commit Message

Ben Greear Nov. 29, 2016, 6:05 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

This fixes OOM when using pktgen to drive a wifi station at more than
the station can transmit.  pktgen uses ndo_start_xmit instead of going
through the queue layer, so it will not back off when the queues are
stopped, and would thus cause packets to be added to the txqi->queue
until the system goes OOM and crashes.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

This is against 4.7.10+, not sure if it is actually needed in latest kernel.

 net/mac80211/tx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Johannes Berg Dec. 5, 2016, 1:56 p.m. UTC | #1
On Tue, 2016-11-29 at 10:05 -0800, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> This fixes OOM when using pktgen to drive a wifi station at more than
> the station can transmit.  pktgen uses ndo_start_xmit instead of
> going
> through the queue layer, so it will not back off when the queues are
> stopped, and would thus cause packets to be added to the txqi->queue
> until the system goes OOM and crashes.
> 
> Signed-off-by: Ben Greear <greearb@candelatech.com>
> ---
> 
> This is against 4.7.10+, not sure if it is actually needed in latest
> kernel.

One would hope that fq_tin_enqueue() does something like that, but
anyway the patch doesn't apply so I'm dropping it.

johannes
Michal Kazior Dec. 5, 2016, 2:05 p.m. UTC | #2
On 5 December 2016 at 14:56, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Tue, 2016-11-29 at 10:05 -0800, greearb@candelatech.com wrote:
>> From: Ben Greear <greearb@candelatech.com>
>>
>> This fixes OOM when using pktgen to drive a wifi station at more than
>> the station can transmit.  pktgen uses ndo_start_xmit instead of
>> going
>> through the queue layer, so it will not back off when the queues are
>> stopped, and would thus cause packets to be added to the txqi->queue
>> until the system goes OOM and crashes.
>>
>> Signed-off-by: Ben Greear <greearb@candelatech.com>
>> ---
>>
>> This is against 4.7.10+, not sure if it is actually needed in latest
>> kernel.
>
> One would hope that fq_tin_enqueue() does something like that, but
> anyway the patch doesn't apply so I'm dropping it.

fq_tin_enqueue() drops "fat" flow head packet upon reaching packet
count limit (8192) or memory limit (4 or 16 mbytes depending on vht
availability) whichever is hit first.


Michał
diff mbox

Patch

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index fbcb5fc..0573ab9 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1293,6 +1293,16 @@  static void ieee80211_drv_tx(struct ieee80211_local *local,
 		goto tx_normal;
 
 	ac = txq->ac;
+
+	if (atomic_read(&sdata->txqs_len[ac]) >=
+	    (local->hw.txq_ac_max_pending * 2)) {
+		/* Must be that something is not paying attention to
+		 * max-pending, like pktgen, so just drop this frame.
+		 */
+		ieee80211_free_txskb(&local->hw, skb);
+		return;
+	}
+
 	txqi = to_txq_info(txq);
 	atomic_inc(&sdata->txqs_len[ac]);
 	if (atomic_read(&sdata->txqs_len[ac]) >= local->hw.txq_ac_max_pending)