mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-11-25 02:53:28 +08:00
As DHCPv6 can remove addresses with vltime 0 as well as a RA,
move the check into probeaddresses to save on duplication.
This commit is contained in:
parent
dc222356db
commit
78ae729605
12
ipv6ns.c
12
ipv6ns.c
@ -388,9 +388,11 @@ ipv6ns_probeaddrs(struct ipv6_addrhead *addrs)
|
||||
TAILQ_FOREACH_SAFE(ap, addrs, next, apn) {
|
||||
if (ap->prefix_vltime == 0) {
|
||||
TAILQ_REMOVE(addrs, ap, next);
|
||||
if (ap->flags & IPV6_AF_ADDED)
|
||||
if (ap->flags & IPV6_AF_ADDED) {
|
||||
syslog(LOG_INFO, "%s: deleting address %s",
|
||||
ap->iface->name, ap->saddr);
|
||||
i++;
|
||||
}
|
||||
if (del_address6(ap) == -1 &&
|
||||
errno != EADDRNOTAVAIL)
|
||||
syslog(LOG_ERR, "del_address6 %m");
|
||||
@ -495,6 +497,14 @@ ipv6ns_proberouter(void *arg)
|
||||
ipv6ns_unreachable, rap);
|
||||
}
|
||||
|
||||
void
|
||||
ipv6ns_cancelproberouter(struct ra *rap)
|
||||
{
|
||||
|
||||
eloop_timeout_delete(ipv6ns_proberouter, rap);
|
||||
eloop_timeout_delete(ipv6ns_unreachable, rap);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
ipv6ns_handledata(__unused void *arg)
|
||||
|
1
ipv6ns.h
1
ipv6ns.h
@ -39,6 +39,7 @@
|
||||
void ipv6ns_probeaddr(void *);
|
||||
ssize_t ipv6ns_probeaddrs(struct ipv6_addrhead *);
|
||||
void ipv6ns_proberouter(void *);
|
||||
void ipv6ns_cancelproberouter(struct ra *);
|
||||
|
||||
#ifdef LISTEN_DAD
|
||||
void ipv6ns_cancelprobeaddr(struct ipv6_addr *);
|
||||
|
39
ipv6rs.c
39
ipv6rs.c
@ -1110,22 +1110,6 @@ ipv6rs_findprefix(const struct ipv6_addr *a)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct ipv6_addr *
|
||||
ipv6rs_findsameaddr(const struct ipv6_addr *ap)
|
||||
{
|
||||
const struct ra *rap;
|
||||
const struct ipv6_addr *a;
|
||||
|
||||
TAILQ_FOREACH(rap, &ipv6_routers, next) {
|
||||
TAILQ_FOREACH(a, &rap->addrs, next) {
|
||||
if (ap != a &&
|
||||
memcmp(&a->addr, &ap->addr, sizeof(ap->addr) == 0))
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ipv6rs_handleifa(int cmd, const char *ifname,
|
||||
const struct in6_addr *addr, int flags)
|
||||
@ -1144,7 +1128,6 @@ ipv6rs_expire(void *arg)
|
||||
{
|
||||
struct interface *ifp;
|
||||
struct ra *rap, *ran;
|
||||
struct ipv6_addr *ap, *apn;
|
||||
struct ra_opt *rao, *raon;
|
||||
struct timeval now, lt, expire, next;
|
||||
int expired, valid;
|
||||
@ -1167,6 +1150,7 @@ ipv6rs_expire(void *arg)
|
||||
"%s: %s: expired default Router",
|
||||
ifp->name, rap->sfrom);
|
||||
rap->expired = expired = 1;
|
||||
ipv6ns_cancelproberouter(rap);
|
||||
}
|
||||
} else {
|
||||
valid = 1;
|
||||
@ -1175,25 +1159,8 @@ ipv6rs_expire(void *arg)
|
||||
next = lt;
|
||||
}
|
||||
|
||||
if (options & DHCPCD_IPV6RA_OWN) {
|
||||
TAILQ_FOREACH_SAFE(ap, &rap->addrs, next, apn) {
|
||||
lt.tv_sec = ap->prefix_vltime;
|
||||
lt.tv_usec = 0;
|
||||
timeradd(&rap->received, <, &expire);
|
||||
if (timercmp(&now, &expire, >) &&
|
||||
ipv6rs_findsameaddr(ap) == NULL)
|
||||
{
|
||||
syslog(LOG_WARNING,
|
||||
"%s: %s: expired address",
|
||||
ifp->name, ap->saddr);
|
||||
eloop_timeout_delete(NULL, ap);
|
||||
TAILQ_REMOVE(&rap->addrs, ap, next);
|
||||
free(ap);
|
||||
/* No need to delete it as the kernel
|
||||
* should have done this. */
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Addresses are expired in ipv6ns_probeaddrs
|
||||
* so that DHCPv6 addresses can be removed also. */
|
||||
|
||||
TAILQ_FOREACH_SAFE(rao, &rap->options, next, raon) {
|
||||
if (rap->expired) {
|
||||
|
Loading…
Reference in New Issue
Block a user