svn commit: r191287 - head/sys/netinet
Robert Watson
rwatson at FreeBSD.org
Sun Apr 19 22:29:17 UTC 2009
Author: rwatson
Date: Sun Apr 19 22:29:16 2009
New Revision: 191287
URL: http://svn.freebsd.org/changeset/base/191287
Log:
In divert_packet(), lock the interface address list before iterating over
it in search of an address.
MFC after: 2 weeks
Modified:
head/sys/netinet/ip_divert.c
Modified: head/sys/netinet/ip_divert.c
==============================================================================
--- head/sys/netinet/ip_divert.c Sun Apr 19 22:25:09 2009 (r191286)
+++ head/sys/netinet/ip_divert.c Sun Apr 19 22:29:16 2009 (r191287)
@@ -244,18 +244,22 @@ divert_packet(struct mbuf *m, int incomi
divsrc.sin_port = divert_cookie(mtag); /* record matching rule */
if (incoming) {
struct ifaddr *ifa;
+ struct ifnet *ifp;
/* Sanity check */
M_ASSERTPKTHDR(m);
/* Find IP address for receive interface */
- TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrhead, ifa_link) {
+ ifp = m->m_pkthdr.rcvif;
+ IF_ADDR_LOCK(ifp);
+ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
divsrc.sin_addr =
((struct sockaddr_in *) ifa->ifa_addr)->sin_addr;
break;
}
+ IF_ADDR_UNLOCK(ifp);
}
/*
* Record the incoming interface name whenever we have one.
More information about the svn-src-all
mailing list