diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-06-25 16:35:28 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-06-25 16:35:28 +0000 |
commit | bd6eb7be79d81290efa6dcaa9f492a05b1966344 (patch) | |
tree | ff4ff11920651e5f6aaeaa54e259e4f335eec1af /sys/netinet6/in6_src.c | |
parent | 07492aedb8a9805aa9b5287012a05ac498d59d7b (diff) | |
download | FreeBSD-src-bd6eb7be79d81290efa6dcaa9f492a05b1966344.zip FreeBSD-src-bd6eb7be79d81290efa6dcaa9f492a05b1966344.tar.gz |
Add address list locking for in6_ifaddrhead/ia_link: as with locking
for in_ifaddrhead, we stick with an rwlock for the time being, which
we will revisit in the future with a possible move to rmlocks.
Some pieces of code require significant further reworking to be
safe from all classes of writer-writer races.
Reviewed by: bz
MFC after: 6 weeks
Diffstat (limited to 'sys/netinet6/in6_src.c')
-rw-r--r-- | sys/netinet6/in6_src.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index b38fbc7..f1ccca1 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -289,6 +289,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, if (error) return (error); + IN6_IFADDR_RLOCK(); TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { int new_scope = -1, new_matchlen = -1; struct in6_addrpolicy *new_policy = NULL; @@ -466,13 +467,16 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, break; } - if ((ia = ia_best) == NULL) + if ((ia = ia_best) == NULL) { + IN6_IFADDR_RUNLOCK(); return (EADDRNOTAVAIL); + } if (ifpp) *ifpp = ifp; bcopy(&ia->ia_addr.sin6_addr, srcp, sizeof(*srcp)); + IN6_IFADDR_RUNLOCK(); return (0); } |