summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-10-24 21:13:14 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-10-27 16:58:35 +0200
commitd951507d5d6855e63cbc53afe1a0df76b2134460 (patch)
tree60e1a07b1450092f90fa99509ecb119c96977438
parentsd-radv: make prefix/route prefix lifetime can be specified with independentl... (diff)
downloadsystemd-d951507d5d6855e63cbc53afe1a0df76b2134460.tar.xz
systemd-d951507d5d6855e63cbc53afe1a0df76b2134460.zip
sd-radv: shorten the default lifetime for prefix/route prefix
See draft-ietf-6man-slaac-renum-02 section 4.1.1.
-rw-r--r--src/libsystemd-network/radv-internal.h5
-rw-r--r--src/libsystemd-network/sd-radv.c6
-rw-r--r--src/libsystemd-network/test-ndisc-ra.c8
3 files changed, 12 insertions, 7 deletions
diff --git a/src/libsystemd-network/radv-internal.h b/src/libsystemd-network/radv-internal.h
index df3c22c8c0..1a268757ad 100644
--- a/src/libsystemd-network/radv-internal.h
+++ b/src/libsystemd-network/radv-internal.h
@@ -39,6 +39,11 @@
#define RADV_MIN_ROUTER_LIFETIME_USEC RADV_MIN_MAX_TIMEOUT_USEC
#define RADV_MAX_ROUTER_LIFETIME_USEC (9000 * USEC_PER_SEC)
#define RADV_DEFAULT_ROUTER_LIFETIME_USEC (3 * RADV_DEFAULT_MAX_TIMEOUT_USEC)
+/* draft-ietf-6man-slaac-renum-02 section 4.1.1.
+ * AdvPreferredLifetime: max(AdvDefaultLifetime, 3 * MaxRtrAdvInterval)
+ * AdvValidLifetime: 2 * AdvPreferredLifetime */
+#define RADV_DEFAULT_PREFERRED_LIFETIME_USEC CONST_MAX(RADV_DEFAULT_ROUTER_LIFETIME_USEC, 3 * RADV_DEFAULT_MAX_TIMEOUT_USEC)
+#define RADV_DEFAULT_VALID_LIFETIME_USEC (2 * RADV_DEFAULT_PREFERRED_LIFETIME_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 4e146fe282..2f3f480151 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -837,8 +837,8 @@ _public_ int sd_radv_prefix_new(sd_radv_prefix **ret) {
/* RFC 4861, Section 6.2.1 */
.opt.flags = ND_OPT_PI_FLAG_ONLINK|ND_OPT_PI_FLAG_AUTO,
- .lifetime_valid_usec = 30 * USEC_PER_DAY,
- .lifetime_preferred_usec = 7 * USEC_PER_DAY,
+ .lifetime_valid_usec = RADV_DEFAULT_VALID_LIFETIME_USEC,
+ .lifetime_preferred_usec = RADV_DEFAULT_PREFERRED_LIFETIME_USEC,
.valid_until = USEC_INFINITY,
.preferred_until = USEC_INFINITY,
};
@@ -930,7 +930,7 @@ _public_ int sd_radv_route_prefix_new(sd_radv_route_prefix **ret) {
.opt.length = DIV_ROUND_UP(sizeof(p->opt), 8),
.opt.prefixlen = 64,
- .lifetime_usec = 7 * USEC_PER_DAY,
+ .lifetime_usec = RADV_DEFAULT_VALID_LIFETIME_USEC,
.valid_until = USEC_INFINITY,
};
diff --git a/src/libsystemd-network/test-ndisc-ra.c b/src/libsystemd-network/test-ndisc-ra.c
index 88a32dcc58..7b961f4761 100644
--- a/src/libsystemd-network/test-ndisc-ra.c
+++ b/src/libsystemd-network/test-ndisc-ra.c
@@ -32,13 +32,13 @@ static uint8_t advertisement[] = {
0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Prefix Information Option */
- 0x03, 0x04, 0x40, 0xc0, 0x00, 0x27, 0x8d, 0x00,
- 0x00, 0x09, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x04, 0x40, 0xc0, 0x00, 0x00, 0x0e, 0x10,
+ 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00,
0x20, 0x01, 0x0d, 0xb8, 0x0b, 0x16, 0xd0, 0x0d,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Prefix Information Option */
- 0x03, 0x04, 0x30, 0xc0, 0x00, 0x27, 0x8d, 0x00,
- 0x00, 0x09, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x04, 0x30, 0xc0, 0x00, 0x00, 0x0e, 0x10,
+ 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00,
0x20, 0x01, 0x0d, 0xb8, 0xc0, 0x01, 0x0d, 0xad,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Recursive DNS Server Option */