Acquire address list lock before walking an interface's address list to

identify possible jail addresses on it for IPv4 and IPv6.

MFC after:	2 weeks
This commit is contained in:
Robert Watson 2009-04-20 23:23:31 +00:00
parent 93c83dd8bf
commit 77ee4c0e00

View File

@ -356,6 +356,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp,
* Try to find an address on the given outgoing interface
* that belongs to the jail.
*/
IF_ADDR_LOCK(ifp);
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
struct sockaddr *sa;
sa = ifa->ifa_addr;
@ -367,6 +368,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp,
break;
}
}
IF_ADDR_UNLOCK(ifp);
if (!found) {
/*
* As a last resort return the 'default' jail address.
@ -394,6 +396,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp,
* Try to find an address on the given outgoing interface
* that belongs to the jail.
*/
IF_ADDR_LOCK(ifp);
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
struct sockaddr *sa;
sa = ifa->ifa_addr;
@ -406,6 +409,7 @@ rtm_get_jailed(struct rt_addrinfo *info, struct ifnet *ifp,
break;
}
}
IF_ADDR_UNLOCK(ifp);
if (!found) {
/*
* As a last resort return the 'default' jail address.