dhclient does not reup valid_lft on service restart, kernel reaps IP
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
isc-dhcp (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Between Bionic and Focal, dhclient was patched to set the valid_lft on ipv4 addresses, which is a timer in the kernel that tells the kernel when to reap the IP. dhclient then is supposed to issue repeated `ip addr add` commands to reset this lft and prevent the kernel from releasing the IP. However, if you restart the dhclient service, it acquires a lease and then does *not* reup the lft. It only reups after a lease the currently running service knows about expires. So if you restart the dhclient service on a cadence that is faster than the DHCP leases in your network environment, you never see a lease expire during the lifetime of the service, which means the kernel will eventually rip the address out from under the server, causing a network outage. In some environments, the DCHP lease can be longer than a service restart cadence, and this bug can be very severe.
I'm using the most up-to-date version of Focal's dhclient package.
I'm not familiar with how the patch management for Ubuntu works, but the bug was introduced here:
commit 41013cf19647ec3
Author: Michael Gilbert <email address hidden>
Date: Tue Dec 11 03:55:12 2018 +0000
4.4.1-2 (patches unapplied)
Imported using git-ubuntu import.
These changes specifically:
diff --git a/debian/
index 9b0d3f89..f9b734ab 100644
--- a/debian/
+++ b/debian/
@@ -246,6 +246,8 @@ case "$reason" in
# new IP has been leased or leased IP changed => set it
ip -4 addr add ${new_ip_
+ ${new_dhcp_
+ ${new_dhcp_
if [ -n "$new_interface
@@ -277,6 +279,12 @@ case "$reason" in
fi
+ else # RENEW||REBIND
+ ip -4 addr change ${new_ip_
+ ${new_broadcast
+ ${new_dhcp_
+ ${new_dhcp_
+ dev ${interface} label ${interface}
fi
if [ -n "$alias_ip_address" ] &&
@@ -323,6 +331,8 @@ case "$reason" in
# set IP from recorded lease
ip -4 addr add ${new_ip_
+ ${new_dhcp_
+ ${new_dhcp_
dev ${interface} label ${interface}
if [ -n "$new_interface
Status changed to 'Confirmed' because the bug affects multiple users.