From nobody Tue Nov 16 18:27:37 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 42418189352C; Tue, 16 Nov 2021 18:27:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HtvgG2fnJz4RL7; Tue, 16 Nov 2021 18:27:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0164212701; Tue, 16 Nov 2021 18:27:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AGIRb4q078589; Tue, 16 Nov 2021 18:27:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AGIRbkn078588; Tue, 16 Nov 2021 18:27:37 GMT (envelope-from git) Date: Tue, 16 Nov 2021 18:27:37 GMT Message-Id: <202111161827.1AGIRbkn078588@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 231bac4ccc43 - main - rtsol/rtsold: Add option to skip random delay List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 231bac4ccc431381d70c966a5bd5a95fbfc1f163 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=231bac4ccc431381d70c966a5bd5a95fbfc1f163 commit 231bac4ccc431381d70c966a5bd5a95fbfc1f163 Author: Colin Percival AuthorDate: 2021-11-16 18:24:05 +0000 Commit: Colin Percival CommitDate: 2021-11-16 18:27:28 +0000 rtsol/rtsold: Add option to skip random delay In accordance with a SHOULD in RFC 4861, rtsol and rtsold wait a random time between zero and one (aka MAX_RTR_SOLICITATION_DELAY) seconds before sending a Router Solicitation, in order to avoid network congestion if many hosts come online at once. (The question of how many hosts would be required to cause congestion by each sending a single packet on a Gbps+ network is left to the reader.) The new option -i disables this wait and instructs rtsol and rtsold to send the Router Solicitation immediately. Reviewed by: bz, kp (earlier version) MFC after: 1 week Relnotes: yes Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D32956 --- usr.sbin/rtsold/rtsold.8 | 16 +++++++++++----- usr.sbin/rtsold/rtsold.c | 13 ++++++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8 index 84e4d3013ef4..6b0e64ab0fac 100644 --- a/usr.sbin/rtsold/rtsold.8 +++ b/usr.sbin/rtsold/rtsold.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 14, 2021 +.Dd November 12, 2021 .Dt RTSOLD 8 .Os .\" @@ -39,27 +39,27 @@ .\" .Sh SYNOPSIS .Nm -.Op Fl dDfFmu1 +.Op Fl dDfFimu1 .Op Fl M Ar script-name .Op Fl O Ar script-name .Op Fl p Ar pidfile .Op Fl R Ar script-name .Ar interface ... .Nm -.Op Fl dDfFmu1 +.Op Fl dDfFimu1 .Op Fl M Ar script-name .Op Fl O Ar script-name .Op Fl p Ar pidfile .Op Fl R Ar script-name .Fl a .Nm rtsol -.Op Fl dDu +.Op Fl dDiu .Op Fl M Ar script-name .Op Fl O Ar script-name .Op Fl R Ar script-name .Ar interface ... .Nm rtsol -.Op Fl dDu +.Op Fl dDiu .Op Fl M Ar script-name .Op Fl O Ar script-name .Op Fl R Ar script-name @@ -194,6 +194,12 @@ The settings may be changed manually with .Xr sysctl 8 and .Xr ifconfig 8 . +.It Fl i +Transmit Router Solicitation packets immediately, without waiting the +normal random (between 0 and 1 second) delay. +This option should not be used on networks where it might result in +congestion due to many hosts simultaneously (re)connecting and +sending such packets. .It Fl m Enable mobility support. If this option is specified, diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index 592321f59aca..f1ba3b07c879 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -99,6 +99,7 @@ cap_channel_t *capllflags, *capscript, *capsendmsg, *capsyslog; /* static variables and functions */ static int mobile_node = 0; +static int no_solicitation_delay = 0; static sig_atomic_t do_dump, do_exit; static struct pidfh *pfh; @@ -125,11 +126,11 @@ main(int argc, char **argv) progname = basename(argv[0]); if (strcmp(progname, "rtsold") == 0) { - opts = "adDfFm1M:O:p:R:u"; + opts = "adDfFim1M:O:p:R:u"; once = 0; pidfilepath = NULL; } else { - opts = "adDFM:O:R:u"; + opts = "adDFiM:O:R:u"; fflag = 1; once = 1; } @@ -151,6 +152,9 @@ main(int argc, char **argv) case 'F': Fflag = 1; break; + case 'i': + no_solicitation_delay = 1; + break; case 'm': mobile_node = 1; break; @@ -717,7 +721,10 @@ rtsol_timer_update(struct ifinfo *ifi) ifi->timer = tm_max; /* stop timer(valid?) */ break; case IFS_DELAY: - interval = arc4random_uniform(MAX_RTR_SOLICITATION_DELAY * MILLION); + if (no_solicitation_delay) + interval = 0; + else + interval = arc4random_uniform(MAX_RTR_SOLICITATION_DELAY * MILLION); ifi->timer.tv_sec = interval / MILLION; ifi->timer.tv_nsec = (interval % MILLION) * 1000; break;