Index | Thread | Search

From:
Florian Obser <florian@openbsd.org>
Subject:
Re: dhcp6leased patch to fix IA_PD t1 == 0
To:
Nick Owens <mischief@offblast.org>
Cc:
tech <tech@openbsd.org>
Date:
Sat, 26 Apr 2025 16:41:24 +0200

Download raw body.

Thread
On 2025-04-23 03:14 -07, Nick Owens <mischief@offblast.org> wrote:
> hi,
>
> i moved and got a new isp (google fiber webpass). i moved my odroid-h2
> gateway and plugged it in and got met with some dhcp6leased spam in the
> log, where it kept sending renews. there seems to be a 'ruckus wireless'
> (based on mac oui) sending back ia pd with iaid 0, t1 0, t2 0. ipv6 works
> fine besides that, but dhcp6leased does not appear to follow the advice in
> RFC 8415 S 21.21 that says the client needs to pick a renew time that isn't
> too fast if the server gives 0.
>
> i've arbitrarily picked 1 day here on 0, this at least shuts up dhcp6leased
> from spamming renews. i'm not really an ipv6 expert, happy to have
> input or

that section as this:

   Recommended values for T1 and T2 are 0.5 and 0.8 times the
   shortest preferred lifetime of the prefixes in the IA_PD that the
   server is willing to extend, respectively.

which dhcpleased implements. I wonder why I didn't implement the same
thing in dhcp6leased, I even put an XXX in.

Please try this (it also fixes the calculation of lease_time, it needs
to be the smallest vltime, not the largest.):

diff --git engine.c engine.c
index 80c8d3bc1db..ac56c0f3e09 100644
--- engine.c
+++ engine.c
@@ -873,7 +873,7 @@ parse_dhcp(struct dhcp6leased_iface *iface, struct imsg_dhcp *dhcp)
 			goto out;
 		}
 
-		if (lease_time < pd->vltime)
+		if (lease_time == 0 || lease_time > pd->vltime)
 			lease_time = pd->vltime;
 
 		log_debug("%s: pltime: %u, vltime: %u, prefix: %s/%u",
@@ -928,9 +928,14 @@ parse_dhcp(struct dhcp6leased_iface *iface, struct imsg_dhcp *dhcp)
 		iface->serverid_len = serverid_len;
 		memcpy(iface->serverid, serverid, SERVERID_SIZE);
 
-		/* XXX handle t1 = 0 or t2 = 0 */
-		iface->t1 = t1;
-		iface->t2 = t2;
+		if (t1 == 0)
+			iface->t1 = lease_time / 2;
+		else
+			iface->t1 = t1;
+		if (t2 == 0)
+		    iface->t2 = lease_time - (lease_time / 8);
+		else
+			iface->t2 = t2;
 		iface->lease_time = lease_time;
 		clock_gettime(CLOCK_MONOTONIC, &iface->request_time);
 		state_transition(iface, IF_BOUND);


-- 
In my defence, I have been left unsupervised.