From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385155; b=5Vo65NtPOammcyJoli4q3hpm6hsw5ckLlDw4nHRebjlhZW78Hoeq2/KwRbSFsQ5oN8ua sxqLOQJARuS9uShEP2bh78GNTvzW7Yak0CNK9ngppk4g1Yk/uAQkz3AxfkfnDy92Nl4Uc zMyfHvkB4rhZAmdunkTfOJ45/yohgpTJFeeh6/mfD6Kj+fKzMcPCVXO2n3qUijBNC6Hj1 Kq4XC/wyb7ZgFWABmQ3hTysTAxsKRKrCrJX0R54IvhvnEnmcPAPxJcuDoZq/MQEfGgRco gsL0LH2ZfjEU4PZ/m6HsXHpOlzWZYHdlXa+hKhMmFLDJIz24MRDEeOLONRjIss2vLxA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385155; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=GBmNLZTyxmxPO1qcnCY+1sWNJ2dND4/CIqEgmYpHa1o=; b=mFG7GpruIo65WkjvJWYusLgMimh6z/C2ynpVH5gfRxuR44EQl6kOCbkJ5XyOoDTbPb5a ycc6GGesPqpQ+M3BmewaY6UZRtsV7bi0Zg6ixb00QEG5UkyCfHAlhx1A5WH9lx8D0RcG2 OQBMQ+O0NjImsDVeXOCF1UvooIMS/EBWS0E3i65zqs9bNVBXiNNG9IufZeWa9WBZNdvBQ mYE89DgYYDscBwLhv4tOmEm5wxUkexhO4mLE+TrjP0pDN8qChag+bp5iOaAZiGSPf7vnD rCRHMJINaISD51baVDCS7AMDNCIPqNx1oJFc/DAjus3399o05X8w7BeyWjtYdLuTyTg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=iSAgugpN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4648606A332; Fri, 4 Dec 2026 11:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=iSAgugpN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 581021F0092C; Fri, 4 Dec 2026 11:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385155; bh=GBmNLZTyxmxPO1qcnCY+1sWNJ2dND4/CIqEgmYpHa1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iSAgugpNWWFqEJ1XZoiVP7usWOhqmTXBUUXYQmbS0gqHHwDw/miYuTm5y3JpaIGB/ lzcy6QBjC/ycFzhd0HJrV0iJBSO/tEVMRv/IcO2JmeRIG17P8QNe5HefHIIiHiy7ur SJr42978R3zwJRtdkKAfHWt4Q7LomhsoksUGd1j4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiayuan Chen , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Toshiaki Makita , Lorenzo Bianconi , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6 0414/1167] veth: clear rx queue hint in veth_xmit Date: Fri, 4 Dec 2026 18:57:21 +0900 Message-ID: <20261204100712.809314504@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiayuan Chen [ Upstream commit 1b1c0e87cfe78d731bbab99c9c018655980b6790 ] With more tx queues on one end of a veth pair than rx queues on the other, and RPS or generic XDP enabled on the receiving end, we get: veth1 received packet on queue 2, but number of RX queues is 2 WARNING: net/core/dev.c:5212 at get_rps_cpu+0x560/0x1360 Call Trace: netif_rx_internal+0x1af/0x4c0 __netif_rx+0x99/0x350 veth_xmit+0x713/0xca0 dev_hard_start_xmit+0x166/0x5f0 __dev_queue_xmit+0x1797/0x42d0 ip_finish_output2+0xa34/0x1f40 __ip_finish_output+0x510/0x7e0 ip_finish_output+0x2f/0x320 ip_output+0x17a/0x3f0 ip_send_skb+0x1bc/0x220 ...... Easy to hit with "ethtool -L veth0 tx 4", "ethtool -L veth1 rx 2", rps_cpus set on veth1 and a few flows sent over the pair [1]. veth_xmit() uses skb->queue_mapping to pick the peer rq, but never clears it before veth_forward_skb(), so the rx side still sees the tx queue index. Everything on the rx side that goes through skb_get_rx_queue(), like get_rps_cpu() and netif_get_rxqueue() for generic XDP, takes it as a recorded rx queue and warns once it is out of range. Clear it before handing the skb to the peer: - It is the tx queue index of this device, it says nothing about the rx queue of the peer. - The two sides don't even agree on the encoding. The tx side stores the index as is, the rx side stores index + 1 so that 0 can mean "not recorded". So tx queue k is read back as rx queue k - 1, and tx queue 0 as "not recorded". - Commit 710ad98c363a ("veth: Do not record rx queue hint in veth_xmit") already decided that veth should not pass any queue hint to the peer. There is no tx->rx queue mapping to preserve, so nothing is lost by clearing it. On NETDEV_TX_BUSY the skb goes back to the qdisc, which looks up the txq from skb->queue_mapping to decide when to retry, so restore it there, next to the existing __skb_push(). [1]: https://lore.kernel.org/netdev/156834bb-8e40-496e-9443-9d515fa18eab@linux.dev/ Fixes: 76ff5cc91935 ("rtnl: allow to specify number of rx and tx queues on device creation") Signed-off-by: Jiayuan Chen Reviewed-by: Björn Töpel Reviewed-by: Toshiaki Makita Reviewed-by: Lorenzo Bianconi Link: https://patch.msgid.link/20261009040412.14571-1-jiayuan.chen@linux.dev Signed-off-by: Paolo Abeni [ sashal: Added the skb_set_queue_mapping(skb, 0) clear before forwarding, but dropped the NETDEV_TX_BUSY queue-mapping restore because this tree's veth_xmit() has no such path. ] Signed-off-by: Sasha Levin --- drivers/net/veth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 486eea7d060ec..1a8ff02fb050c 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -375,6 +375,10 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) } skb_tx_timestamp(skb); + + /* tx queue index of this device, meaningless as rx queue of the peer */ + skb_set_queue_mapping(skb, 0); + if (likely(veth_forward_skb(rcv, skb, rq, use_napi) == NET_RX_SUCCESS)) { if (!use_napi) dev_sw_netstats_tx_add(dev, 1, length); -- 2.53.0