From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KVy0P2oJ; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 5AFBA5A0624 for ; Mon, 05 Jan 2026 15:50:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767624621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DQlrjzr4vHVKPjYAXHcKtqSP+rIVxoZhFfS+wu2miW0=; b=KVy0P2oJX0OIc61izrNOUTRgUcoe9R70so5PhzoZXBiHuAezMF3cxCcJJVtMrIeRRxCLPA 4nQq+nPHGP+4O/EFGDyykWW3KxAbxiZPzX7GoKfpXlvzzFrEb6TH0ydEP4SByYd+SqcNDD P40PbNq7a2ID2Ex4E+2kOl8NzsJ+3/4= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-rlvlgG55P0qtN_-Cfqy1ZQ-1; Mon, 05 Jan 2026 09:50:20 -0500 X-MC-Unique: rlvlgG55P0qtN_-Cfqy1ZQ-1 X-Mimecast-MFC-AGG-ID: rlvlgG55P0qtN_-Cfqy1ZQ_1767624619 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D3CA195F156 for ; Mon, 5 Jan 2026 14:50:19 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.45.225.173]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 12B0E19560A7; Mon, 5 Jan 2026 14:50:17 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH] udp_vu: Discard datagrams when RX virtqueue is not usable Date: Mon, 5 Jan 2026 15:50:16 +0100 Message-ID: <20260105145016.394828-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Jus1BAZnGkPyaGRKqiaZMeY2rf8-IlLiSClSLJwBv_w_1767624619 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: FIONJG64QAJQMHOE7ZXUA3HUD63MT2DK X-Message-ID-Hash: FIONJG64QAJQMHOE7ZXUA3HUD63MT2DK X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: During vhost-user device initialization, UDP datagrams may arrive on listening sockets before the guest has enabled the RX virtqueue. When this happens, udp_vu_sock_recv() returns 0 without consuming the datagram from the socket. The caller, udp_sock_fwd(), uses a while loop with udp_peek_addr() to process pending datagrams. Since the datagram remains in the socket buffer, udp_peek_addr() keeps returning data available, causing a busy loop with 100% CPU usage. Add an early check for virtqueue readiness in udp_vu_sock_to_tap(), mirroring tcp_vu_data_from_sock(). When the queue is not enabled or not started, explicitly discard the datagram with recvmsg() and return. The caller will drain remaining datagrams through repeated calls. Fixes: 28997fcb29b5 ("vhost-user: add vhost-user") Link: https://bugs.passt.top/show_bug.cgi?id=185 Signed-off-by: Laurent Vivier --- udp_vu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/udp_vu.c b/udp_vu.c index c30dcf97698f..67f4ee619bfb 100644 --- a/udp_vu.c +++ b/udp_vu.c @@ -211,6 +211,17 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx) struct vu_virtq *vq = &vdev->vq[VHOST_USER_RX_QUEUE]; int i; + if (!vu_queue_enabled(vq) || !vu_queue_started(vq)) { + struct msghdr msg = { 0 }; + + debug("Got UDP packet, but RX virtqueue not usable yet"); + + if (recvmsg(s, &msg, MSG_DONTWAIT) < 0) + debug_perror("Failed to discard datagram"); + + return; + } + for (i = 0; i < n; i++) { ssize_t dlen; int iov_used; -- 2.52.0