[git commit] udhcp: export IPv6 preferred_lifetime to the script

Denys Vlasenko vda.linux at googlemail.com
Sun Oct 11 00:36:32 UTC 2026


commit: https://git.busybox.net/busybox/commit/?id=89032255bb443b763b9c0c661017518eadaafe9c
branch: https://git.busybox.net/busybox/log/?h=master

Export the DHCPv6 preferred address lifetime alongside the existing
valid lifetime in lease.

function                                             old     new   delta
option_to_env                                        711     739     +28
.rodata                                           104781  104808     +27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 55/0)               Total: 55 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_common.h | 2 ++
 networking/udhcp/d6_dhcpc.c  | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/networking/udhcp/d6_common.h b/networking/udhcp/d6_common.h
index 3cbfbb89e..8c608e354 100644
--- a/networking/udhcp/d6_common.h
+++ b/networking/udhcp/d6_common.h
@@ -61,6 +61,7 @@ struct d6_option {
 	uint8_t data[1];
 } PACKED;
 
+/* Defined in RFC 3315 "DHCP for IPv6": 1-9,11-20 */
 #define D6_OPT_CLIENTID       1
 #define D6_OPT_SERVERID       2
 /* "Identity Association for Non-temporary Addresses",
@@ -95,6 +96,7 @@ struct d6_option {
 //#define D6_OPT_RECONF_MSG    19
 //#define D6_OPT_RECONF_ACCEPT 20
 
+/* RFC 3646 "DNS Configuration options for DHCPv6": */
 #define D6_OPT_DNS_SERVERS   23
 #define D6_OPT_DOMAIN_LIST   24
 
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 7233c5fbe..cda83485a 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -312,6 +312,10 @@ static void option_to_env(const uint8_t *option, const uint8_t *option_end)
 			sprint_nip6(ipv6str, option + 4);
 			*new_env() = xasprintf("ipv6=%s", ipv6str);
 
+			move_from_unaligned32(v32, option + 4 + 16);
+			v32 = ntohl(v32);
+			*new_env() = xasprintf("preferred_lifetime=%u", (unsigned)v32);
+
 			move_from_unaligned32(v32, option + 4 + 16 + 4);
 			v32 = ntohl(v32);
 			*new_env() = xasprintf("lease=%u", (unsigned)v32);


More information about the busybox-cvs mailing list