From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=LT3NVOao; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id CEF985A068E for ; Wed, 07 Jan 2026 01:17:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1767745075; bh=U4VaIJnV1TFsYU/ZDkR43daKvkwqEfR1/UDTSdklaNg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LT3NVOao7RSZuFg4JuJktfNXgFsOw1QHECBOqQ0AV188BFoQHbZVCJXvBRuYWSy33 Z+x5dueRd4CUbiFOF7vGJVednRw0mVreq+xCZSJxx2cCav0KxMhYb1rFJsKBRi4Kae IJf3ClB5LoKA1UM/8HZqVcIxthPz2vHHZu8RX+xv2DOCENydzI/LwzqUhp58Q4HloU nYOaEqcvJfaVz27uxNgCKmTqZAqw0GA7JC35t0uPtq1PnUjxAlqfKqGn23XbYN9Ghm OY+uzP7jb1EpJ9moYnMegWlsB1yaRv7DBzf3AEBwF9Rii5ktbs7GI+ZZwiQppOmEBE eVO58tdH9GhJw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dm7sb3vtlz4wQd; Wed, 07 Jan 2026 11:17:55 +1100 (AEDT) Date: Wed, 7 Jan 2026 11:17:51 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH] udp_vu: Discard datagrams when RX virtqueue is not usable Message-ID: References: <20260105145016.394828-1-lvivier@redhat.com> <92742f50-f095-45af-b43b-4d49254886f6@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="mB8OdZTeDNAX2xs/" Content-Disposition: inline In-Reply-To: <92742f50-f095-45af-b43b-4d49254886f6@redhat.com> Message-ID-Hash: RZRDSDOBLIXD5QG7DZXTUAZOWSQ3LLG6 X-Message-ID-Hash: RZRDSDOBLIXD5QG7DZXTUAZOWSQ3LLG6 X-MailFrom: dgibson@gandalf.ozlabs.org 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: passt-dev@passt.top 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: --mB8OdZTeDNAX2xs/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 06, 2026 at 08:48:31AM +0100, Laurent Vivier wrote: > On 1/6/26 00:28, David Gibson wrote: > > On Mon, Jan 05, 2026 at 03:50:16PM +0100, Laurent Vivier wrote: > > > During vhost-user device initialization, UDP datagrams may arrive on > > > listening sockets before the guest has enabled the RX virtqueue. > > >=20 > > > 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. > > >=20 > > > 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. > > >=20 > > > Fixes: 28997fcb29b5 ("vhost-user: add vhost-user") > > > Link: https://bugs.passt.top/show_bug.cgi?id=3D185 > > > Signed-off-by: Laurent Vivier > >=20 > > My only concern here is that this will only consume a single datagram, > > whereas it looks like the loop could consume multiple datagrams. I'm > > guessing something higher up will keep calling this until the queue is > > empty, but I'm not certain. Otherwise LGTM. >=20 > I can move the change into udp_vu_sock_recv() (inside the datagram loop),= it > will be closer to what udp_buf_sock_to_tap() does: reads data with > udp_sock_recv() and if fd_tap is not initialized tap_send_frames() drops > them. That seems a little safer (or at least, more obviously safe) to me. --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --mB8OdZTeDNAX2xs/ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmldpi4ACgkQzQJF27ox 2Gf3PBAAgK4uLgtrxnkIdjqzx/7TNxer0LXbP4Cdg6g6uQViJ+2O4PrULd9uvp7g dEq6YzKpTmZoY+ruVg9Ez1EM6UF3kxmB8J6bJteN7wwyoyIfkE5+IJwD/poAMhzp j4gu7NAnCtdSLJiAsTW693SGiCC5cFaVZnfXqBKUR2FCDvlS4IVt5r6IIT43AiG7 mdfimHDBfyNwMfYdPLWXWTbJ0sQezlRChyNoOiOy4T/pnwQP48hXX3xuIuLpATg4 TKkimlzoDBjbT2YX/c2hWOTGUjv36rKSgine9dtzXt/tPM2F24TP/SNGoOCOsDqT zMpMSgb/zwYwsj67SZKaBUrzwzPM0tX1tN7sgHlxBnnceE2TWFW19I0ioYj4wLSQ gQaY1pyD8qFQU/Ir4wu2mc2cErfTkrmGcwnU8iwdWGRl08FowTVazm8XldURTveN isA1zcAWbVP9HkozMk9xzu11OLpaEqo1DTImT2+ni06Qg5IL8ZVRxVQ42bwXEjzz 9WTy/wT2BwEMVHMOzqrAXfO1nR17yUjIBcO7DFQN+kSTmhCk6yqSFvxl5bBK0s6s VqeHkdDmW2UDfgDmQb/PoZUKXBvbRTMMF3/Z7P6oNN9joIWJITjRG0n9bWTYNNOP tdRintK1u/be0cryL5m6iMLaAHqtmEGaMJ1GTpifmJn8d5Lykpc= =SDDE -----END PGP SIGNATURE----- --mB8OdZTeDNAX2xs/--