From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 824F45A061A; Mon, 25 Nov 2024 09:09:05 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] ndp: Don't send first periodic router advertisement right after guest connects Date: Mon, 25 Nov 2024 09:09:05 +0100 Message-ID: <20241125080905.118341-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LNS3X5RXL7B5G4XXI6YJEB6KX3IPHKUK X-Message-ID-Hash: LNS3X5RXL7B5G4XXI6YJEB6KX3IPHKUK X-MailFrom: sbrivio@passt.top 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: David Gibson 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: 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. 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. 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. Signed-off-by: Stefano Brivio --- ndp.c | 4 ++++ 1 file changed, 4 insertions(+) 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 timespec *now) interval = min_rtr_adv_interval + random() % (max_rtr_adv_interval - min_rtr_adv_interval); + if (!next_ra) + goto first; + info("NDP: sending unsolicited RA, next in %llds", (long long)interval); ndp_ra(c, &in6addr_ll_all_nodes); +first: next_ra = now->tv_sec + interval; } -- 2.43.0