diff mbox series

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

Message ID 20221007180209.1069526-1-andrew.zaborowski@intel.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/2] netconfig: Set preferred lifetimes on DHCP addresses | expand

Commit Message

Andrew Zaborowski Oct. 7, 2022, 6:02 p.m. UTC
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(-)

Comments

Denis Kenzior Oct. 7, 2022, 6:35 p.m. UTC | #1
Hi Andrew,

On 10/7/22 13:02, Andrew Zaborowski wrote:
> 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(-)
> 

Both applied, thanks.

Regards,
-Denis
diff mbox series

Patch

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))