-/* $OpenBSD: in6.c,v 1.127 2014/01/07 16:34:05 stsp Exp $ */
+/* $OpenBSD: in6.c,v 1.128 2014/01/13 23:03:52 bluhm Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
void
in6_ifremloop(struct ifaddr *ifa)
{
- struct in6_ifaddr *ia;
+ struct in6_ifaddr *ia6;
struct rtentry *rt;
int ia_count = 0;
* (probably p2p) interfaces.
* XXX: we should avoid such a configuration in IPv6...
*/
- TAILQ_FOREACH(ia, &in6_ifaddr, ia_list) {
- if (IN6_ARE_ADDR_EQUAL(IFA_IN6(ifa), &ia->ia_addr.sin6_addr)) {
+ TAILQ_FOREACH(ia6, &in6_ifaddr, ia_list) {
+ if (IN6_ARE_ADDR_EQUAL(IFA_IN6(ifa), &ia6->ia_addr.sin6_addr)) {
ia_count++;
if (ia_count > 1)
break;
in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp)
{
struct in6_ifreq *ifr = (struct in6_ifreq *)data;
- struct in6_ifaddr *ia = NULL;
+ struct in6_ifaddr *ia6 = NULL;
struct in6_aliasreq *ifra = (struct in6_aliasreq *)data;
struct sockaddr_in6 *sa6;
int privileged;
sa6->sin6_scope_id = 0; /* XXX: good way? */
}
}
- ia = in6ifa_ifpwithaddr(ifp, &sa6->sin6_addr);
+ ia6 = in6ifa_ifpwithaddr(ifp, &sa6->sin6_addr);
} else
- ia = NULL;
+ ia6 = NULL;
switch (cmd) {
case SIOCSIFADDR_IN6:
* interface address from the day one, we consider "remove the
* first one" semantics to be not preferable.
*/
- if (ia == NULL)
+ if (ia6 == NULL)
return (EADDRNOTAVAIL);
/* FALLTHROUGH */
case SIOCAIFADDR_IN6:
case SIOCGIFDSTADDR_IN6:
case SIOCGIFALIFETIME_IN6:
/* must think again about its semantics */
- if (ia == NULL)
+ if (ia6 == NULL)
return (EADDRNOTAVAIL);
break;
case SIOCSIFALIFETIME_IN6:
if (!privileged)
return (EPERM);
- if (ia == NULL)
+ if (ia6 == NULL)
return (EADDRNOTAVAIL);
/* sanity for overflow - beware unsigned */
lt = &ifr->ifr_ifru.ifru_lifetime;
switch (cmd) {
case SIOCGIFADDR_IN6:
- ifr->ifr_addr = ia->ia_addr;
+ ifr->ifr_addr = ia6->ia_addr;
break;
case SIOCGIFDSTADDR_IN6:
* XXX: should we check if ifa_dstaddr is NULL and return
* an error?
*/
- ifr->ifr_dstaddr = ia->ia_dstaddr;
+ ifr->ifr_dstaddr = ia6->ia_dstaddr;
break;
case SIOCGIFNETMASK_IN6:
- ifr->ifr_addr = ia->ia_prefixmask;
+ ifr->ifr_addr = ia6->ia_prefixmask;
break;
case SIOCGIFAFLAG_IN6:
- ifr->ifr_ifru.ifru_flags6 = ia->ia6_flags;
+ ifr->ifr_ifru.ifru_flags6 = ia6->ia6_flags;
break;
case SIOCGIFSTAT_IN6:
break;
case SIOCGIFALIFETIME_IN6:
- ifr->ifr_ifru.ifru_lifetime = ia->ia6_lifetime;
- if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
+ ifr->ifr_ifru.ifru_lifetime = ia6->ia6_lifetime;
+ if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
time_t maxexpire;
struct in6_addrlifetime *retlt =
&ifr->ifr_ifru.ifru_lifetime;
*/
maxexpire =
(time_t)~(1ULL << ((sizeof(maxexpire) * 8) - 1));
- if (ia->ia6_lifetime.ia6t_vltime <
- maxexpire - ia->ia6_updatetime) {
- retlt->ia6t_expire = ia->ia6_updatetime +
- ia->ia6_lifetime.ia6t_vltime;
+ if (ia6->ia6_lifetime.ia6t_vltime <
+ maxexpire - ia6->ia6_updatetime) {
+ retlt->ia6t_expire = ia6->ia6_updatetime +
+ ia6->ia6_lifetime.ia6t_vltime;
} else
retlt->ia6t_expire = maxexpire;
}
- if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
+ if (ia6->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
time_t maxexpire;
struct in6_addrlifetime *retlt =
&ifr->ifr_ifru.ifru_lifetime;
*/
maxexpire =
(time_t)~(1ULL << ((sizeof(maxexpire) * 8) - 1));
- if (ia->ia6_lifetime.ia6t_pltime <
- maxexpire - ia->ia6_updatetime) {
- retlt->ia6t_preferred = ia->ia6_updatetime +
- ia->ia6_lifetime.ia6t_pltime;
+ if (ia6->ia6_lifetime.ia6t_pltime <
+ maxexpire - ia6->ia6_updatetime) {
+ retlt->ia6t_preferred = ia6->ia6_updatetime +
+ ia6->ia6_lifetime.ia6t_pltime;
} else
retlt->ia6t_preferred = maxexpire;
}
break;
case SIOCSIFALIFETIME_IN6:
- ia->ia6_lifetime = ifr->ifr_ifru.ifru_lifetime;
+ ia6->ia6_lifetime = ifr->ifr_ifru.ifru_lifetime;
/* for sanity */
- if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
- ia->ia6_lifetime.ia6t_expire =
- time_second + ia->ia6_lifetime.ia6t_vltime;
+ if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
+ ia6->ia6_lifetime.ia6t_expire =
+ time_second + ia6->ia6_lifetime.ia6t_vltime;
} else
- ia->ia6_lifetime.ia6t_expire = 0;
- if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
- ia->ia6_lifetime.ia6t_preferred =
- time_second + ia->ia6_lifetime.ia6t_pltime;
+ ia6->ia6_lifetime.ia6t_expire = 0;
+ if (ia6->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
+ ia6->ia6_lifetime.ia6t_preferred =
+ time_second + ia6->ia6_lifetime.ia6t_pltime;
} else
- ia->ia6_lifetime.ia6t_preferred = 0;
+ ia6->ia6_lifetime.ia6t_preferred = 0;
break;
case SIOCAIFADDR_IN6:
* and link it to the list.
*/
s = splsoftnet();
- error = in6_update_ifa(ifp, ifra, ia);
+ error = in6_update_ifa(ifp, ifra, ia6);
splx(s);
if (error != 0)
return (error);
- if ((ia = in6ifa_ifpwithaddr(ifp, &ifra->ifra_addr.sin6_addr))
+ if ((ia6 = in6ifa_ifpwithaddr(ifp, &ifra->ifra_addr.sin6_addr))
== NULL) {
/*
* this can happen when the user specify the 0 valid
}
/* relate the address to the prefix */
- if (ia->ia6_ndpr == NULL) {
- ia->ia6_ndpr = pr;
+ if (ia6->ia6_ndpr == NULL) {
+ ia6->ia6_ndpr = pr;
pr->ndpr_refcnt++;
}
}
case SIOCDIFADDR_IN6:
- in6_purgeaddr(&ia->ia_ifa);
+ in6_purgeaddr(&ia6->ia_ifa);
dohooks(ifp->if_addrhooks, 0);
break;
*/
int
in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
- struct in6_ifaddr *ia)
+ struct in6_ifaddr *ia6)
{
int error = 0, hostIsNew = 0, plen = -1;
struct sockaddr_in6 dst6;
* We also require the prefix (when specified) mask is valid, and thus
* reject a non-consecutive mask.
*/
- if (ia == NULL && ifra->ifra_prefixmask.sin6_len == 0)
+ if (ia6 == NULL && ifra->ifra_prefixmask.sin6_len == 0)
return (EINVAL);
if (ifra->ifra_prefixmask.sin6_len != 0) {
plen = in6_mask2len(&ifra->ifra_prefixmask.sin6_addr,
return (EINVAL);
} else {
/*
- * In this case, ia must not be NULL. We just use its prefix
+ * In this case, ia6 must not be NULL. We just use its prefix
* length.
*/
- plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL);
+ plen = in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL);
}
/*
* If the destination address on a p2p interface is specified,
inet_ntop(AF_INET6, &ifra->ifra_addr.sin6_addr,
addr, sizeof(addr))));
- if (ia == NULL)
+ if (ia6 == NULL)
return (0); /* there's nothing to do */
}
* If this is a new address, allocate a new ifaddr and link it
* into chains.
*/
- if (ia == NULL) {
+ if (ia6 == NULL) {
hostIsNew = 1;
- ia = malloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO);
- LIST_INIT(&ia->ia6_memberships);
+ ia6 = malloc(sizeof(*ia6), M_IFADDR, M_WAITOK | M_ZERO);
+ LIST_INIT(&ia6->ia6_memberships);
/* Initialize the address and masks, and put time stamp */
- ia->ia_ifa.ifa_addr = sin6tosa(&ia->ia_addr);
- ia->ia_addr.sin6_family = AF_INET6;
- ia->ia_addr.sin6_len = sizeof(ia->ia_addr);
- ia->ia6_createtime = ia->ia6_updatetime = time_second;
+ ia6->ia_ifa.ifa_addr = sin6tosa(&ia6->ia_addr);
+ ia6->ia_addr.sin6_family = AF_INET6;
+ ia6->ia_addr.sin6_len = sizeof(ia6->ia_addr);
+ ia6->ia6_createtime = ia6->ia6_updatetime = time_second;
if ((ifp->if_flags & (IFF_POINTOPOINT | IFF_LOOPBACK)) != 0) {
/*
* XXX: some functions expect that ifa_dstaddr is not
* NULL for p2p interfaces.
*/
- ia->ia_ifa.ifa_dstaddr = sin6tosa(&ia->ia_dstaddr);
+ ia6->ia_ifa.ifa_dstaddr = sin6tosa(&ia6->ia_dstaddr);
} else {
- ia->ia_ifa.ifa_dstaddr = NULL;
+ ia6->ia_ifa.ifa_dstaddr = NULL;
}
- ia->ia_ifa.ifa_netmask = sin6tosa(&ia->ia_prefixmask);
+ ia6->ia_ifa.ifa_netmask = sin6tosa(&ia6->ia_prefixmask);
- ia->ia_ifp = ifp;
- TAILQ_INSERT_TAIL(&in6_ifaddr, ia, ia_list);
- ia->ia_addr = ifra->ifra_addr;
- ifa_add(ifp, &ia->ia_ifa);
+ ia6->ia_ifp = ifp;
+ TAILQ_INSERT_TAIL(&in6_ifaddr, ia6, ia_list);
+ ia6->ia_addr = ifra->ifra_addr;
+ ifa_add(ifp, &ia6->ia_ifa);
}
/* set prefix mask */
* + such an operation should be rare in IPv6, and
* + the operation would confuse prefix management.
*/
- if (ia->ia_prefixmask.sin6_len &&
- in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL) != plen) {
+ if (ia6->ia_prefixmask.sin6_len &&
+ in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL) != plen) {
nd6log((LOG_INFO, "in6_update_ifa: the prefix length of an"
" existing (%s) address should not be changed\n",
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr))));
error = EINVAL;
goto unlink;
}
- ia->ia_prefixmask = ifra->ifra_prefixmask;
+ ia6->ia_prefixmask = ifra->ifra_prefixmask;
}
/*
* p2p or loopback (see the check above.)
*/
if (dst6.sin6_family == AF_INET6 &&
- !IN6_ARE_ADDR_EQUAL(&dst6.sin6_addr, &ia->ia_dstaddr.sin6_addr)) {
+ !IN6_ARE_ADDR_EQUAL(&dst6.sin6_addr, &ia6->ia_dstaddr.sin6_addr)) {
int e;
- if ((ia->ia_flags & IFA_ROUTE) != 0 &&
- (e = rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST)) != 0) {
+ if ((ia6->ia_flags & IFA_ROUTE) != 0 &&
+ (e = rtinit(&(ia6->ia_ifa), (int)RTM_DELETE, RTF_HOST)) != 0) {
nd6log((LOG_ERR, "in6_update_ifa: failed to remove "
"a route to the old destination: %s\n",
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr))));
/* proceed anyway... */
} else
- ia->ia_flags &= ~IFA_ROUTE;
- ia->ia_dstaddr = dst6;
+ ia6->ia_flags &= ~IFA_ROUTE;
+ ia6->ia_dstaddr = dst6;
}
/*
* to see if the address is deprecated or invalidated, but initialize
* these members for applications.
*/
- ia->ia6_lifetime = ifra->ifra_lifetime;
- if (ia->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
- ia->ia6_lifetime.ia6t_expire =
- time_second + ia->ia6_lifetime.ia6t_vltime;
+ ia6->ia6_lifetime = ifra->ifra_lifetime;
+ if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME) {
+ ia6->ia6_lifetime.ia6t_expire =
+ time_second + ia6->ia6_lifetime.ia6t_vltime;
} else
- ia->ia6_lifetime.ia6t_expire = 0;
- if (ia->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
- ia->ia6_lifetime.ia6t_preferred =
- time_second + ia->ia6_lifetime.ia6t_pltime;
+ ia6->ia6_lifetime.ia6t_expire = 0;
+ if (ia6->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME) {
+ ia6->ia6_lifetime.ia6t_preferred =
+ time_second + ia6->ia6_lifetime.ia6t_pltime;
} else
- ia->ia6_lifetime.ia6t_preferred = 0;
+ ia6->ia6_lifetime.ia6t_preferred = 0;
/* reset the interface and routing table appropriately. */
- if ((error = in6_ifinit(ifp, ia, hostIsNew)) != 0)
+ if ((error = in6_ifinit(ifp, ia6, hostIsNew)) != 0)
goto unlink;
/*
* configure address flags.
*/
- ia->ia6_flags = ifra->ifra_flags;
+ ia6->ia6_flags = ifra->ifra_flags;
/*
* backward compatibility - if IN6_IFF_DEPRECATED is set from the
* userland, make it deprecated.
*/
if ((ifra->ifra_flags & IN6_IFF_DEPRECATED) != 0) {
- ia->ia6_lifetime.ia6t_pltime = 0;
- ia->ia6_lifetime.ia6t_preferred = time_second;
+ ia6->ia6_lifetime.ia6t_pltime = 0;
+ ia6->ia6_lifetime.ia6t_preferred = time_second;
}
/*
* Make the address tentative before joining multicast addresses,
* so that corresponding MLD responses would not have a tentative
* source address.
*/
- ia->ia6_flags &= ~IN6_IFF_DUPLICATED; /* safety */
+ ia6->ia6_flags &= ~IN6_IFF_DUPLICATED; /* safety */
if (hostIsNew && in6if_do_dad(ifp) &&
(ifra->ifra_flags & IN6_IFF_NODAD) == 0)
- ia->ia6_flags |= IN6_IFF_TENTATIVE;
+ ia6->ia6_flags |= IN6_IFF_TENTATIVE;
/*
* We are done if we have simply modified an existing address.
ifp->if_xname, error));
goto cleanup;
}
- LIST_INSERT_HEAD(&ia->ia6_memberships, imm, i6mm_chain);
+ LIST_INSERT_HEAD(&ia6->ia6_memberships, imm, i6mm_chain);
bzero(&mltmask, sizeof(mltmask));
mltmask.sin6_len = sizeof(struct sockaddr_in6);
bzero(&info, sizeof(info));
info.rti_info[RTAX_DST] = sin6tosa(&mltaddr);
- info.rti_info[RTAX_GATEWAY] = sin6tosa(&ia->ia_addr);
+ info.rti_info[RTAX_GATEWAY] = sin6tosa(&ia6->ia_addr);
info.rti_info[RTAX_NETMASK] = sin6tosa(&mltmask);
- info.rti_info[RTAX_IFA] = sin6tosa(&ia->ia_addr);
+ info.rti_info[RTAX_IFA] = sin6tosa(&ia6->ia_addr);
/* XXX: we need RTF_CLONING to fake nd6_rtrequest */
info.rti_flags = RTF_UP | RTF_CLONING;
error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, NULL,
ifp->if_xname, error));
goto cleanup;
}
- LIST_INSERT_HEAD(&ia->ia6_memberships, imm, i6mm_chain);
+ LIST_INSERT_HEAD(&ia6->ia6_memberships, imm, i6mm_chain);
/*
* join node information group address
ifp->if_xname, error));
/* XXX not very fatal, go on... */
} else {
- LIST_INSERT_HEAD(&ia->ia6_memberships,
+ LIST_INSERT_HEAD(&ia6->ia6_memberships,
imm, i6mm_chain);
}
}
bzero(&info, sizeof(info));
info.rti_info[RTAX_DST] = sin6tosa(&mltaddr);
- info.rti_info[RTAX_GATEWAY] = sin6tosa(&ia->ia_addr);
+ info.rti_info[RTAX_GATEWAY] = sin6tosa(&ia6->ia_addr);
info.rti_info[RTAX_NETMASK] = sin6tosa(&mltmask);
- info.rti_info[RTAX_IFA] = sin6tosa(&ia->ia_addr);
+ info.rti_info[RTAX_IFA] = sin6tosa(&ia6->ia_addr);
info.rti_flags = RTF_UP | RTF_CLONING;
error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED,
NULL, ifp->if_rdomain);
ifp->if_xname, error));
goto cleanup;
}
- LIST_INSERT_HEAD(&ia->ia6_memberships, imm, i6mm_chain);
+ LIST_INSERT_HEAD(&ia6->ia6_memberships, imm, i6mm_chain);
}
/*
if (hostIsNew && in6if_do_dad(ifp) &&
(ifra->ifra_flags & IN6_IFF_NODAD) == 0)
{
- nd6_dad_start(&ia->ia_ifa, NULL);
+ nd6_dad_start(&ia6->ia_ifa, NULL);
}
return (error);
* anyway.
*/
if (hostIsNew)
- in6_unlink_ifa(ia, ifp);
+ in6_unlink_ifa(ia6, ifp);
return (error);
cleanup:
- in6_purgeaddr(&ia->ia_ifa);
+ in6_purgeaddr(&ia6->ia_ifa);
return error;
}
in6_purgeaddr(struct ifaddr *ifa)
{
struct ifnet *ifp = ifa->ifa_ifp;
- struct in6_ifaddr *ia = ifatoia6(ifa);
+ struct in6_ifaddr *ia6 = ifatoia6(ifa);
struct in6_multi_mship *imm;
/* stop DAD processing */
* delete route to the destination of the address being purged.
* The interface must be p2p or loopback in this case.
*/
- if ((ia->ia_flags & IFA_ROUTE) != 0 && ia->ia_dstaddr.sin6_len != 0) {
+ if ((ia6->ia_flags & IFA_ROUTE) != 0 && ia6->ia_dstaddr.sin6_len != 0) {
int e;
- if ((e = rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST))
+ if ((e = rtinit(&(ia6->ia_ifa), (int)RTM_DELETE, RTF_HOST))
!= 0) {
char addr[INET6_ADDRSTRLEN];
log(LOG_ERR, "in6_purgeaddr: failed to remove "
"a route to the p2p destination: %s on %s, "
"errno=%d\n",
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr)),
ifp->if_xname, e);
/* proceed anyway... */
} else
- ia->ia_flags &= ~IFA_ROUTE;
+ ia6->ia_flags &= ~IFA_ROUTE;
}
/* Remove ownaddr's loopback rtentry, if it exists. */
- in6_ifremloop(&(ia->ia_ifa));
+ in6_ifremloop(&(ia6->ia_ifa));
/*
* leave from multicast groups we have joined for the interface
*/
- while (!LIST_EMPTY(&ia->ia6_memberships)) {
- imm = LIST_FIRST(&ia->ia6_memberships);
+ while (!LIST_EMPTY(&ia6->ia6_memberships)) {
+ imm = LIST_FIRST(&ia6->ia6_memberships);
LIST_REMOVE(imm, i6mm_chain);
in6_leavegroup(imm);
}
- in6_unlink_ifa(ia, ifp);
+ in6_unlink_ifa(ia6, ifp);
}
void
-in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp)
+in6_unlink_ifa(struct in6_ifaddr *ia6, struct ifnet *ifp)
{
int s = splnet();
- ifa_del(ifp, &ia->ia_ifa);
+ ifa_del(ifp, &ia6->ia_ifa);
- TAILQ_REMOVE(&in6_ifaddr, ia, ia_list);
+ TAILQ_REMOVE(&in6_ifaddr, ia6, ia_list);
/* Release the reference to the base prefix. */
- if (ia->ia6_ndpr == NULL) {
+ if (ia6->ia6_ndpr == NULL) {
char addr[INET6_ADDRSTRLEN];
- if (!IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia)) &&
- !IN6_IS_ADDR_LOOPBACK(IA6_IN6(ia)) &&
- !IN6_ARE_ADDR_EQUAL(IA6_MASKIN6(ia), &in6mask128))
+ if (!IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia6)) &&
+ !IN6_IS_ADDR_LOOPBACK(IA6_IN6(ia6)) &&
+ !IN6_ARE_ADDR_EQUAL(IA6_MASKIN6(ia6), &in6mask128))
log(LOG_NOTICE, "in6_unlink_ifa: interface address "
"%s has no prefix\n",
- inet_ntop(AF_INET6, IA6_IN6(ia), addr,
+ inet_ntop(AF_INET6, IA6_IN6(ia6), addr,
sizeof(addr)));
} else {
- ia->ia6_flags &= ~IN6_IFF_AUTOCONF;
- if (--ia->ia6_ndpr->ndpr_refcnt == 0)
- prelist_remove(ia->ia6_ndpr);
- ia->ia6_ndpr = NULL;
+ ia6->ia6_flags &= ~IN6_IFF_AUTOCONF;
+ if (--ia6->ia6_ndpr->ndpr_refcnt == 0)
+ prelist_remove(ia6->ia6_ndpr);
+ ia6->ia6_ndpr = NULL;
}
/*
* release another refcnt for the link from in6_ifaddr.
* Note that we should decrement the refcnt at least once for all *BSD.
*/
- ifafree(&ia->ia_ifa);
+ ifafree(&ia6->ia_ifa);
splx(s);
}
case SIOCGLIFADDR:
case SIOCDLIFADDR:
{
- struct in6_ifaddr *ia;
+ struct in6_ifaddr *ia6;
struct in6_addr mask, candidate, match;
struct sockaddr_in6 *sin6;
int cmp;
}
if (!ifa)
return EADDRNOTAVAIL;
- ia = ifatoia6(ifa);
+ ia6 = ifatoia6(ifa);
if (cmd == SIOCGLIFADDR) {
/* fill in the if_laddrreq structure */
- bcopy(&ia->ia_addr, &iflr->addr, ia->ia_addr.sin6_len);
+ bcopy(&ia6->ia_addr, &iflr->addr, ia6->ia_addr.sin6_len);
if ((ifp->if_flags & IFF_POINTOPOINT) != 0) {
- bcopy(&ia->ia_dstaddr, &iflr->dstaddr,
- ia->ia_dstaddr.sin6_len);
+ bcopy(&ia6->ia_dstaddr, &iflr->dstaddr,
+ ia6->ia_dstaddr.sin6_len);
} else
bzero(&iflr->dstaddr, sizeof(iflr->dstaddr));
iflr->prefixlen =
- in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL);
+ in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL);
- iflr->flags = ia->ia6_flags; /*XXX*/
+ iflr->flags = ia6->ia6_flags; /*XXX*/
return 0;
} else {
bcopy(iflr->iflr_name, ifra.ifra_name,
sizeof(ifra.ifra_name));
- bcopy(&ia->ia_addr, &ifra.ifra_addr,
- ia->ia_addr.sin6_len);
+ bcopy(&ia6->ia_addr, &ifra.ifra_addr,
+ ia6->ia_addr.sin6_len);
if ((ifp->if_flags & IFF_POINTOPOINT) != 0) {
- bcopy(&ia->ia_dstaddr, &ifra.ifra_dstaddr,
- ia->ia_dstaddr.sin6_len);
+ bcopy(&ia6->ia_dstaddr, &ifra.ifra_dstaddr,
+ ia6->ia_dstaddr.sin6_len);
} else {
bzero(&ifra.ifra_dstaddr,
sizeof(ifra.ifra_dstaddr));
}
- bcopy(&ia->ia_prefixmask, &ifra.ifra_dstaddr,
- ia->ia_prefixmask.sin6_len);
+ bcopy(&ia6->ia_prefixmask, &ifra.ifra_dstaddr,
+ ia6->ia_prefixmask.sin6_len);
- ifra.ifra_flags = ia->ia6_flags;
+ ifra.ifra_flags = ia6->ia6_flags;
return in6_control(so, SIOCDIFADDR_IN6, (caddr_t)&ifra,
ifp);
}
* and routing table entry.
*/
int
-in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia, int newhost)
+in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia6, int newhost)
{
int error = 0, plen, ifacount = 0;
int s = splnet();
}
if ((ifacount <= 1 || ifp->if_type == IFT_CARP) && ifp->if_ioctl &&
- (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia))) {
+ (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia6))) {
splx(s);
return (error);
}
splx(s);
- ia->ia_ifa.ifa_metric = ifp->if_metric;
+ ia6->ia_ifa.ifa_metric = ifp->if_metric;
/* we could do in(6)_socktrim here, but just omit it at this moment. */
* interface, install a route to the destination as an interface
* direct route.
*/
- plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL); /* XXX */
- if (plen == 128 && ia->ia_dstaddr.sin6_family == AF_INET6) {
- if ((error = rtinit(&(ia->ia_ifa), (int)RTM_ADD,
+ plen = in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL); /* XXX */
+ if (plen == 128 && ia6->ia_dstaddr.sin6_family == AF_INET6) {
+ if ((error = rtinit(&(ia6->ia_ifa), (int)RTM_ADD,
RTF_UP | RTF_HOST)) != 0)
return (error);
- ia->ia_flags |= IFA_ROUTE;
+ ia6->ia_flags |= IFA_ROUTE;
}
/* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */
if (newhost) {
/* set the rtrequest function to create llinfo */
- ia->ia_ifa.ifa_rtrequest = nd6_rtrequest;
- in6_ifaddloop(&(ia->ia_ifa));
+ ia6->ia_ifa.ifa_rtrequest = nd6_rtrequest;
+ in6_ifaddloop(&(ia6->ia_ifa));
}
return (error);
int blen = -1;
struct ifaddr *ifa;
struct ifnet *ifp;
- struct in6_ifaddr *ifa_best = NULL;
+ struct in6_ifaddr *ia6_best = NULL;
#if NCARP > 0
struct sockaddr_dl *proxydl = NULL;
#endif
"newaddr=%s, scope=%x, dcmp=%d, bcmp=%d, "
"matchlen=%d, flgs=%x\n",
inet_ntop(AF_INET6, dst, adst, sizeof(adst)),
- (ifa_best == NULL) ? "none" :
- inet_ntop(AF_INET6, &ifa_best->ia_addr.sin6_addr,
+ (ia6_best == NULL) ? "none" :
+ inet_ntop(AF_INET6, &ia6_best->ia_addr.sin6_addr,
bestaddr, sizeof(bestaddr)),
inet_ntop(AF_INET6, IFA_IN6(ifa),
asrc, sizeof(asrc)),
src_scope, dscopecmp,
- ifa_best ? IN6_ARE_SCOPE_CMP(src_scope, best_scope) : -1,
+ ia6_best ? IN6_ARE_SCOPE_CMP(src_scope, best_scope) : -1,
in6_matchlen(IFA_IN6(ifa), dst),
ifatoia6(ifa)->ia6_flags);
}
* If this is the first address we find,
* keep it anyway.
*/
- if (ifa_best == NULL)
+ if (ia6_best == NULL)
goto replace;
/*
- * ifa_best is never NULL beyond this line except
+ * ia6_best is never NULL beyond this line except
* within the block labeled "replace".
*/
/*
- * If ifa_best has a smaller scope than dst and
+ * If ia6_best has a smaller scope than dst and
* the current address has a larger one than
- * (or equal to) dst, always replace ifa_best.
+ * (or equal to) dst, always replace ia6_best.
* Also, if the current address has a smaller scope
- * than dst, ignore it unless ifa_best also has a
+ * than dst, ignore it unless ia6_best also has a
* smaller scope.
*/
if (IN6_ARE_SCOPE_CMP(best_scope, dst_scope) < 0 &&
* If we have already found a non-deprecated
* candidate, just ignore deprecated addresses.
*/
- if ((ifa_best->ia6_flags & IN6_IFF_DEPRECATED)
+ if ((ia6_best->ia6_flags & IN6_IFF_DEPRECATED)
== 0)
continue;
}
* to a deprecated one regardless of scopes and
* address matching.
*/
- if ((ifa_best->ia6_flags & IN6_IFF_DEPRECATED) &&
+ if ((ia6_best->ia6_flags & IN6_IFF_DEPRECATED) &&
(ifatoia6(ifa)->ia6_flags &
IN6_IFF_DEPRECATED) == 0)
goto replace;
/*
* At this point, we have two cases:
* 1. we are looking at a non-deprecated address,
- * and ifa_best is also non-deprecated.
+ * and ia6_best is also non-deprecated.
* 2. we are looking at a deprecated address,
- * and ifa_best is also deprecated.
+ * and ia6_best is also deprecated.
* Also, we do not have to consider a case where
* the scope of if_best is larger(smaller) than dst and
* the scope of the current address is smaller(larger)
* - the scope comparison between the address and
* dst (dscopecmp)
* - the scope comparison between the address and
- * ifa_best (bscopecmp)
- * - if the address match dst longer than ifa_best
+ * ia6_best (bscopecmp)
+ * - if the address match dst longer than ia6_best
* (matchcmp)
* - if the address is on the outgoing I/F (outI/F)
*
if (oifp == ifp) {
/* Do not replace temporary autoconf addresses
* with non-temporary addresses. */
- if ((ifa_best->ia6_flags & IN6_IFF_PRIVACY) &&
+ if ((ia6_best->ia6_flags & IN6_IFF_PRIVACY) &&
!(ifatoia6(ifa)->ia6_flags &
IN6_IFF_PRIVACY))
continue;
/* Replace non-temporary autoconf addresses
* with temporary addresses. */
- if (!(ifa_best->ia6_flags & IN6_IFF_PRIVACY) &&
+ if (!(ia6_best->ia6_flags & IN6_IFF_PRIVACY) &&
(ifatoia6(ifa)->ia6_flags &
IN6_IFF_PRIVACY))
goto replace;
continue; /* (b) */
replace:
- ifa_best = ifatoia6(ifa);
+ ia6_best = ifatoia6(ifa);
blen = tlen >= 0 ? tlen :
in6_matchlen(IFA_IN6(ifa), dst);
- best_scope = in6_addrscope(&ifa_best->ia_addr.sin6_addr);
+ best_scope = in6_addrscope(&ia6_best->ia_addr.sin6_addr);
}
}
/* count statistics for future improvements */
- if (ifa_best == NULL)
+ if (ia6_best == NULL)
ip6stat.ip6s_sources_none++;
else {
- if (oifp == ifa_best->ia_ifp)
+ if (oifp == ia6_best->ia_ifp)
ip6stat.ip6s_sources_sameif[best_scope]++;
else
ip6stat.ip6s_sources_otherif[best_scope]++;
else
ip6stat.ip6s_sources_otherscope[best_scope]++;
- if ((ifa_best->ia6_flags & IN6_IFF_DEPRECATED) != 0)
+ if ((ia6_best->ia6_flags & IN6_IFF_DEPRECATED) != 0)
ip6stat.ip6s_sources_deprecated[best_scope]++;
}
- return (ifa_best);
+ return (ia6_best);
}
/*
in6_if_up(struct ifnet *ifp)
{
struct ifaddr *ifa;
- struct in6_ifaddr *ia;
+ struct in6_ifaddr *ia6;
int dad_delay; /* delay ticks before DAD output */
/*
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
- ia = ifatoia6(ifa);
- if (ia->ia6_flags & IN6_IFF_TENTATIVE)
+ ia6 = ifatoia6(ifa);
+ if (ia6->ia6_flags & IN6_IFF_TENTATIVE)
nd6_dad_start(ifa, &dad_delay);
}
}
-/* $OpenBSD: nd6_nbr.c,v 1.73 2014/01/07 17:07:46 mikeb Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.74 2014/01/13 23:03:52 bluhm Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
void
nd6_dad_start(struct ifaddr *ifa, int *tick)
{
- struct in6_ifaddr *ia = ifatoia6(ifa);
+ struct in6_ifaddr *ia6 = ifatoia6(ifa);
struct dadq *dp;
char addr[INET6_ADDRSTRLEN];
* - DAD is disabled (ip6_dad_count == 0)
* - the interface address is anycast
*/
- if (!(ia->ia6_flags & IN6_IFF_TENTATIVE)) {
+ if (!(ia6->ia6_flags & IN6_IFF_TENTATIVE)) {
log(LOG_DEBUG,
"nd6_dad_start: called with non-tentative address "
"%s(%s)\n",
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
return;
}
- if (ia->ia6_flags & IN6_IFF_ANYCAST) {
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ if (ia6->ia6_flags & IN6_IFF_ANYCAST) {
+ ia6->ia6_flags &= ~IN6_IFF_TENTATIVE;
return;
}
if (!ip6_dad_count) {
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ ia6->ia6_flags &= ~IN6_IFF_TENTATIVE;
return;
}
if (!ifa->ifa_ifp)
if (dp == NULL) {
log(LOG_ERR, "nd6_dad_start: memory allocation failed for "
"%s(%s)\n",
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
return;
ip6_dad_pending++;
nd6log((LOG_DEBUG, "%s: starting DAD for %s\n", ifa->ifa_ifp->if_xname,
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr, addr, sizeof(addr))));
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr, addr, sizeof(addr))));
/*
* Send NS packet for DAD, ip6_dad_count times.
nd6_dad_timer(struct ifaddr *ifa)
{
int s;
- struct in6_ifaddr *ia = ifatoia6(ifa);
+ struct in6_ifaddr *ia6 = ifatoia6(ifa);
struct dadq *dp;
char addr[INET6_ADDRSTRLEN];
s = splsoftnet(); /* XXX */
/* Sanity check */
- if (ia == NULL) {
+ if (ia6 == NULL) {
log(LOG_ERR, "nd6_dad_timer: called with null parameter\n");
goto done;
}
log(LOG_ERR, "nd6_dad_timer: DAD structure not found\n");
goto done;
}
- if (ia->ia6_flags & IN6_IFF_DUPLICATED) {
+ if (ia6->ia6_flags & IN6_IFF_DUPLICATED) {
log(LOG_ERR, "nd6_dad_timer: called with duplicated address "
"%s(%s)\n",
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
goto done;
}
- if ((ia->ia6_flags & IN6_IFF_TENTATIVE) == 0) {
+ if ((ia6->ia6_flags & IN6_IFF_TENTATIVE) == 0) {
log(LOG_ERR, "nd6_dad_timer: called with non-tentative address "
"%s(%s)\n",
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
goto done;
* We are done with DAD. No NA came, no NS came.
* duplicated address found.
*/
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ ia6->ia6_flags &= ~IN6_IFF_TENTATIVE;
nd6log((LOG_DEBUG,
"%s: DAD complete for %s - no duplicates found\n",
ifa->ifa_ifp->if_xname,
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr))));
TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list);
void
nd6_dad_duplicated(struct ifaddr *ifa)
{
- struct in6_ifaddr *ia = ifatoia6(ifa);
+ struct in6_ifaddr *ia6 = ifatoia6(ifa);
struct dadq *dp;
char addr[INET6_ADDRSTRLEN];
log(LOG_ERR, "%s: DAD detected duplicate IPv6 address %s: "
"NS in/out=%d/%d, NA in=%d\n",
ifa->ifa_ifp->if_xname,
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr, addr, sizeof(addr)),
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr, addr, sizeof(addr)),
dp->dad_ns_icount, dp->dad_ns_ocount, dp->dad_na_icount);
- ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
- ia->ia6_flags |= IN6_IFF_DUPLICATED;
+ ia6->ia6_flags &= ~IN6_IFF_TENTATIVE;
+ ia6->ia6_flags |= IN6_IFF_DUPLICATED;
/* We are done with DAD, with duplicated address found. (failure) */
nd6_dad_stoptimer(dp);
log(LOG_ERR, "%s: DAD complete for %s - duplicate found\n",
ifa->ifa_ifp->if_xname,
- inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr, addr, sizeof(addr)));
+ inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr, addr, sizeof(addr)));
log(LOG_ERR, "%s: manual intervention required\n",
ifa->ifa_ifp->if_xname);
void
nd6_dad_ns_output(struct dadq *dp, struct ifaddr *ifa)
{
- struct in6_ifaddr *ia = ifatoia6(ifa);
+ struct in6_ifaddr *ia6 = ifatoia6(ifa);
struct ifnet *ifp = ifa->ifa_ifp;
dp->dad_ns_tcount++;
}
dp->dad_ns_ocount++;
- nd6_ns_output(ifp, NULL, &ia->ia_addr.sin6_addr, NULL, 1);
+ nd6_ns_output(ifp, NULL, &ia6->ia_addr.sin6_addr, NULL, 1);
}
void
nd6_dad_ns_input(struct ifaddr *ifa)
{
- struct in6_ifaddr *ia;
+ struct in6_ifaddr *ia6;
struct in6_addr *taddr6;
struct dadq *dp;
int duplicate;
if (!ifa)
panic("ifa == NULL in nd6_dad_ns_input");
- ia = ifatoia6(ifa);
- taddr6 = &ia->ia_addr.sin6_addr;
+ ia6 = ifatoia6(ifa);
+ taddr6 = &ia6->ia_addr.sin6_addr;
duplicate = 0;
dp = nd6_dad_find(ifa);
-/* $OpenBSD: nd6_rtr.c,v 1.76 2014/01/10 14:29:08 tedu Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.77 2014/01/13 23:03:52 bluhm Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
purge_detached(struct ifnet *ifp)
{
struct nd_prefix *pr, *pr_next;
- struct in6_ifaddr *ia;
+ struct in6_ifaddr *ia6;
struct ifaddr *ifa, *ifa_next;
LIST_FOREACH_SAFE(pr, &nd_prefix, ndpr_entry, pr_next) {
TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrlist, ifa_list, ifa_next) {
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
- ia = ifatoia6(ifa);
- if ((ia->ia6_flags & IN6_IFF_AUTOCONF) ==
- IN6_IFF_AUTOCONF && ia->ia6_ndpr == pr) {
+ ia6 = ifatoia6(ifa);
+ if ((ia6->ia6_flags & IN6_IFF_AUTOCONF) ==
+ IN6_IFF_AUTOCONF && ia6->ia6_ndpr == pr) {
in6_purgeaddr(ifa);
}
}
* should reject autoconfiguration of a new address.
*/
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
- struct in6_ifaddr *ifa6;
+ struct in6_ifaddr *ia6;
int ifa_plen;
u_int32_t storedlifetime;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
- ifa6 = ifatoia6(ifa);
+ ia6 = ifatoia6(ifa);
/*
* Spec is not clear here, but I believe we should concentrate
* on unicast (i.e. not anycast) addresses.
* XXX: other ia6_flags? detached or duplicated?
*/
- if ((ifa6->ia6_flags & IN6_IFF_ANYCAST) != 0)
+ if ((ia6->ia6_flags & IN6_IFF_ANYCAST) != 0)
continue;
- ifa_plen = in6_mask2len(&ifa6->ia_prefixmask.sin6_addr, NULL);
+ ifa_plen = in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL);
if (ifa_plen != new->ndpr_plen ||
- !in6_are_prefix_equal(&ifa6->ia_addr.sin6_addr,
+ !in6_are_prefix_equal(&ia6->ia_addr.sin6_addr,
&new->ndpr_prefix.sin6_addr, ifa_plen))
continue;
if (ia6_match == NULL) /* remember the first one */
- ia6_match = ifa6;
+ ia6_match = ia6;
- if ((ifa6->ia6_flags & IN6_IFF_AUTOCONF) == 0) {
+ if ((ia6->ia6_flags & IN6_IFF_AUTOCONF) == 0) {
statique = 1;
continue;
}
* See the discussion in the IETF ipngwg ML in August 2001,
* with the Subject "StoredLifetime in RFC 2462".
*/
- lt6_tmp = ifa6->ia6_lifetime;
+ lt6_tmp = ia6->ia6_lifetime;
/* RFC 4941 temporary addresses (privacy extension). */
- if (ifa6->ia6_flags & IN6_IFF_PRIVACY) {
+ if (ia6->ia6_flags & IN6_IFF_PRIVACY) {
/* Do we still have a non-deprecated address? */
- if ((ifa6->ia6_flags & IN6_IFF_DEPRECATED) == 0)
+ if ((ia6->ia6_flags & IN6_IFF_DEPRECATED) == 0)
tempaddr_preferred = 1;
/* Don't extend lifetime for temporary addresses. */
if (new->ndpr_vltime >= lt6_tmp.ia6t_vltime)
continue;
if (new->ndpr_pltime >= lt6_tmp.ia6t_pltime)
continue;
- } else if ((ifa6->ia6_flags & IN6_IFF_DEPRECATED) == 0)
+ } else if ((ia6->ia6_flags & IN6_IFF_DEPRECATED) == 0)
/* We have a regular SLAAC address. */
autoconf = 1;
if (lt6_tmp.ia6t_vltime == ND6_INFINITE_LIFETIME)
storedlifetime = ND6_INFINITE_LIFETIME;
- else if (time_second - ifa6->ia6_updatetime >
+ else if (time_second - ia6->ia6_updatetime >
lt6_tmp.ia6t_vltime) {
/*
* The case of "invalid" address. We should usually
storedlifetime = 0;
} else
storedlifetime = lt6_tmp.ia6t_vltime -
- (time_second - ifa6->ia6_updatetime);
+ (time_second - ia6->ia6_updatetime);
if (TWOHOUR < new->ndpr_vltime ||
storedlifetime < new->ndpr_vltime) {
lt6_tmp.ia6t_vltime = new->ndpr_vltime;
in6_init_address_ltimes(pr, <6_tmp);
- ifa6->ia6_lifetime = lt6_tmp;
- ifa6->ia6_updatetime = time_second;
+ ia6->ia6_lifetime = lt6_tmp;
+ ia6->ia6_updatetime = time_second;
}
if ((!autoconf || ((ifp->if_xflags & IFXF_INET6_NOPRIVACY) == 0 &&
pfxlist_onlink_check(void)
{
struct nd_prefix *pr;
- struct in6_ifaddr *ifa;
+ struct in6_ifaddr *ia6;
char addr[INET6_ADDRSTRLEN];
/*
* always be attached.
* The precise detection logic is same as the one for prefixes.
*/
- TAILQ_FOREACH(ifa, &in6_ifaddr, ia_list) {
- if (!(ifa->ia6_flags & IN6_IFF_AUTOCONF))
+ TAILQ_FOREACH(ia6, &in6_ifaddr, ia_list) {
+ if (!(ia6->ia6_flags & IN6_IFF_AUTOCONF))
continue;
- if (ifa->ia6_ndpr == NULL) {
+ if (ia6->ia6_ndpr == NULL) {
/*
* This can happen when we first configure the address
* (i.e. the address exists, but the prefix does not).
continue;
}
- if (find_pfxlist_reachable_router(ifa->ia6_ndpr))
+ if (find_pfxlist_reachable_router(ia6->ia6_ndpr))
break;
}
- if (ifa) {
- TAILQ_FOREACH(ifa, &in6_ifaddr, ia_list) {
- if ((ifa->ia6_flags & IN6_IFF_AUTOCONF) == 0)
+ if (ia6) {
+ TAILQ_FOREACH(ia6, &in6_ifaddr, ia_list) {
+ if ((ia6->ia6_flags & IN6_IFF_AUTOCONF) == 0)
continue;
- if (ifa->ia6_ndpr == NULL) /* XXX: see above. */
+ if (ia6->ia6_ndpr == NULL) /* XXX: see above. */
continue;
- if (find_pfxlist_reachable_router(ifa->ia6_ndpr))
- ifa->ia6_flags &= ~IN6_IFF_DETACHED;
+ if (find_pfxlist_reachable_router(ia6->ia6_ndpr))
+ ia6->ia6_flags &= ~IN6_IFF_DETACHED;
else
- ifa->ia6_flags |= IN6_IFF_DETACHED;
+ ia6->ia6_flags |= IN6_IFF_DETACHED;
}
}
else {
- TAILQ_FOREACH(ifa, &in6_ifaddr, ia_list) {
- if ((ifa->ia6_flags & IN6_IFF_AUTOCONF) == 0)
+ TAILQ_FOREACH(ia6, &in6_ifaddr, ia_list) {
+ if ((ia6->ia6_flags & IN6_IFF_AUTOCONF) == 0)
continue;
- ifa->ia6_flags &= ~IN6_IFF_DETACHED;
+ ia6->ia6_flags &= ~IN6_IFF_DETACHED;
}
}
}
struct ifnet *ifp = pr->ndpr_ifp;
struct ifaddr *ifa;
struct in6_aliasreq ifra;
- struct in6_ifaddr *ia, *ib;
+ struct in6_ifaddr *ia6;
int error, s, plen0;
struct in6_addr mask, rand_ifid;
int prefixlen = pr->ndpr_plen;
*/
ifa = &in6ifa_ifpforlinklocal(ifp, 0)->ia_ifa; /* 0 is OK? */
if (ifa)
- ib = ifatoia6(ifa);
+ ia6 = ifatoia6(ifa);
else
return NULL;
#endif
/* prefixlen + ifidlen must be equal to 128 */
- plen0 = in6_mask2len(&ib->ia_prefixmask.sin6_addr, NULL);
+ plen0 = in6_mask2len(&ia6->ia_prefixmask.sin6_addr, NULL);
if (prefixlen != plen0) {
nd6log((LOG_INFO, "in6_ifadd: wrong prefixlen for %s "
"(prefix=%d ifid=%d)\n",
(rand_ifid.s6_addr32[3] & ~mask.s6_addr32[3]);
} else {
ifra.ifra_addr.sin6_addr.s6_addr32[0] |=
- (ib->ia_addr.sin6_addr.s6_addr32[0] & ~mask.s6_addr32[0]);
+ (ia6->ia_addr.sin6_addr.s6_addr32[0] & ~mask.s6_addr32[0]);
ifra.ifra_addr.sin6_addr.s6_addr32[1] |=
- (ib->ia_addr.sin6_addr.s6_addr32[1] & ~mask.s6_addr32[1]);
+ (ia6->ia_addr.sin6_addr.s6_addr32[1] & ~mask.s6_addr32[1]);
ifra.ifra_addr.sin6_addr.s6_addr32[2] |=
- (ib->ia_addr.sin6_addr.s6_addr32[2] & ~mask.s6_addr32[2]);
+ (ia6->ia_addr.sin6_addr.s6_addr32[2] & ~mask.s6_addr32[2]);
ifra.ifra_addr.sin6_addr.s6_addr32[3] |=
- (ib->ia_addr.sin6_addr.s6_addr32[3] & ~mask.s6_addr32[3]);
+ (ia6->ia_addr.sin6_addr.s6_addr32[3] & ~mask.s6_addr32[3]);
}
/* new prefix mask. */
return (NULL); /* ifaddr must not have been allocated. */
}
- ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr);
-
- return (ia); /* this is always non-NULL */
+ /* this is always non-NULL */
+ return (in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr));
}
int