* [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses
@ 2022-10-07 18:02 Andrew Zaborowski
2022-10-07 18:02 ` [PATCH 2/2] dhcp: Simplify check in BPF filter Andrew Zaborowski
2022-10-07 18:35 ` [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses Denis Kenzior
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Zaborowski @ 2022-10-07 18:02 UTC (permalink / raw)
To: ell
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] dhcp: Simplify check in BPF filter
2022-10-07 18:02 [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses Andrew Zaborowski
@ 2022-10-07 18:02 ` Andrew Zaborowski
2022-10-07 18:35 ` [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Zaborowski @ 2022-10-07 18:02 UTC (permalink / raw)
To: ell
Instead of separately loading and testing the low 4 bits and the high 4
bits of the IP Version+Header length byte in the DHCP frame, test both
in one operation. The filter can be further shortened but with some
loss of readability.
---
ell/dhcp-transport.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/ell/dhcp-transport.c b/ell/dhcp-transport.c
index c4cf0ca..41b582d 100644
--- a/ell/dhcp-transport.c
+++ b/ell/dhcp-transport.c
@@ -389,18 +389,8 @@ static int kernel_raw_socket_open(uint32_t ifindex, uint16_t port, uint32_t xid)
BPF_STMT(BPF_RET + BPF_K, 0),
/* A <- IP version + Header length */
BPF_STMT(BPF_LD + BPF_B + BPF_ABS, 0),
- /* A <- A & 0xf0 (Mask off version */
- BPF_STMT(BPF_ALU + BPF_AND + BPF_K, 0xf0),
- /* A == IPVERSION (shifted left 4) ? */
- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPVERSION << 4, 1, 0),
- /* ignore */
- BPF_STMT(BPF_RET + BPF_K, 0),
- /* A <- IP version + Header length */
- BPF_STMT(BPF_LD + BPF_B + BPF_ABS, 0),
- /* A <- A & 0x0f (Mask off IP Header Length */
- BPF_STMT(BPF_ALU + BPF_AND + BPF_K, 0x0f),
- /* A == 5 ? */
- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 5, 1, 0),
+ /* IP version == IPVERSION && Header length == 5 ? */
+ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, (IPVERSION << 4) | 5, 1, 0),
/* ignore */
BPF_STMT(BPF_RET + BPF_K, 0),
/* A <- IP protocol */
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses
2022-10-07 18:02 [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses Andrew Zaborowski
2022-10-07 18:02 ` [PATCH 2/2] dhcp: Simplify check in BPF filter Andrew Zaborowski
@ 2022-10-07 18:35 ` Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2022-10-07 18:35 UTC (permalink / raw)
To: Andrew Zaborowski, ell
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-07 18:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-07 18:02 [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses Andrew Zaborowski
2022-10-07 18:02 ` [PATCH 2/2] dhcp: Simplify check in BPF filter Andrew Zaborowski
2022-10-07 18:35 ` [PATCH 1/2] netconfig: Set preferred lifetimes on DHCP addresses Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).