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=202410 header.b=bDp4xAEd; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 5BE9F5A004C for ; Tue, 26 Nov 2024 05:22:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1732594961; bh=U8Dp8Icko8KyemYswvYHyfR6GpQY6kY5PGB2w1ApJ0Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bDp4xAEd+DRsbLaPPgVK+LBapUNfhU46+hzNIdBpLVykgAxcDxG6bHPj5DNeOEjZE qWYiq8JdKjwyOQf6+led4dHl65A32KI9dsMG+BxN9HdkUPERdqTxniwxLyPa6j1QFN uOwjJzJe5WYFFVY4QEk8/azuTnbxndBmFaRSTWc/Sj2h/msdqfLPuflmqmVfHhbIRt mZh0/jn/GNmZ1RLpIh/LJjQVScLJLcDk23X/TcFQ1xpItp2yIjITq/Ngl8bVphSKQw GgANHWtqLeaUe+FguZOKTZqQGLPQloFlsHMK1RFar4TrYV3RLMc1mAaqsF2wO2Zx2g 3SD5CThJLU8MQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Xy8Ys2HXTz4xfv; Tue, 26 Nov 2024 15:22:41 +1100 (AEDT) Date: Tue, 26 Nov 2024 15:22:38 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] ndp: Don't send first periodic router advertisement right after guest connects Message-ID: References: <20241125080905.118341-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ksHZ9AhxcxE5PB+x" Content-Disposition: inline In-Reply-To: <20241125080905.118341-1-sbrivio@redhat.com> Message-ID-Hash: BA2SNEJC7DW2KK6OORLX6WZJZTSN62UX X-Message-ID-Hash: BA2SNEJC7DW2KK6OORLX6WZJZTSN62UX 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: --ksHZ9AhxcxE5PB+x Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 25, 2024 at 09:09:05AM +0100, Stefano Brivio wrote: > This is very visible with muvm, but it also happens with QEMU: we're > sending the first unsolicited router advertisement milliseconds after > the guest connects. >=20 > That's usually pointless because, when the hypervisor connects, the > guest is typically not ready yet to process anything of that sort: > it's still booting. And if we happen to send it late enough (still > milliseconds), with muvm, while the message is discarded, it > sometimes (slightly) delays the response to the first solicited > router advertisement, which is the one we need to have coming fast. >=20 > Skip sending the unsolicited advertisement on the first timer run, > just calculate the next delay. Keep it simple by observing that we're > probably not trying to reach the 1970s with IPv6. So, as I wrote it, I wasn't particularly happy with how we handled timing the first announcement (what does next_ra=3D=3D0 even mean against the monotonic clock?). I guess this addresses a practical problem, and is no less logical. I'm not especially convinced it's any *more* logical than the current behaviour either, though. I guess it works on the fiction that the link's always been there, the guest is just seeing it for the first time. Under that fiction there would have been RAs in the past, and this works out the next one at a plausible interval based on that. > Signed-off-by: Stefano Brivio > --- > ndp.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/ndp.c b/ndp.c > index 1752d64..37bf7a3 100644 > --- a/ndp.c > +++ b/ndp.c > @@ -420,9 +420,13 @@ void ndp_timer(const struct ctx *c, const struct tim= espec *now) > interval =3D min_rtr_adv_interval + > random() % (max_rtr_adv_interval - min_rtr_adv_interval); > =20 > + if (!next_ra) > + goto first; I don't think avoiding re-indenting two lines is sufficient reason to introduce yet another goto, though.. > + > info("NDP: sending unsolicited RA, next in %llds", (long long)interval); > =20 > ndp_ra(c, &in6addr_ll_all_nodes); > =20 > +first: > next_ra =3D now->tv_sec + interval; > } --=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 --ksHZ9AhxcxE5PB+x Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmdFTQ0ACgkQzQJF27ox 2GfHJA//WiIRuK8Ot7U5ix3Gu9tcl+xwZ/LcFMAAef3dv+A3MXttJx+fyxZt60Xe GeMRhLsp69Yp33cpXP0wCcNGPBg+s3c54K8kde0H99cyz3sy9oj9fz+TOm1QExZx bLqIC+rE2zFiVqlIEZAR7N0In3uEBU8+BoH8WUpiiYmNpVG3SjpliVtR/uQhEXaM yHFUQDfk3c9wf+9W6yVe9H6WEeNFV3hBFlGouixZE4dCIY10zk6jPoLeYgU2YHtj aKeTDOQomT7EqliApZr2RzGpeFAZ8BLjZPyOv0YTDIJxfGxxTXKDRbclEi2gjhc8 UHD2s5SNptaB4xBt/zpTkOU6Wy2ChrjN94xFtcmFCy2YMvCkaagMn7NfcYcTKAPN psiEoWQ4wkDI1coYW9YsDHcZ/Q+uzk0tzDMnjDl991QBiVtlbW/ePdWQvxgiPVDZ nqN9serGjOhS2xdNaN/L9R+Q9Eo3TI0k/MRyYXp/+wc+BmY2TmyFwmuLVhOQtg93 +9SrmCTocYn5WIFn9hj0lWcGwHaqFcGD7FLVJDhsjBDgYmyOjwzQurPRKC6mjO/j OuxwBEKgHH38Yff0w6x1i6eIUFoVoKojcInY0OfEqQkFBVg4Lvaf0YM32ed2PKmP D55LeGvY7Hl+qgKx/bGKxBKk1OaYNYvC2rKA1YQYCdKyzLaBI28= =6DdY -----END PGP SIGNATURE----- --ksHZ9AhxcxE5PB+x--