From patchwork Tue Nov 29 18:05:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 9452895 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41FE76071C for ; Tue, 29 Nov 2016 18:06:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ED66283ED for ; Tue, 29 Nov 2016 18:06:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23630283F7; Tue, 29 Nov 2016 18:06:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB12A283F7 for ; Tue, 29 Nov 2016 18:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755412AbcK2SGA (ORCPT ); Tue, 29 Nov 2016 13:06:00 -0500 Received: from mail2.candelatech.com ([208.74.158.173]:56034 "EHLO mail2.candelatech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754392AbcK2SF6 (ORCPT ); Tue, 29 Nov 2016 13:05:58 -0500 Received: from ben-dt3.candelatech.com (firewall.candelatech.com [50.251.239.81]) by mail2.candelatech.com (Postfix) with ESMTP id DC56940BF02; Tue, 29 Nov 2016 10:05:57 -0800 (PST) From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Ben Greear Subject: [PATCH 2/2] mac80211: put upper bound on txqi queue length. Date: Tue, 29 Nov 2016 10:05:53 -0800 Message-Id: <1480442753-6830-2-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1480442753-6830-1-git-send-email-greearb@candelatech.com> References: <1480442753-6830-1-git-send-email-greearb@candelatech.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Greear 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 --- 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)