[PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses

Andrew Zaborowski <[email protected]>
Newsgroups dev.linux.lists.ell
Message-ID <[email protected]>
We receive one lease lifetime value for a DHCP lease so we were setting
the preferred lifetime for the RTNL address to 0 and the valid lifetime
to the lease lifetime.  If either value is non-zero rtnl.c will send
both to the kernel and the 0 preferred lifetime is treated as literal
zero and the address becomes deprecated immediately.  This doesn't
matter for most usages but systemd-resolved would check whether a link
has a non-deprecated address before setting the link's
"unicast_relevant" flag and internally wouldn't create a DNS "scope" on
the link or set its "DefaultRoute" flag both of which are required for
it to want to resolve names.
---
 ell/netconfig.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ell/netconfig.c b/ell/netconfig.c
index 76b18a7..8ded113 100644
--- a/ell/netconfig.c
+++ b/ell/netconfig.c
@@ -405,8 +405,8 @@ static void netconfig_set_dhcp_lifetimes(struct l_netconfig *nc, bool updated)
 	uint64_t expiry = l_dhcp_lease_get_start_time(lease) +
 		lifetime * L_USEC_PER_SEC;
 
-	l_rtnl_address_set_lifetimes(nc->v4_address, 0, lifetime);
-	l_rtnl_address_set_expiry(nc->v4_address, 0, expiry);
+	l_rtnl_address_set_lifetimes(nc->v4_address, lifetime, lifetime);
+	l_rtnl_address_set_expiry(nc->v4_address, expiry, expiry);
 
 	if (updated && !netconfig_address_exists(nc->addresses.added,
 							nc->v4_address))
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.