1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-23 05:34:18 +00:00

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
This commit is contained in:
florian
2025-10-05 07:25:16 +00:00
parent 0bae8e191e
commit aa62f3c3ef

View File

@@ -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 <florian@openbsd.org>
@@ -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;