From 14508ef857f8907e634f355bbe7d67da57be5e25 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Wed, 8 Jan 2025 16:38:39 -0600 Subject: [PATCH 01/18] Add route lifetime from Router Advertisement Sends route lifetime to NETLINK RTA_EXPIRES Partially addresses #428 --- src/if-linux.c | 4 ++++ src/ipv6.c | 2 ++ src/route.h | 1 + 3 files changed, 7 insertions(+) diff --git a/src/if-linux.c b/src/if-linux.c index 5980574b..8a8f42a0 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -1735,6 +1735,10 @@ if_route(unsigned char cmd, const struct rt *rt) if (!sa_is_loopback(&rt->rt_gateway)) add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, rt->rt_ifp->index); + /* add route lifetime */ + logdebugx("Sending RTA_EXPIRES %d", rt->rt_expires); + add_attr_32(&nlm.hdr, sizeof(nlm), RTA_EXPIRES, rt->rt_expires); + if (rt->rt_metric != 0) add_attr_32(&nlm.hdr, sizeof(nlm), RTA_PRIORITY, rt->rt_metric); diff --git a/src/ipv6.c b/src/ipv6.c index a4221a8c..e1a544b6 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -2370,6 +2370,8 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif + rt->rt_expires = rap->lifetime; + rt_proto_add(routes, rt); } return 0; diff --git a/src/route.h b/src/route.h index b9b0dfd6..61e752ad 100644 --- a/src/route.h +++ b/src/route.h @@ -120,6 +120,7 @@ struct rt { #define RTDF_GATELINK 0x40 /* Gateway is on link */ size_t rt_order; rb_node_t rt_tree; + int rt_expires; /* current lifetime of route */ }; extern const rb_tree_ops_t rt_compare_list_ops; From 3b004f819dcb4343096dbb3107039478ed921014 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Wed, 8 Jan 2025 16:50:12 -0600 Subject: [PATCH 02/18] Fix whitespace --- src/if-linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/if-linux.c b/src/if-linux.c index 8a8f42a0..43bcb96c 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -1736,8 +1736,8 @@ if_route(unsigned char cmd, const struct rt *rt) add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, rt->rt_ifp->index); /* add route lifetime */ - logdebugx("Sending RTA_EXPIRES %d", rt->rt_expires); - add_attr_32(&nlm.hdr, sizeof(nlm), RTA_EXPIRES, rt->rt_expires); + logdebugx("Sending RTA_EXPIRES %d", rt->rt_expires); + add_attr_32(&nlm.hdr, sizeof(nlm), RTA_EXPIRES, rt->rt_expires); if (rt->rt_metric != 0) add_attr_32(&nlm.hdr, sizeof(nlm), RTA_PRIORITY, From 4526bb6b9e3c17640225e13d891f521f037bb52c Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Wed, 8 Jan 2025 16:51:24 -0600 Subject: [PATCH 03/18] Fix whitespace --- src/route.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/route.h b/src/route.h index 61e752ad..721953a9 100644 --- a/src/route.h +++ b/src/route.h @@ -120,7 +120,7 @@ struct rt { #define RTDF_GATELINK 0x40 /* Gateway is on link */ size_t rt_order; rb_node_t rt_tree; - int rt_expires; /* current lifetime of route */ + int rt_expires; /* current lifetime of route */ }; extern const rb_tree_ops_t rt_compare_list_ops; From 1f4b9f1aaf5aef5bb64fd9c3ad5bfbf8cdf48f22 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Thu, 9 Jan 2025 09:05:53 -0600 Subject: [PATCH 04/18] Add RTA_EXPIRES to if_copyrt --- src/if-linux.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/if-linux.c b/src/if-linux.c index 43bcb96c..1c1873d4 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -752,6 +752,9 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm) } break; } + case RTA_EXPIRES: + rt->rt_expires = *(unsigned int *)RTA_DATA(rta); + break; } if (sa != NULL) { From 1ecf2451387968dffec4131f2accd09946eb99ce Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Thu, 9 Jan 2025 09:45:43 -0600 Subject: [PATCH 05/18] Use uint32_t for RTA_EXPIRES Remove debug logging as well. --- src/if-linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/if-linux.c b/src/if-linux.c index 1c1873d4..e8d2c85b 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -753,7 +753,7 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm) break; } case RTA_EXPIRES: - rt->rt_expires = *(unsigned int *)RTA_DATA(rta); + rt->rt_expires = *(uint32_t *)RTA_DATA(rta); break; } @@ -1739,7 +1739,6 @@ if_route(unsigned char cmd, const struct rt *rt) add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, rt->rt_ifp->index); /* add route lifetime */ - logdebugx("Sending RTA_EXPIRES %d", rt->rt_expires); add_attr_32(&nlm.hdr, sizeof(nlm), RTA_EXPIRES, rt->rt_expires); if (rt->rt_metric != 0) From a3c95eb9bb4c048496036660fdc15eba30fb42c2 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Thu, 9 Jan 2025 09:46:44 -0600 Subject: [PATCH 06/18] Change rt_expires to uint32_t in struct --- src/route.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/route.h b/src/route.h index 721953a9..6be2e1ea 100644 --- a/src/route.h +++ b/src/route.h @@ -120,7 +120,7 @@ struct rt { #define RTDF_GATELINK 0x40 /* Gateway is on link */ size_t rt_order; rb_node_t rt_tree; - int rt_expires; /* current lifetime of route */ + uint32_t rt_expires; /* current lifetime of route */ }; extern const rb_tree_ops_t rt_compare_list_ops; From fa8a1ac682625a3c7f92b7b6bff43594c66fd80d Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Thu, 9 Jan 2025 11:00:32 -0600 Subject: [PATCH 07/18] Account for elapsed time when updating route lifetime in netlink --- src/ipv6.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ipv6.c b/src/ipv6.c index e1a544b6..829260b4 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -2301,6 +2301,10 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) const struct routeinfo *rinfo; const struct ipv6_addr *addr; struct in6_addr netmask; + struct timespec now; + uint32_t elapsed; + + clock_gettime(CLOCK_MONOTONIC, &now); if (ctx->ra_routers == NULL) return 0; @@ -2325,6 +2329,8 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rinfo->flags); #endif + elapsed = (uint32_t)eloop_timespec_diff(&now, &rap->acquired, NULL); + rt->rt_expires = rap->lifetime - elapsed; rt_proto_add(routes, rt); } @@ -2339,6 +2345,9 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif + elapsed = (uint32_t)eloop_timespec_diff(&now, &rap->acquired, NULL); + rt->rt_expires = rap->lifetime - elapsed; + rt_proto_add(routes, rt); } } @@ -2370,7 +2379,8 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif - rt->rt_expires = rap->lifetime; + elapsed = (uint32_t)eloop_timespec_diff(&now, &rap->acquired, NULL); + rt->rt_expires = rap->lifetime - elapsed; rt_proto_add(routes, rt); } From d2306bd6dee97e7f6a9b59c1f6af37b85d55ea7e Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Thu, 9 Jan 2025 11:57:39 -0600 Subject: [PATCH 08/18] update elapsed route lifetime check acquired time for routes only fetch "now" if routes available. --- src/ipv6.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ipv6.c b/src/ipv6.c index 829260b4..60f1ff8d 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -2301,14 +2301,15 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) const struct routeinfo *rinfo; const struct ipv6_addr *addr; struct in6_addr netmask; + + if (ctx->ra_routers == NULL) + return 0; + struct timespec now; uint32_t elapsed; clock_gettime(CLOCK_MONOTONIC, &now); - if (ctx->ra_routers == NULL) - return 0; - TAILQ_FOREACH(rap, ctx->ra_routers, next) { if (rap->expired) continue; @@ -2329,7 +2330,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rinfo->flags); #endif - elapsed = (uint32_t)eloop_timespec_diff(&now, &rap->acquired, NULL); + elapsed = (uint32_t)eloop_timespec_diff(&now, &rinfo->acquired, NULL); rt->rt_expires = rap->lifetime - elapsed; rt_proto_add(routes, rt); @@ -2345,7 +2346,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif - elapsed = (uint32_t)eloop_timespec_diff(&now, &rap->acquired, NULL); + elapsed = (uint32_t)eloop_timespec_diff(&now, &addr->acquired, NULL); rt->rt_expires = rap->lifetime - elapsed; rt_proto_add(routes, rt); From 4a07e739a37160d4f33d97b29b936b2f8c8e611a Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Thu, 9 Jan 2025 11:59:29 -0600 Subject: [PATCH 09/18] Only send non-zero route lifetime to NETLINK --- src/if-linux.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/if-linux.c b/src/if-linux.c index e8d2c85b..4dad05da 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -753,9 +753,14 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm) break; } case RTA_EXPIRES: - rt->rt_expires = *(uint32_t *)RTA_DATA(rta); + { + if (rt->rt_expires != 0) + { + rt->rt_expires = *(uint32_t *)RTA_DATA(rta); + } break; } + } if (sa != NULL) { socklen_t salen; From fb70fe8c553e2d5b8ddb297c572f0b9dbd0a3bbb Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Thu, 9 Jan 2025 12:01:44 -0600 Subject: [PATCH 10/18] Only send non-zero route lifetime to NETLINK --- src/if-linux.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/if-linux.c b/src/if-linux.c index 4dad05da..96bcbbb9 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -754,10 +754,7 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm) } case RTA_EXPIRES: { - if (rt->rt_expires != 0) - { - rt->rt_expires = *(uint32_t *)RTA_DATA(rta); - } + rt->rt_expires = *(uint32_t *)RTA_DATA(rta); break; } } @@ -1744,7 +1741,8 @@ if_route(unsigned char cmd, const struct rt *rt) add_attr_32(&nlm.hdr, sizeof(nlm), RTA_OIF, rt->rt_ifp->index); /* add route lifetime */ - add_attr_32(&nlm.hdr, sizeof(nlm), RTA_EXPIRES, rt->rt_expires); + if (rt->rt_expires != 0) + add_attr_32(&nlm.hdr, sizeof(nlm), RTA_EXPIRES, rt->rt_expires); if (rt->rt_metric != 0) add_attr_32(&nlm.hdr, sizeof(nlm), RTA_PRIORITY, From 2d2e7bef015db8be339e3d12eeb75f18ebbc6930 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Fri, 10 Jan 2025 09:21:51 -0600 Subject: [PATCH 11/18] Move route lifetime calc to common func If not set to infinite, lifetime is shortened by time elapsed since acquired --- src/common.c | 14 ++++++++++++++ src/common.h | 3 +++ src/ipv6.c | 11 +++-------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/common.c b/src/common.c index 0558ccbe..3d5a0f93 100644 --- a/src/common.c +++ b/src/common.c @@ -214,3 +214,17 @@ is_root_local(void) return -1; #endif } + +uint32_t +lifetime_left(uint32_t lifetime, const struct timespec *aquired, const struct timespec *now) +{ + uint32_t elpased; + + if (lifetime == INFINITE_LIFETIME) + return lifetime; + + elapsed = (uint32_t)eloop_timespec_diff(now, &acquired, NULL); + if (elapsed > lifetime) + return 0; + return lifetime - elapsed; +} diff --git a/src/common.h b/src/common.h index 97fffa5b..096f6bd4 100644 --- a/src/common.h +++ b/src/common.h @@ -141,6 +141,8 @@ # endif #endif +#define INFINITE_LIFETIME (~0U) + const char *hwaddr_ntoa(const void *, size_t, char *, size_t); size_t hwaddr_aton(uint8_t *, const char *); ssize_t readfile(const char *, void *, size_t); @@ -148,4 +150,5 @@ ssize_t writefile(const char *, mode_t, const void *, size_t); int filemtime(const char *, time_t *); char *get_line(char ** __restrict, ssize_t * __restrict); int is_root_local(void); +uint32_t lifetime_left(uint32_t, const struct timespec *, const struct timespec *); #endif diff --git a/src/ipv6.c b/src/ipv6.c index 60f1ff8d..9948d021 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -2306,8 +2306,6 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) return 0; struct timespec now; - uint32_t elapsed; - clock_gettime(CLOCK_MONOTONIC, &now); TAILQ_FOREACH(rap, ctx->ra_routers, next) { @@ -2330,8 +2328,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rinfo->flags); #endif - elapsed = (uint32_t)eloop_timespec_diff(&now, &rinfo->acquired, NULL); - rt->rt_expires = rap->lifetime - elapsed; + rt->rt_expires = lifetime_left(rap->lifetime, &rinfo->aquired, &now); rt_proto_add(routes, rt); } @@ -2346,8 +2343,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif - elapsed = (uint32_t)eloop_timespec_diff(&now, &addr->acquired, NULL); - rt->rt_expires = rap->lifetime - elapsed; + rt->rt_expires = lifetime_left(rap->lifetime, &addr->aquired, &now); rt_proto_add(routes, rt); } @@ -2380,8 +2376,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif - elapsed = (uint32_t)eloop_timespec_diff(&now, &rap->acquired, NULL); - rt->rt_expires = rap->lifetime - elapsed; + rt->rt_expires = lifetime_left(rap->lifetime, &rap->aquired, &now); rt_proto_add(routes, rt); } From 0f13be7a0e22f418fc117ec8bf57e263f4c76d10 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Fri, 10 Jan 2025 09:31:48 -0600 Subject: [PATCH 12/18] Fixed typos and missing header --- src/common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common.c b/src/common.c index 3d5a0f93..a3cc83b9 100644 --- a/src/common.c +++ b/src/common.c @@ -38,6 +38,7 @@ #include "common.h" #include "dhcpcd.h" +#include "eloop.h" #include "if-options.h" const char * @@ -216,9 +217,9 @@ is_root_local(void) } uint32_t -lifetime_left(uint32_t lifetime, const struct timespec *aquired, const struct timespec *now) +lifetime_left(uint32_t lifetime, const struct timespec *acquired, const struct timespec *now) { - uint32_t elpased; + uint32_t elapsed; if (lifetime == INFINITE_LIFETIME) return lifetime; From 8453c573da7e51ed70792244fc7bfc4543d76757 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Fri, 10 Jan 2025 09:33:23 -0600 Subject: [PATCH 13/18] Typo in route acquired --- src/ipv6.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ipv6.c b/src/ipv6.c index 9948d021..5128e524 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -2328,7 +2328,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rinfo->flags); #endif - rt->rt_expires = lifetime_left(rap->lifetime, &rinfo->aquired, &now); + rt->rt_expires = lifetime_left(rap->lifetime, &rinfo->acquired, &now); rt_proto_add(routes, rt); } @@ -2343,7 +2343,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif - rt->rt_expires = lifetime_left(rap->lifetime, &addr->aquired, &now); + rt->rt_expires = lifetime_left(rap->lifetime, &addr->acquired, &now); rt_proto_add(routes, rt); } @@ -2376,7 +2376,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif - rt->rt_expires = lifetime_left(rap->lifetime, &rap->aquired, &now); + rt->rt_expires = lifetime_left(rap->lifetime, &rap->acquired, &now); rt_proto_add(routes, rt); } From 1974f2ede4e5cb810ff2ae5d2dc6ce28954ff4e2 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 13 Jan 2025 09:42:08 -0600 Subject: [PATCH 14/18] Use correct route lifetime sources for rinfo and addr --- src/ipv6.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ipv6.c b/src/ipv6.c index 5128e524..e1aa6dca 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -730,7 +730,7 @@ ipv6_addaddr1(struct ipv6_addr *ia, const struct timespec *now) else ia->prefix_pltime -= elapsed; } - if (ia->prefix_vltime != ND6_INFINITE_LIFETIME) { + if (ia->prefix_vltime != ND6_INFINITE_) { if (elapsed > ia->prefix_vltime) ia->prefix_vltime = 0; else @@ -2328,7 +2328,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rinfo->flags); #endif - rt->rt_expires = lifetime_left(rap->lifetime, &rinfo->acquired, &now); + rt->rt_expires = lifetime_left(rinfo->lifetime, &rinfo->acquired, &now); rt_proto_add(routes, rt); } @@ -2343,7 +2343,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) #ifdef HAVE_ROUTE_PREF rt->rt_pref = ipv6nd_rtpref(rap->flags); #endif - rt->rt_expires = lifetime_left(rap->lifetime, &addr->acquired, &now); + rt->rt_expires = lifetime_left(addr->prefix_vltime, &addr->acquired, &now); rt_proto_add(routes, rt); } From cfcf427f833696ac20c4c01f89b9478d6f29e720 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 13 Jan 2025 09:43:20 -0600 Subject: [PATCH 15/18] Fix whitespace --- src/common.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common.c b/src/common.c index a3cc83b9..02e37a7b 100644 --- a/src/common.c +++ b/src/common.c @@ -219,13 +219,14 @@ is_root_local(void) uint32_t lifetime_left(uint32_t lifetime, const struct timespec *acquired, const struct timespec *now) { - uint32_t elapsed; + uint32_t elapsed; - if (lifetime == INFINITE_LIFETIME) - return lifetime; + if (lifetime == INFINITE_LIFETIME) + return lifetime; - elapsed = (uint32_t)eloop_timespec_diff(now, &acquired, NULL); - if (elapsed > lifetime) - return 0; - return lifetime - elapsed; + elapsed = (uint32_t)eloop_timespec_diff(now, &acquired, NULL); + if (elapsed > lifetime) + return 0; + + return lifetime - elapsed; } From cbb58c4e35cf1b2beb2d663ac0e2037edbc8fd92 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Mon, 13 Jan 2025 17:31:37 -0600 Subject: [PATCH 16/18] Fixed ND6_INFINITE_LIFETIME truncation --- src/ipv6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipv6.c b/src/ipv6.c index e1aa6dca..4866774f 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -730,7 +730,7 @@ ipv6_addaddr1(struct ipv6_addr *ia, const struct timespec *now) else ia->prefix_pltime -= elapsed; } - if (ia->prefix_vltime != ND6_INFINITE_) { + if (ia->prefix_vltime != ND6_INFINITE_LIFETIME) { if (elapsed > ia->prefix_vltime) ia->prefix_vltime = 0; else From 2637f07c06c754106b84ad920b297e1578193a17 Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Tue, 14 Jan 2025 08:19:11 -0600 Subject: [PATCH 17/18] Pass acquired-time pointer by value --- src/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index 02e37a7b..03bb33c1 100644 --- a/src/common.c +++ b/src/common.c @@ -224,7 +224,7 @@ lifetime_left(uint32_t lifetime, const struct timespec *acquired, const struct t if (lifetime == INFINITE_LIFETIME) return lifetime; - elapsed = (uint32_t)eloop_timespec_diff(now, &acquired, NULL); + elapsed = (uint32_t)eloop_timespec_diff(now, acquired, NULL); if (elapsed > lifetime) return 0; From 5179c464009b87f65072f297395a05a731dffa9e Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Tue, 14 Jan 2025 08:21:09 -0600 Subject: [PATCH 18/18] Move variable declaration to top of scope --- src/ipv6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipv6.c b/src/ipv6.c index 4866774f..c867626e 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -2301,11 +2301,11 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx) const struct routeinfo *rinfo; const struct ipv6_addr *addr; struct in6_addr netmask; + struct timespec now; if (ctx->ra_routers == NULL) return 0; - struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); TAILQ_FOREACH(rap, ctx->ra_routers, next) {