diff options
author | hsu <hsu@FreeBSD.org> | 2002-12-22 05:35:03 +0000 |
---|---|---|
committer | hsu <hsu@FreeBSD.org> | 2002-12-22 05:35:03 +0000 |
commit | 82e1e3bab0d3abe1018a0b56559c154485f2f676 (patch) | |
tree | d0f9ee7e6f9d8014e6f8f94ab6965e85c268792e /sys/netinet6 | |
parent | 2afef11c570b7b725c3145fc710f8dcd8d7ed4e0 (diff) | |
download | FreeBSD-src-82e1e3bab0d3abe1018a0b56559c154485f2f676.zip FreeBSD-src-82e1e3bab0d3abe1018a0b56559c154485f2f676.tar.gz |
SMP locking for ifnet list.
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/icmp6.c | 10 | ||||
-rw-r--r-- | sys/netinet6/in6.c | 4 | ||||
-rw-r--r-- | sys/netinet6/in6_ifattach.c | 7 |
3 files changed, 19 insertions, 2 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index edb41f7..9e3015d 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1672,6 +1672,7 @@ ni6_addrs(ni6, m, ifpp, subj) } } + IFNET_RLOCK(); for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { addrsofif = 0; @@ -1729,11 +1730,13 @@ ni6_addrs(ni6, m, ifpp, subj) } if (iffound) { *ifpp = ifp; + IFNET_RUNLOCK(); return(addrsofif); } addrs += addrsofif; } + IFNET_RUNLOCK(); return(addrs); } @@ -1755,9 +1758,9 @@ ni6_store_addrs(ni6, nni6, ifp0, resid) if (ifp0 == NULL && !(niflags & NI_NODEADDR_FLAG_ALL)) return(0); /* needless to copy */ - + + IFNET_RLOCK(); again: - for (; ifp; ifp = TAILQ_NEXT(ifp, if_list)) { for (ifa = ifp->if_addrlist.tqh_first; ifa; @@ -1823,6 +1826,7 @@ ni6_store_addrs(ni6, nni6, ifp0, resid) */ nni6->ni_flags |= NI_NODEADDR_FLAG_TRUNCATE; + IFNET_RUNLOCK(); return(copied); } @@ -1877,6 +1881,8 @@ ni6_store_addrs(ni6, nni6, ifp0, resid) goto again; } + IFNET_RUNLOCK(); + return(copied); } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index bb38bde..c450dea 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1973,6 +1973,7 @@ in6_ifawithscope(oifp, dst) * Comparing an interface with the outgoing interface will be done * only at the final stage of tiebreaking. */ + IFNET_RLOCK(); for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { /* @@ -2204,6 +2205,7 @@ in6_ifawithscope(oifp, dst) best_scope = in6_addrscope(&ifa_best->ia_addr.sin6_addr); } } + IFNET_RUNLOCK(); /* count statistics for future improvements */ if (ifa_best == NULL) @@ -2385,12 +2387,14 @@ in6_setmaxmtu() unsigned long maxmtu = 0; struct ifnet *ifp; + IFNET_RLOCK(); for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { if ((ifp->if_flags & IFF_LOOPBACK) == 0 && nd_ifinfo[ifp->if_index].linkmtu > maxmtu) maxmtu = nd_ifinfo[ifp->if_index].linkmtu; } + IFNET_RUNLOCK(); if (maxmtu) /* update only when maxmtu is positive */ in6_maxmtu = maxmtu; } diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 9150a36..5abcca1 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -381,6 +381,7 @@ get_ifid(ifp0, altifp, in6) } /* next, try to get it from some other hardware interface */ + IFNET_RLOCK(); for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) { if (ifp == ifp0) @@ -396,9 +397,11 @@ get_ifid(ifp0, altifp, in6) nd6log((LOG_DEBUG, "%s: borrow interface identifier from %s\n", if_name(ifp0), if_name(ifp))); + IFNET_RUNLOCK(); goto success; } } + IFNET_RUNLOCK(); /* last resort: get from random number source */ if (get_rand_ifid(ifp, in6) == 0) { @@ -688,6 +691,7 @@ in6_nigroup_attach(name, namelen) if (in6_nigroup(NULL, name, namelen, &mltaddr.sin6_addr) != 0) return; + IFNET_RLOCK(); for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) { mltaddr.sin6_addr.s6_addr16[1] = htons(ifp->if_index); @@ -701,6 +705,7 @@ in6_nigroup_attach(name, namelen) } } } + IFNET_RUNLOCK(); } void @@ -718,6 +723,7 @@ in6_nigroup_detach(name, namelen) if (in6_nigroup(NULL, name, namelen, &mltaddr.sin6_addr) != 0) return; + IFNET_RLOCK(); for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) { mltaddr.sin6_addr.s6_addr16[1] = htons(ifp->if_index); @@ -725,6 +731,7 @@ in6_nigroup_detach(name, namelen) if (in6m) in6_delmulti(in6m); } + IFNET_RUNLOCK(); } /* |