diff options
| author | Robert Watson <rwatson@FreeBSD.org> | 2009-06-25 16:35:28 +0000 |
|---|---|---|
| committer | Robert Watson <rwatson@FreeBSD.org> | 2009-06-25 16:35:28 +0000 |
| commit | d1da0a0672600164899bfee5b854a738bca30086 (patch) | |
| tree | ff4ff11920651e5f6aaeaa54e259e4f335eec1af /sys/netinet6/in6_src.c | |
| parent | b372d0d8bc8ce9b1d82fd7878069de9431ba6de5 (diff) | |
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
Notes
svn path=/head/; revision=194971
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 b38fbc703a2a..f1ccca15ffec 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); } |
