Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in.c
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | |||||
in_localip_more(struct in_ifaddr *ia) | in_localip_more(struct in_ifaddr *ia) | ||||
{ | { | ||||
struct rm_priotracker in_ifa_tracker; | struct rm_priotracker in_ifa_tracker; | ||||
in_addr_t in = IA_SIN(ia)->sin_addr.s_addr; | in_addr_t in = IA_SIN(ia)->sin_addr.s_addr; | ||||
struct in_ifaddr *it; | struct in_ifaddr *it; | ||||
IN_IFADDR_RLOCK(&in_ifa_tracker); | IN_IFADDR_RLOCK(&in_ifa_tracker); | ||||
LIST_FOREACH(it, INADDR_HASH(in), ia_hash) { | LIST_FOREACH(it, INADDR_HASH(in), ia_hash) { | ||||
if (it != ia && IA_SIN(it)->sin_addr.s_addr == in) { | if (it != ia && IA_SIN(it)->sin_addr.s_addr == in && | ||||
ifa_ref(&it->ia_ifa); | ifa_ref(&it->ia_ifa) != 0) { | ||||
IN_IFADDR_RUNLOCK(&in_ifa_tracker); | IN_IFADDR_RUNLOCK(&in_ifa_tracker); | ||||
return (it); | return (it); | ||||
} | } | ||||
} | } | ||||
IN_IFADDR_RUNLOCK(&in_ifa_tracker); | IN_IFADDR_RUNLOCK(&in_ifa_tracker); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | if (error) | ||||
return (error); | return (error); | ||||
} | } | ||||
/* if_addrhead is already referenced by ifa_alloc() */ | /* if_addrhead is already referenced by ifa_alloc() */ | ||||
IF_ADDR_WLOCK(ifp); | IF_ADDR_WLOCK(ifp); | ||||
CK_STAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); | CK_STAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); | ||||
IF_ADDR_WUNLOCK(ifp); | IF_ADDR_WUNLOCK(ifp); | ||||
ifa_ref(ifa); /* in_ifaddrhead */ | if (ifa_ref(ifa) != 0) { | ||||
IN_IFADDR_WLOCK(); | IN_IFADDR_WLOCK(); | ||||
CK_STAILQ_INSERT_TAIL(&V_in_ifaddrhead, ia, ia_link); | CK_STAILQ_INSERT_TAIL(&V_in_ifaddrhead, ia, ia_link); | ||||
LIST_INSERT_HEAD(INADDR_HASH(ia->ia_addr.sin_addr.s_addr), ia, ia_hash); | LIST_INSERT_HEAD(INADDR_HASH(ia->ia_addr.sin_addr.s_addr), ia, ia_hash); | ||||
IN_IFADDR_WUNLOCK(); | IN_IFADDR_WUNLOCK(); | ||||
} | |||||
/* | /* | ||||
* Give the interface a chance to initialize | * Give the interface a chance to initialize | ||||
* if this is its first address, | * if this is its first address, | ||||
* and to validate the address if necessary. | * and to validate the address if necessary. | ||||
*/ | */ | ||||
if (ifp->if_ioctl != NULL) { | if (ifp->if_ioctl != NULL) { | ||||
error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia); | error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia); | ||||
▲ Show 20 Lines • Show All 386 Lines • ▼ Show 20 Lines | CK_STAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { | ||||
if ((ia->ia_ifp->if_flags & IFF_UP) == 0) | if ((ia->ia_ifp->if_flags & IFF_UP) == 0) | ||||
continue; | continue; | ||||
/* | /* | ||||
* If we got a matching prefix address, move IFA_ROUTE and | * If we got a matching prefix address, move IFA_ROUTE and | ||||
* the route itself to it. Make sure that routing daemons | * the route itself to it. Make sure that routing daemons | ||||
* get a heads-up. | * get a heads-up. | ||||
*/ | */ | ||||
if ((ia->ia_flags & IFA_ROUTE) == 0) { | if ((ia->ia_flags & IFA_ROUTE) == 0 && | ||||
ifa_ref(&ia->ia_ifa); | ifa_ref(&ia->ia_ifa) != 0) { | ||||
IN_IFADDR_RUNLOCK(&in_ifa_tracker); | IN_IFADDR_RUNLOCK(&in_ifa_tracker); | ||||
error = rtinit(&(target->ia_ifa), (int)RTM_DELETE, | error = rtinit(&(target->ia_ifa), (int)RTM_DELETE, | ||||
rtinitflags(target)); | rtinitflags(target)); | ||||
if (error == 0) | if (error == 0) | ||||
target->ia_flags &= ~IFA_ROUTE; | target->ia_flags &= ~IFA_ROUTE; | ||||
else | else | ||||
log(LOG_INFO, "in_scrubprefix: err=%d, old prefix delete failed\n", | log(LOG_INFO, "in_scrubprefix: err=%d, old prefix delete failed\n", | ||||
error); | error); | ||||
▲ Show 20 Lines • Show All 632 Lines • Show Last 20 Lines |