[git commit] udhcpc6: restart acquisition after a zero valid lifetime
Denys Vlasenko
vda.linux at googlemail.com
Sun Oct 11 01:08:34 UTC 2026
commit: https://git.busybox.net/busybox/commit/?id=a65bea40f482f0b91d4e382ea9414710c460e4f4
branch: https://git.busybox.net/busybox/log/?h=master
A Reply with a zero valid lifetime revokes an address or delegated
prefix. The current client instead applies its minimum lease time and
keeps renewing the revoked lease. When both IA_NA and IA_PD are requested,
the zero can also be replaced by the other IA's nonzero lifetime.
Check the lifetimes of requested IAs before combining or clamping them.
On zero, run deconfig and return to INIT_SELECTING. Clear the requested
address hint, remaining lease, elapsed time and packet counter. Use the
same three-second delay as the existing DHCPv6 NAK recovery path to avoid
repeatedly soliciting an unusable lease. Deconfiguration happens
immediately; the delay applies only to restarting acquisition. This is
an existing implementation convention, not an RFC requirement. Do not
report bound or renew, or honor quit-after-lease, for an unusable lease.
Use option_mask32, which includes the default address request and the
-r no/-l overrides. A zero preferred lifetime with a positive valid
lifetime remains accepted. Stateful address and prefix acquisition
still share one client state: revoking either restarts both.
This addresses the existing zero-lease TODO. It does not implement
independent IA renewal or processing of multiple leases per IA.
Existing partial-Reply handling is unchanged: if a requested companion
IA is missing, the Reply is ignored before this revocation check.
Tested on aarch64: address and prefix revocation, combined leases with
one or both lifetimes zero, replacement acquisition and renewal,
zero first Reply, persistent zero Replies, quit-after-lease, deprecated
addresses, and stateless Information-request. The unpatched baseline
continues renewing revoked state.
Native aarch64, GCC 15.2.0, Alpine configuration; relative to
the preceding patch in this series. Data and BSS are unchanged.
bloat-o-meter:
function old new delta
udhcpc6_main 3024 3120 +96
.rodata 69449 69484 +35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 131/0) Total: 131 bytes
Signed-off-by: Jake Buchholz Göktürk <tomalok at gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
networking/udhcp/d6_dhcpc.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index ebfa5350b..d77d76d88 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -1840,10 +1840,12 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
requested_ipv6 = (struct in6_addr*) iaaddr->data;
move_from_unaligned32(lease_seconds, iaaddr->data + 16 + 4);
lease_seconds = ntohl(lease_seconds);
-/// TODO: check for 0 lease time?
bb_info_msg("%s obtained, lease time %u",
"IPv6", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
address_timeout = lease_seconds;
+ /* A zero valid lifetime revokes the address */
+ if (address_timeout == 0)
+ goto lease_revoked;
}
if (option_mask32 & OPT_d) {
struct d6_option *iaprefix;
@@ -1892,6 +1894,19 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
bb_info_msg("%s obtained, lease time %u",
"prefix", /*inet_ntoa(temp_addr),*/ (unsigned)lease_seconds);
prefix_timeout = lease_seconds;
+ /* A zero valid lifetime revokes the prefix */
+ if (prefix_timeout == 0) {
+ lease_revoked:
+ bb_simple_info_msg("lease revoked, entering init state");
+ d6_run_script_no_option("deconfig");
+ client_data.state = INIT_SELECTING;
+ client_data.first_secs = 0;
+ requested_ipv6 = NULL;
+ lease_remaining = 0;
+ timeout = 3; /* avoid excessive network traffic */
+ packet_num = 0;
+ continue;
+ }
}
if (!address_timeout)
address_timeout = prefix_timeout;
More information about the busybox-cvs
mailing list