From: Ben Greear <gree...@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 <gree...@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(+) 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) -- 2.4.11