From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D48743E4510; Mon, 17 Aug 2026 13:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786974472; cv=none; b=JNf8KkYVTRcBqbSTNnSCfZ//7hJ3LBEwR6iV1+4h3y++fL0hj92HfErH9lnL42rFyVE7cxIh9fWIyUV3ze07rdxchljsF4wTgxiJB4HXD3+NG9Nj00Dv2t0lKZbto4WC5fMWSbe3715HBHz8cXz+Ms6KpcQ2aW/EznxAdUwXQII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786974472; c=relaxed/simple; bh=r/IAXfj8CqtFBcEefPeASxdeDq5YwtN16Z4B+10zQYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=llriatuyFqyjSUeWsdsiZcIWyK+pEygGXUFPn/mYMhgvO5YV4WzPBSgEE4sTv9Uvnv44Ljgqe15HQkSlpvG+NqyjbPNl92CGwk97VigCzYwRq0D+3FbymVOnmBuwiREOrNZnfd47BBMtphXKYzW9cUR9vZS+QSmUuKraTNrwU3o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oFJMqiSB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oFJMqiSB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A2EF1F00A3F; Mon, 17 Aug 2026 13:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786974469; bh=i9YMyhVzGc11S6ZUJpwR/GUv9O33kyUfMREMDW2JVxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oFJMqiSB6HQIEN11LsxYrkDJnIOS8l3AWiSsO7rIVyHpI+JjLciGfScRssL4dTZQa 8qBzZijq+Fn/f2b3UKSYWLMraHOCBPiLCxshnEew/9pANfP6yOIWxTQCdp7JN0OOqa CSD2OpJjKkiApBmKWQL17QBGJNkV5ey6oTQ3Iihg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Koichiro Den , Dave Jiang , Paolo Abeni Subject: [PATCH 7.1 217/271] NTB: ntb_netdev: Preserve RX queue depth on allocation failure Date: Mon, 17 Aug 2026 15:32:22 +0200 Message-ID: <20260817132545.703042742@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132536.752504388@linuxfoundation.org> References: <20260817132536.752504388@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Koichiro Den commit d2121faf133ac3bf9531b53a7e21273649a08517 upstream. ntb_netdev_rx_handler() hands the received skb to the network stack before allocating its replacement. If the allocation fails, nothing is reposted. Every failure therefore takes one buffer out of the RX queue while the interface remains up, and enough failures eventually stall reception. A retry path could refill the queue later, but ntb_netdev has none. Allocate the replacement first instead. If that fails, drop the packet and repost the same skb. This keeps the queue full and lets packet delivery resume as soon as memory is available again. Fixes: 548c237c0a99 ("net: Add support for NTB virtual ethernet device") Cc: stable@vger.kernel.org Signed-off-by: Koichiro Den Reviewed-by: Dave Jiang Link: https://patch.msgid.link/20260806032537.3526498-1-den@valinux.co.jp Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- drivers/net/ntb_netdev.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/drivers/net/ntb_netdev.c +++ b/drivers/net/ntb_netdev.c @@ -127,8 +127,8 @@ static void ntb_netdev_rx_handler(struct { struct ntb_netdev_queue *q = qp_data; struct ntb_netdev *dev = q->ntdev; + struct sk_buff *skb, *new_skb; struct net_device *ndev; - struct sk_buff *skb; int rc; ndev = dev->ndev; @@ -144,6 +144,12 @@ static void ntb_netdev_rx_handler(struct goto enqueue_again; } + new_skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN); + if (!new_skb) { + ndev->stats.rx_dropped++; + goto enqueue_again; + } + skb_put(skb, len); skb->protocol = eth_type_trans(skb, ndev); skb->ip_summed = CHECKSUM_NONE; @@ -157,12 +163,7 @@ static void ntb_netdev_rx_handler(struct ndev->stats.rx_bytes += len; } - skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN); - if (!skb) { - ndev->stats.rx_errors++; - ndev->stats.rx_frame_errors++; - return; - } + skb = new_skb; enqueue_again: rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN);