public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH] ndp: Don't send first periodic router advertisement right after guest connects
Date: Mon, 25 Nov 2024 09:09:05 +0100	[thread overview]
Message-ID: <20241125080905.118341-1-sbrivio@redhat.com> (raw)

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 <sbrivio@redhat.com>
---
 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;
 }
-- 
@@ -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


             reply	other threads:[~2024-11-25  8:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25  8:09 Stefano Brivio [this message]
2024-11-26  4:22 ` [PATCH] ndp: Don't send first periodic router advertisement right after guest connects David Gibson
2024-11-26  4:48   ` Stefano Brivio
2024-11-26  5:30     ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241125080905.118341-1-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).