@@ -597,7 +597,7 @@ ipv6_checkaddrflags(void *arg)
597597 /* Simulate the kernel announcing the new address. */
598598 ipv6_handleifa (ia -> iface -> ctx , RTM_NEWADDR ,
599599 ia -> iface -> ctx -> ifaces , ia -> iface -> name ,
600- & ia -> addr , ia -> prefix_len , flags , 0 );
600+ & ia -> addr , ia -> prefix_len , ia -> dstaddr , flags , 0 );
601601 } else {
602602 /* Still tentative? Check again in a bit. */
603603 eloop_timeout_add_msec (ia -> iface -> ctx -> eloop ,
@@ -1108,7 +1108,8 @@ ipv6_anyglobal(struct interface *sifp)
11081108void
11091109ipv6_handleifa (struct dhcpcd_ctx * ctx ,
11101110 int cmd , struct if_head * ifs , const char * ifname ,
1111- const struct in6_addr * addr , uint8_t prefix_len , int addrflags , pid_t pid )
1111+ const struct in6_addr * addr , uint8_t prefix_len ,
1112+ const struct in6_addr * dstaddr , int addrflags , pid_t pid )
11121113{
11131114 struct interface * ifp ;
11141115 struct ipv6_state * state ;
@@ -1132,13 +1133,15 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx,
11321133#endif
11331134
11341135#if 0
1135- char dbuf [INET6_ADDRSTRLEN ];
1136- const char * dbp ;
1137-
1138- dbp = inet_ntop (AF_INET6 , & addr -> s6_addr ,
1139- dbuf , INET6_ADDRSTRLEN );
1140- loginfox ("%s: cmd %d addr %s addrflags %d" ,
1141- ifname , cmd , dbp , addrflags );
1136+ char abuf [INET6_ADDRSTRLEN ], dbuf [INET6_ADDRSTRLEN ];
1137+ const char * abp , * dbp ;
1138+
1139+ abp = inet_ntop (AF_INET6 , & addr -> s6_addr , abuf , sizeof (abuf ));
1140+ dbp = dstaddr ?
1141+ inet_ntop (AF_INET6 , & dstaddr -> s6_addr , dbuf , sizeof (dbuf ))
1142+ : "::" ;
1143+ loginfox ("%s: cmd %d addr %s dstaddr %s addrflags %d" ,
1144+ ifname , cmd , abp , dbp , addrflags );
11421145#endif
11431146
11441147 if (ifs == NULL )
@@ -1199,6 +1202,7 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx,
11991202 ia -> addr_flags = addrflags ;
12001203 TAILQ_INSERT_TAIL (& state -> addrs , ia , next );
12011204 }
1205+ ia -> dstaddr = dstaddr ? * dstaddr : in6addr_any ;
12021206 ia -> flags &= ~IPV6_AF_STALE ;
12031207#ifdef IPV6_MANAGETEMPADDR
12041208 if (ia -> addr_flags & IN6_IFF_TEMPORARY )
@@ -1338,6 +1342,37 @@ ipv6_findmaskaddr(struct dhcpcd_ctx *ctx, const struct in6_addr *addr)
13381342 return NULL ;
13391343}
13401344
1345+
1346+ static struct ipv6_addr *
1347+ ipv6_iffinddstaddr (const struct interface * ifp , const struct in6_addr * addr )
1348+ {
1349+ struct ipv6_state * state ;
1350+ struct ipv6_addr * ap ;
1351+
1352+ state = IPV6_STATE (ifp );
1353+ if (state ) {
1354+ TAILQ_FOREACH (ap , & state -> addrs , next ) {
1355+ if (IN6_ARE_ADDR_EQUAL (& ap -> dstaddr , addr ))
1356+ return ap ;
1357+ }
1358+ }
1359+ return NULL ;
1360+ }
1361+
1362+ struct ipv6_addr *
1363+ ipv6_finddstaddr (struct dhcpcd_ctx * ctx , const struct in6_addr * addr )
1364+ {
1365+ struct interface * ifp ;
1366+ struct ipv6_addr * ap ;
1367+
1368+ TAILQ_FOREACH (ifp , ctx -> ifaces , next ) {
1369+ ap = ipv6_iffinddstaddr (ifp , addr );
1370+ if (ap != NULL )
1371+ return ap ;
1372+ }
1373+ return NULL ;
1374+ }
1375+
13411376int
13421377ipv6_addlinklocalcallback (struct interface * ifp ,
13431378 void (* callback )(void * ), void * arg )
@@ -2145,7 +2180,8 @@ ipv6_deletestaleaddrs(struct interface *ifp)
21452180 if (ia -> flags & IPV6_AF_STALE )
21462181 ipv6_handleifa (ifp -> ctx , RTM_DELADDR ,
21472182 ifp -> ctx -> ifaces , ifp -> name ,
2148- & ia -> addr , ia -> prefix_len , 0 , getpid ());
2183+ & ia -> addr , ia -> prefix_len ,
2184+ & ia -> dstaddr , 0 , getpid ());
21492185 }
21502186}
21512187
0 commit comments