From 72db0a714b3fe181d06cccaae27d62b92ea5c196 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 25 Oct 2021 01:03:30 +0900 Subject: [PATCH] sd-radv: introduce RADV_DEFAULT_ROUTER_LIFETIME_USEC --- src/libsystemd-network/radv-internal.h | 10 ++++++++++ src/libsystemd-network/sd-radv.c | 1 + 2 files changed, 11 insertions(+) diff --git a/src/libsystemd-network/radv-internal.h b/src/libsystemd-network/radv-internal.h index e3d4ab99d6..6d8ad60b48 100644 --- a/src/libsystemd-network/radv-internal.h +++ b/src/libsystemd-network/radv-internal.h @@ -25,6 +25,16 @@ * Default: 0.33 * MaxRtrAdvInterval If MaxRtrAdvInterval >= 9 seconds; otherwise, the Default is * MaxRtrAdvInterval (Note, this should be a typo. We use 0.75 * MaxRtrAdvInterval). */ #define RADV_DEFAULT_MIN_TIMEOUT_USEC (RADV_DEFAULT_MAX_TIMEOUT_USEC / 3) +/* RFC 4861 section 6.2.4. + * AdvDefaultLifetime + * The value to be placed in the Router Lifetime field of Router Advertisements sent from the interface, + * in seconds. MUST be either zero or between MaxRtrAdvInterval and 9000 seconds. A value of zero + * indicates that the router is not to be used as a default router. These limits may be overridden by + * specific documents that describe how IPv6 operates over different link layers. For instance, in a + * point-to-point link the peers may have enough information about the number and status of devices at + * the other end so that advertisements are needed less frequently. + * Default: 3 * MaxRtrAdvInterval */ +#define RADV_DEFAULT_ROUTER_LIFETIME_USEC (3 * RADV_DEFAULT_MAX_TIMEOUT_USEC) /* RFC 4861 section 10. * MAX_INITIAL_RTR_ADVERT_INTERVAL 16 seconds * MAX_INITIAL_RTR_ADVERTISEMENTS 3 transmissions diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index 462b153ac2..0468b5268f 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -38,6 +38,7 @@ _public_ int sd_radv_new(sd_radv **ret) { *ra = (sd_radv) { .n_ref = 1, .fd = -1, + .lifetime_usec = RADV_DEFAULT_ROUTER_LIFETIME_USEC, }; *ret = TAKE_PTR(ra); -- 2.25.1