From: Michael Marley Date: Sun, 26 Jul 2020 03:23:48 +0000 (-0400) Subject: network: radv: Send RA on newly-added dynamic prefix X-Git-Tag: v246~20 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=commitdiff_plain;h=97efde65d81b1501a3737f408f1234c6c25da61c;ds=sidebyside network: radv: Send RA on newly-added dynamic prefix When a prefix is delegated to an interface that is already sending RAs, send an RA immediately to inform clients of the new prefix. This allows them to start using it immediately instead of waiting up to nearly 10 minutes (depending on when the last timed RA was sent). This type of situation might occur if, for example, an outage of the WAN connection caused the addresses and prefixes to be lost and later regained after service was restored. The condition for the number of RAs sent being above 0 simultaneously ensures that RADV is already running and that this code doesn't send any RAs before the timed RAs have started when the interface first comes up. --- diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index 7383c84724a..6163cf16914 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -578,6 +578,15 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, int dynamic) { cur = p; + /* If RAs have already been sent, send an RA immediately to announce the newly-added prefix */ + if (ra->ra_sent > 0) { + r = radv_send(ra, NULL, ra->lifetime); + if (r < 0) + log_radv_errno(r, "Unable to send Router Advertisement for added prefix: %m"); + else + log_radv("Sent Router Advertisement for added prefix"); + } + update: r = sd_event_now(ra->event, clock_boottime_or_monotonic(), &time_now); if (r < 0) @@ -686,6 +695,15 @@ _public_ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p, int return 0; } + /* If RAs have already been sent, send an RA immediately to announce the newly-added route prefix */ + if (ra->ra_sent > 0) { + r = radv_send(ra, NULL, ra->lifetime); + if (r < 0) + log_radv_errno(r, "Unable to send Router Advertisement for added route prefix: %m"); + else + log_radv("Sent Router Advertisement for added route prefix"); + } + update: r = sd_event_now(ra->event, clock_boottime_or_monotonic(), &time_now); if (r < 0)