From aa62f3c3efb07ea3c9cc39a42a4856356277c454 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 5 Oct 2025 07:25:16 +0000 Subject: [PATCH] Lower bound for how long to prefer IPv6 at least. RFC 8925 suggests 5 minutes, so that's what we are going with. kn noticed that if the IPv6-Only preferred option is send from the server with a value of 0, dhcpleased(8) would still request a lease while apple devices would not. There were two problems with that: 1. A value of 0 would be treated as turning the feature of, which is not correct. 2. The value would be used for a timeout, so a very small value would create a timeout that would constantly fire. OK kn --- sbin/dhcpleased/engine.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sbin/dhcpleased/engine.c b/sbin/dhcpleased/engine.c index 0b5f3e6f370..6a79539cb5b 100644 --- a/sbin/dhcpleased/engine.c +++ b/sbin/dhcpleased/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.59 2025/09/18 11:37:01 florian Exp $ */ +/* $OpenBSD: engine.c,v 1.60 2025/10/05 07:25:16 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -61,6 +61,9 @@ #define MAX_EXP_BACKOFF_FAST 2 #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) +/* RFC 8925 3.4 disable IPv4 leases for at least this long */ +#define MIN_V6ONLY_WAIT 300 + enum if_state { IF_DOWN, IF_INIT, @@ -1200,6 +1203,14 @@ parse_dhcp(struct dhcpleased_iface *iface, struct imsg_dhcp *dhcp) log_debug("DHO_IPV6_ONLY_PREFERRED %us", ipv6_only_time); } + if (ipv6_only_time < MIN_V6ONLY_WAIT) { + ipv6_only_time = MIN_V6ONLY_WAIT; + if (log_getverbose() > 1) { + log_debug("DHO_IPV6_ONLY_PREFERRED too " + "small, setting to %us", + ipv6_only_time); + } + } p += dho_len; rem -= dho_len; break;