Index | Thread | Search

From:
Nick Owens <mischief@offblast.org>
Subject:
Re: dhcp6leased patch to fix IA_PD t1 == 0
To:
Florian Obser <florian@openbsd.org>
Cc:
tech <tech@openbsd.org>
Date:
Sat, 26 Apr 2025 09:07:21 -0700

Download raw body.

Thread
On Sat, Apr 26, 2025 at 04:41:24PM +0200, Florian Obser wrote:
> 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);
> 

hello florian,

thanks for taking a look! this also works fine on my freshly upgraded
7.7 system with patched dhcp6leased.

fugu# ./dhcp6leased -d -v
changed iface: rge0[1]
open_udpsock: fe80::21e:6ff:fe45:5c6d%rge0 rdomain: 0
state_transition[rge0] Down -> Rebooting, timo: 1
Rebinding lease on rge0
parse_dhcp: rge0 ia_count: 1
parse_dhcp: IA_PD, IAID: 00000000, T1: 0, T2: 0
parse_ia_pd_options: pltime: 19461276, vltime: 31287276, prefix: 2604:5500:c29f:e800::/56
parse_dhcp: SERVERID: 000100012a730b3b00163ec8302c
parse_dhcp: pltime: 19461276, vltime: 31287276, prefix: 2604:5500:c29f:e800::/56
prefix delegation #0 2604:5500:c29f:e800::/56 received on rge0 from server 000100012a730b3b00163ec8302c
send_reconfigure_interface: vport0 configure: 2604:5500:c29f:e800::1/64
state_transition[rge0] Rebooting -> Bound, timo: 15643638
configure_address: vport0

thank you,
nick

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