@@ -674,7 +674,7 @@ ipv6_getstate(struct interface *ifp)
674674}
675675
676676static int
677- ipv6_addaddr1 (struct ipv6_addr * ia , const struct timespec * now )
677+ ipv6_addaddr1 (struct ipv6_addr * ia , struct timespec * now )
678678{
679679 struct interface * ifp ;
680680 uint32_t pltime , vltime ;
@@ -711,31 +711,11 @@ ipv6_addaddr1(struct ipv6_addr *ia, const struct timespec *now)
711711 ia -> prefix_vltime = ia -> prefix_pltime = ND6_INFINITE_LIFETIME ;
712712 }
713713
714- if (timespecisset (& ia -> acquired ) &&
715- (ia -> prefix_pltime != ND6_INFINITE_LIFETIME ||
716- ia -> prefix_vltime != ND6_INFINITE_LIFETIME ))
717- {
718- uint32_t elapsed ;
719- struct timespec n ;
720-
721- if (now == NULL ) {
722- clock_gettime (CLOCK_MONOTONIC , & n );
723- now = & n ;
724- }
725- elapsed = (uint32_t )eloop_timespec_diff (now , & ia -> acquired ,
726- NULL );
727- if (ia -> prefix_pltime != ND6_INFINITE_LIFETIME ) {
728- if (elapsed > ia -> prefix_pltime )
729- ia -> prefix_pltime = 0 ;
730- else
731- ia -> prefix_pltime -= elapsed ;
732- }
733- if (ia -> prefix_vltime != ND6_INFINITE_LIFETIME ) {
734- if (elapsed > ia -> prefix_vltime )
735- ia -> prefix_vltime = 0 ;
736- else
737- ia -> prefix_vltime -= elapsed ;
738- }
714+ if (timespecisset (& ia -> acquired )) {
715+ ia -> prefix_pltime = lifetime_left (ia -> prefix_pltime ,
716+ & ia -> acquired , now );
717+ ia -> prefix_vltime = lifetime_left (ia -> prefix_vltime ,
718+ & ia -> acquired , now );
739719 }
740720
741721 loglevel = ia -> flags & IPV6_AF_NEW ? LOG_INFO : LOG_DEBUG ;
@@ -880,7 +860,7 @@ ipv6_aliasaddr(struct ipv6_addr *ia, struct ipv6_addr **repl)
880860#endif
881861
882862int
883- ipv6_addaddr (struct ipv6_addr * ia , const struct timespec * now )
863+ ipv6_addaddr (struct ipv6_addr * ia , struct timespec * now )
884864{
885865 int r ;
886866#ifdef ALIAS_ADDR
@@ -975,8 +955,6 @@ ipv6_doaddr(struct ipv6_addr *ia, struct timespec *now)
975955 IN6_IS_ADDR_UNSPECIFIED (& ia -> addr ))
976956 return 0 ;
977957
978- if (!timespecisset (now ))
979- clock_gettime (CLOCK_MONOTONIC , now );
980958 ipv6_addaddr (ia , now );
981959 return ia -> flags & IPV6_AF_NEW ? 1 : 0 ;
982960}
@@ -1070,12 +1048,7 @@ ipv6_freedrop_addrs(struct ipv6_addrhead *addrs, int drop,
10701048 ipv6_deleteaddr (ap );
10711049 if (!(ap -> iface -> options -> options &
10721050 DHCPCD_EXITING ) && apf )
1073- {
1074- if (!timespecisset (& now ))
1075- clock_gettime (CLOCK_MONOTONIC ,
1076- & now );
10771051 ipv6_addaddr (apf , & now );
1078- }
10791052 if (drop == 2 )
10801053 ipv6_freeaddr (ap );
10811054 }
@@ -2073,7 +2046,7 @@ ipv6_settemptime(struct ipv6_addr *ia, int flags)
20732046}
20742047
20752048void
2076- ipv6_addtempaddrs (struct interface * ifp , const struct timespec * now )
2049+ ipv6_addtempaddrs (struct interface * ifp , struct timespec * now )
20772050{
20782051 struct ipv6_state * state ;
20792052 struct ipv6_addr * ia ;
@@ -2306,7 +2279,7 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
23062279 if (ctx -> ra_routers == NULL )
23072280 return 0 ;
23082281
2309- clock_gettime ( CLOCK_MONOTONIC , & now );
2282+ timespecclear ( & now );
23102283
23112284 TAILQ_FOREACH (rap , ctx -> ra_routers , next ) {
23122285 if (rap -> expired )
@@ -2328,7 +2301,8 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
23282301#ifdef HAVE_ROUTE_PREF
23292302 rt -> rt_pref = ipv6nd_rtpref (rinfo -> flags );
23302303#endif
2331- rt -> rt_expires = lifetime_left (rinfo -> lifetime , & rinfo -> acquired , & now );
2304+ rt -> rt_expires = lifetime_left (rinfo -> lifetime ,
2305+ & rinfo -> acquired , & now );
23322306
23332307 rt_proto_add (routes , rt );
23342308 }
@@ -2343,7 +2317,9 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
23432317#ifdef HAVE_ROUTE_PREF
23442318 rt -> rt_pref = ipv6nd_rtpref (rap -> flags );
23452319#endif
2346- rt -> rt_expires = lifetime_left (addr -> prefix_vltime , & addr -> acquired , & now );
2320+ rt -> rt_expires =
2321+ lifetime_left (addr -> prefix_vltime ,
2322+ & addr -> acquired , & now );
23472323
23482324 rt_proto_add (routes , rt );
23492325 }
@@ -2376,7 +2352,8 @@ inet6_raroutes(rb_tree_t *routes, struct dhcpcd_ctx *ctx)
23762352#ifdef HAVE_ROUTE_PREF
23772353 rt -> rt_pref = ipv6nd_rtpref (rap -> flags );
23782354#endif
2379- rt -> rt_expires = lifetime_left (rap -> lifetime , & rap -> acquired , & now );
2355+ rt -> rt_expires = lifetime_left (rap -> lifetime ,
2356+ & rap -> acquired , & now );
23802357
23812358 rt_proto_add (routes , rt );
23822359 }
0 commit comments