dhcpcd-discuss

Re: Extending a lease when dhcp server is offline (similar to lastleaseextend)

Roy Marples

Tue Sep 01 12:07:02 2020

Hi Matthew

On 01/09/2020 00:47, Matthew Clarkson wrote:
Again, thanks for the quick responses.

Welcome

I had a bit of trouble applying those patches, looks like https://roy.marples.name/cgit/dhcpcd.git/commit/?id=b336d43584f8d759acbae668690c6415ca05618f is also required (as one patch uses the dhcp_unlink added in that commit). Before chasing down more commits I have updated to version 9.1.4 and applied the 4 patches you sent.

dhcp_unlink isn't needed for dhcpcd-8 - you can just use unlink from libc in it's place.


I can confirm that after the lease expires, the client sends dhcp discover requests (as broadcasts) roughly every 30 seconds. But there is a new problem. With the lastleaseextend option, the device is not binding to the previous lease's IP. It is bound to a link-local address. In 8.1.9, the interface would be using both a link local address and the address of the previous lease.

In 8.1.9 the output after failing to renew is:
br0: failed to renew DHCP, rebinding
br0: DHCP lease expired, extending lease
br0: pid 0 deleted IP address 192.168.10.20/24
br0: deleting route to 192.168.10.0/24
br0: deleting default route via 192.168.10.1
br0: rebinding lease of 192.168.10.20
br0: probing for an IPv4LL address
br0: timed out contacting a DHCP server, using last lease
br0: leased 192.168.10.20 for 600 seconds
br0: adding route to 192.168.10.0/24
br0: adding default route via 192.168.10.1
br0: soliciting a DHCP lease
br0: using IPv4LL address 169.254.18.158
br0: adding route to 169.254.0.0/16
br0: changing default route
br0: deleting route to 192.168.10.0/24
br0: pid -128819375 deleted default route
br0: adding default route

In 9.1.4 it is:
br0: failed to renew DHCP, rebinding
br0: DHCP lease expired, extending lease
br0: soliciting a DHCP lease
br0: pid 0 deleted IP address 192.168.10.20/24
br0: deleting route to 192.168.10.0/24
br0: deleting default route via 192.168.10.1
br0: rebinding lease of 192.168.10.20
br0: probing for an IPv4LL address
br0: timed out contacting a DHCP server, using last lease
br0: probing address 192.168.10.20/24
br0: soliciting a DHCP lease
br0: using IPv4LL address 169.254.18.158
br0: adding route to 169.254.0.0/16
br0: adding default route

Any thoughts?

Well, technically you could have IPv4LL and a DHCP lease active at the same time. If you don't want IPv4LL, then turn it off in dhcpcd.conf with the noipv4ll directive.

The issue here is that we cannot apply address lifetimes (also applicable to IPv6) when extending the last lease otherwise the kernel will expire the address.

Rather than adding risky code to manage this, I've committed a fix just to set infinite lifetimes and let the existing dhcpcd code manage the lifecycle of the address as some OS's don't even have lifetimes for IPv6 addresses.

Patch here:
https://roy.marples.name/cgit/dhcpcd.git/commit/?id=ffb2feb302ecf3600aa905eb78bc864f6a5eb0f5

I don't have time to extensively test this right, hopefully you can!
Let me know how it works out.

Roy

Follow-Ups:
Re: Extending a lease when dhcp server is offline (similar to lastleaseextend)Roy Marples
References:
Extending a lease when dhcp server is offline (similar to lastleaseextend)Matthew Clarkson
Re: Extending a lease when dhcp server is offline (similar to lastleaseextend)Roy Marples
RE: Extending a lease when dhcp server is offline (similar to lastleaseextend)Matthew Clarkson
Re: Extending a lease when dhcp server is offline (similar to lastleaseextend)Roy Marples
Re: Extending a lease when dhcp server is offline (similar to lastleaseextend)Roy Marples
RE: Extending a lease when dhcp server is offline (similar to lastleaseextend)Matthew Clarkson
Archive administrator: postmaster@marples.name