Index: kern/kern_uuid.c =================================================================== --- kern/kern_uuid.c (revision 229479) +++ kern/kern_uuid.c (working copy) @@ -98,20 +98,20 @@ IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { /* Walk the address list */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { sdl = (struct sockaddr_dl*)ifa->ifa_addr; if (sdl != NULL && sdl->sdl_family == AF_LINK && sdl->sdl_type == IFT_ETHER) { /* Got a MAC address. */ bcopy(LLADDR(sdl), node, UUID_NODE_LEN); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); IFNET_RUNLOCK_NOSLEEP(); CURVNET_RESTORE(); return; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } IFNET_RUNLOCK_NOSLEEP(); Index: netatalk/at_control.c =================================================================== --- netatalk/at_control.c (revision 229479) +++ netatalk/at_control.c (working copy) @@ -254,9 +254,9 @@ */ aa->aa_ifp = ifp; ifa_ref(&aa->aa_ifa); /* if_addrhead */ - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); } else { /* * If we DID find one then we clobber any routes @@ -357,9 +357,9 @@ * remove the ifaddr from the interface */ ifa = (struct ifaddr *)aa; - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); ifa_free(ifa); /* if_addrhead */ /* Index: netatalk/aarp.c =================================================================== --- netatalk/aarp.c (revision 229479) +++ netatalk/aarp.c (working copy) @@ -406,7 +406,7 @@ * Since we don't know the net, we just look for the first * phase 1 address on the interface. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ifp->if_addrhead); aa; aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) { @@ -416,12 +416,12 @@ } } if (aa == NULL) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); m_freem(m); return; } ifa_ref(&aa->aa_ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); tpa.s_net = spa.s_net = AA_SAT(aa)->sat_addr.s_net; } Index: netinet/in.c =================================================================== --- netinet/in.c (revision 229479) +++ netinet/in.c (working copy) @@ -363,7 +363,7 @@ ifa_ref(&ia->ia_ifa); IN_IFADDR_RUNLOCK(); if (ia == NULL) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { iap = ifatoia(ifa); if (iap->ia_addr.sin_family == AF_INET) { @@ -377,7 +377,7 @@ } if (ia != NULL) ifa_ref(&ia->ia_ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } if (ia == NULL) iaIsFirst = 1; @@ -441,9 +441,9 @@ ia->ia_ifp = ifp; ifa_ref(ifa); /* if_addrhead */ - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); ifa_ref(ifa); /* in_ifaddrhead */ IN_IFADDR_WLOCK(); TAILQ_INSERT_TAIL(&V_in_ifaddrhead, ia, ia_link); @@ -622,7 +622,7 @@ if (ia->ia_ifa.ifa_carp) (*carp_detach_p)(&ia->ia_ifa); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); /* Re-check that ia is still part of the list. */ TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa == &ia->ia_ifa) @@ -634,12 +634,12 @@ * try it again for the next loop as there is no other exit * path between here and out. */ - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); error = EADDRNOTAVAIL; goto out; } TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); ifa_free(&ia->ia_ifa); /* if_addrhead */ IN_IFADDR_WLOCK(); @@ -784,7 +784,7 @@ } } - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET) continue; @@ -798,7 +798,7 @@ } if (ifa != NULL) ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (ifa == NULL) return (EADDRNOTAVAIL); ia = (struct in_ifaddr *)ifa; @@ -1302,7 +1302,7 @@ * We need to do this as IF_ADDR_LOCK() may be re-acquired * by code further down. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -1314,7 +1314,7 @@ inm = (struct in_multi *)ifma->ifma_protospec; LIST_INSERT_HEAD(&purgeinms, inm, inm_link); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); LIST_FOREACH_SAFE(inm, &purgeinms, inm_link, tinm) { LIST_REMOVE(inm, inm_link); Index: netinet/in_pcb.c =================================================================== --- netinet/in_pcb.c (revision 229479) +++ netinet/in_pcb.c (working copy) @@ -745,7 +745,7 @@ ifp = ia->ia_ifp; ifa_free(&ia->ia_ifa); ia = NULL; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { sa = ifa->ifa_addr; @@ -759,10 +759,10 @@ } if (ia != NULL) { laddr->s_addr = ia->ia_addr.sin_addr.s_addr; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* 3. As a last resort return the 'default' jail address. */ error = prison_get_ip4(cred, laddr); @@ -804,7 +804,7 @@ */ ia = NULL; ifp = sro.ro_rt->rt_ifp; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { sa = ifa->ifa_addr; if (sa->sa_family != AF_INET) @@ -817,10 +817,10 @@ } if (ia != NULL) { laddr->s_addr = ia->ia_addr.sin_addr.s_addr; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* 3. As a last resort return the 'default' jail address. */ error = prison_get_ip4(cred, laddr); @@ -868,7 +868,7 @@ ifp = ia->ia_ifp; ifa_free(&ia->ia_ifa); ia = NULL; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { sa = ifa->ifa_addr; @@ -883,10 +883,10 @@ } if (ia != NULL) { laddr->s_addr = ia->ia_addr.sin_addr.s_addr; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } /* 3. As a last resort return the 'default' jail address. */ Index: netinet/sctp_bsd_addr.c =================================================================== --- netinet/sctp_bsd_addr.c (revision 229479) +++ netinet/sctp_bsd_addr.c (working copy) @@ -216,7 +216,7 @@ IFNET_RLOCK(); TAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_list) { - IF_ADDR_LOCK(ifn); + IF_ADDR_RLOCK(ifn); TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) { continue; @@ -273,7 +273,7 @@ sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE; } } - IF_ADDR_UNLOCK(ifn); + IF_ADDR_RUNLOCK(ifn); } IFNET_RUNLOCK(); } Index: netinet/in_mcast.c =================================================================== --- netinet/in_mcast.c (revision 229479) +++ netinet/in_mcast.c (working copy) @@ -429,7 +429,7 @@ return (error); /* XXX ifma_protospec must be covered by IF_ADDR_LOCK */ - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); /* * If something other than netinet is occupying the link-layer @@ -453,11 +453,11 @@ #endif ++inm->inm_refcount; *pinm = inm; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); return (0); } - IF_ADDR_LOCK_ASSERT(ifp); + IF_ADDR_WLOCK_ASSERT(ifp); /* * A new in_multi record is needed; allocate and initialize it. @@ -469,7 +469,7 @@ inm = malloc(sizeof(*inm), M_IPMADDR, M_NOWAIT | M_ZERO); if (inm == NULL) { if_delmulti_ifma(ifma); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); return (ENOMEM); } inm->inm_addr = *group; @@ -492,7 +492,7 @@ *pinm = inm; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); return (0); } @@ -2832,7 +2832,7 @@ IN_MULTI_LOCK(); - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -2865,7 +2865,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); IN_MULTI_UNLOCK(); Index: netinet/ip_input.c =================================================================== --- netinet/ip_input.c (revision 229479) +++ netinet/ip_input.c (working copy) @@ -611,7 +611,7 @@ * into the stack for SIMPLEX interfaces handled by ether_output(). */ if (ifp != NULL && ifp->if_flags & IFF_BROADCAST) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET) continue; @@ -619,18 +619,18 @@ if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr == ip->ip_dst.s_addr) { ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto ours; } #ifdef BOOTP_COMPAT if (IA_SIN(ia)->sin_addr.s_addr == INADDR_ANY) { ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto ours; } #endif } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); ia = NULL; } /* RFC 3927 2.7: Do not forward datagrams for 169.254.0.0/16. */ Index: netinet/ip_icmp.c =================================================================== --- netinet/ip_icmp.c (revision 229479) +++ netinet/ip_icmp.c (working copy) @@ -703,7 +703,7 @@ */ ifp = m->m_pkthdr.rcvif; if (ifp != NULL && ifp->if_flags & IFF_BROADCAST) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET) continue; @@ -711,11 +711,11 @@ if (satosin(&ia->ia_broadaddr)->sin_addr.s_addr == t.s_addr) { t = IA_SIN(ia)->sin_addr; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto match; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } /* * If the packet was transiting through us, use the address of @@ -724,16 +724,16 @@ * criteria apply. */ if (V_icmp_rfi && ifp != NULL) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET) continue; ia = ifatoia(ifa); t = IA_SIN(ia)->sin_addr; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto match; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } /* * If the incoming packet was not addressed directly to us, use @@ -742,16 +742,16 @@ * with normal source selection. */ if (V_reply_src[0] != '\0' && (ifp = ifunit(V_reply_src))) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET) continue; ia = ifatoia(ifa); t = IA_SIN(ia)->sin_addr; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto match; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } /* * If the packet was transiting through us, use the address of Index: netinet/in_var.h =================================================================== --- netinet/in_var.h (revision 229479) +++ netinet/in_var.h (working copy) @@ -394,9 +394,9 @@ struct in_multi *inm; IN_MULTI_LOCK_ASSERT(); - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); inm = inm_lookup_locked(ifp, ina); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (inm); } Index: netinet/if_ether.c =================================================================== --- netinet/if_ether.c (revision 229479) +++ netinet/if_ether.c (working copy) @@ -608,17 +608,17 @@ * No match, use the first inet address on the receive interface * as a dummy address for the rest of the function. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) if (ifa->ifa_addr->sa_family == AF_INET && (ifa->ifa_carp == NULL || (*carp_iamatch_p)(ifa, &enaddr))) { ia = ifatoia(ifa); ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto match; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* * If bridging, fall back to using any inet address. Index: netinet/ip_carp.c =================================================================== --- netinet/ip_carp.c (revision 229479) +++ netinet/ip_carp.c (working copy) @@ -549,14 +549,14 @@ struct timeval sc_tv, ch_tv; /* verify that the VHID is valid on the receiving interface */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); IFNET_FOREACH_IFA(ifp, ifa) if (ifa->ifa_addr->sa_family == af && ifa->ifa_carp->sc_vhid == ch->carp_vhid) { ifa_ref(ifa); break; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (ifa == NULL) { CARPSTATS_INC(carps_badvhid); @@ -1003,16 +1003,16 @@ { struct ifaddr *ifa; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); IFNET_FOREACH_IFA(ifp, ifa) if (ifa->ifa_addr->sa_family == AF_INET6 && ifa->ifa_carp->sc_state == MASTER && IN6_ARE_ADDR_EQUAL(taddr, IFA_IN6(ifa))) { ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (ifa); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (NULL); } @@ -1022,14 +1022,14 @@ { struct ifaddr *ifa; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); IFNET_FOREACH_IFA(ifp, ifa) if (ifa->ifa_addr->sa_family == AF_INET6 && IN6_ARE_ADDR_EQUAL(taddr, IFA_IN6(ifa))) { struct carp_softc *sc = ifa->ifa_carp; struct m_tag *mtag; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); mtag = m_tag_get(PACKET_TAG_CARP, sizeof(struct ifnet *), M_NOWAIT); @@ -1043,7 +1043,7 @@ return (LLADDR(&sc->sc_addr)); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (NULL); } @@ -1512,10 +1512,10 @@ cif->cif_ifp = ifp; TAILQ_INIT(&cif->cif_vrs); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); ifp->if_carp = cif; if_ref(ifp); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); return (cif); @@ -1534,10 +1534,10 @@ KASSERT(TAILQ_EMPTY(&cif->cif_vrs), ("%s: softc list not empty", __func__)); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); ifp->if_carp = NULL; if_rele(ifp); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); CIF_LOCK_DESTROY(cif); Index: netinet/igmp.c =================================================================== --- netinet/igmp.c (revision 229479) +++ netinet/igmp.c (working copy) @@ -618,7 +618,7 @@ igi = ((struct in_ifinfo *)ifp->if_afdata[AF_INET])->ii_igmp; if (igi->igi_version == IGMP_VERSION_3) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -634,7 +634,7 @@ } inm_clear_recorded(inm); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* * Free the in_multi reference(s) for this IGMP lifecycle. */ @@ -751,7 +751,7 @@ * for the interface on which the query arrived, * except those which are already running. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -779,7 +779,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); out_locked: IGMP_UNLOCK(); @@ -852,7 +852,7 @@ */ CTR2(KTR_IGMPV3, "process v2 general query on ifp %p(%s)", ifp, ifp->if_xname); - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -860,7 +860,7 @@ inm = (struct in_multi *)ifma->ifma_protospec; igmp_v2_update_group(inm, timer); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } else { /* * Group-specific IGMPv2 query, we need only @@ -1708,7 +1708,7 @@ IFQ_SET_MAXLEN(&scq, IGMP_MAX_STATE_CHANGE_PACKETS); } - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -1726,7 +1726,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (igi->igi_version == IGMP_VERSION_3) { struct in_multi *tinm; @@ -2023,7 +2023,7 @@ * for all memberships scoped to this link. */ ifp = igi->igi_ifp; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -2068,7 +2068,7 @@ inm->inm_timer = 0; _IF_DRAIN(&inm->inm_scq); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); SLIST_FOREACH_SAFE(inm, &igi->igi_relinmhead, inm_nrele, tinm) { SLIST_REMOVE_HEAD(&igi->igi_relinmhead, inm_nrele); inm_release_locked(inm); @@ -3331,7 +3331,7 @@ ifp = igi->igi_ifp; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET || ifma->ifma_protospec == NULL) @@ -3362,7 +3362,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); loop = (igi->igi_flags & IGIF_LOOPBACK) ? 1 : 0; igmp_dispatch_queue(&igi->igi_gq, IGMP_MAX_RESPONSE_BURST, loop); Index: netipx/ipx.c =================================================================== --- netipx/ipx.c (revision 229479) +++ netipx/ipx.c (working copy) @@ -214,9 +214,9 @@ IPX_IFADDR_WUNLOCK(); ifa_ref(&ia->ia_ifa); /* if_addrhead */ - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); } break; @@ -253,9 +253,9 @@ ipx_ifscrub(ifp, ia); ifa = (struct ifaddr *)ia; - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); ifa_free(ifa); /* if_addrhead */ IPX_IFADDR_WLOCK(); Index: net/if.c =================================================================== --- net/if.c (revision 229479) +++ net/if.c (working copy) @@ -786,10 +786,10 @@ struct ifmultiaddr *ifma; struct ifmultiaddr *next; - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_FOREACH_SAFE(ifma, &ifp->if_multiaddrs, ifma_link, next) if_delmulti_locked(ifp, ifma, 1); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); } /* @@ -1133,10 +1133,10 @@ ifgl->ifgl_group = ifg; ifgm->ifgm_ifp = ifp; - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_INSERT_TAIL(&ifg->ifg_members, ifgm, ifgm_next); TAILQ_INSERT_TAIL(&ifp->if_groups, ifgl, ifgl_next); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); IFNET_WUNLOCK(); @@ -1163,9 +1163,9 @@ return (ENOENT); } - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_REMOVE(&ifp->if_groups, ifgl, ifgl_next); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); TAILQ_FOREACH(ifgm, &ifgl->ifgl_group->ifg_members, ifgm_next) if (ifgm->ifgm_ifp == ifp) @@ -1206,9 +1206,9 @@ strlcpy(groupname, ifgl->ifgl_group->ifg_group, IFNAMSIZ); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_REMOVE(&ifp->if_groups, ifgl, ifgl_next); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); TAILQ_FOREACH(ifgm, &ifgl->ifgl_group->ifg_members, ifgm_next) if (ifgm->ifgm_ifp == ifp) @@ -1250,33 +1250,33 @@ struct ifgroupreq *ifgr = data; if (ifgr->ifgr_len == 0) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifgl, &ifp->if_groups, ifgl_next) ifgr->ifgr_len += sizeof(struct ifg_req); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (0); } len = ifgr->ifgr_len; ifgp = ifgr->ifgr_groups; /* XXX: wire */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifgl, &ifp->if_groups, ifgl_next) { if (len < sizeof(ifgrq)) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (EINVAL); } bzero(&ifgrq, sizeof ifgrq); strlcpy(ifgrq.ifgrq_group, ifgl->ifgl_group->ifg_group, sizeof(ifgrq.ifgrq_group)); if ((error = copyout(&ifgrq, ifgp, sizeof(struct ifg_req)))) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (error); } len -= sizeof(ifgrq); ifgp++; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (0); } @@ -1383,28 +1383,28 @@ if_addr_rlock(struct ifnet *ifp) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); } void if_addr_runlock(struct ifnet *ifp) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } void if_maddr_rlock(struct ifnet *ifp) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); } void if_maddr_runlock(struct ifnet *ifp) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } /* @@ -1516,14 +1516,14 @@ IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != addr->sa_family) continue; if (sa_equal(addr, ifa->ifa_addr)) { if (getref) ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } /* IP6 doesn't have broadcast */ @@ -1533,11 +1533,11 @@ sa_equal(ifa->ifa_broadaddr, addr)) { if (getref) ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } ifa = NULL; done: @@ -1571,7 +1571,7 @@ IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != addr->sa_family) continue; @@ -1580,11 +1580,11 @@ ifa->ifa_broadaddr->sa_len != 0 && sa_equal(ifa->ifa_broadaddr, addr)) { ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } ifa = NULL; done: @@ -1606,18 +1606,18 @@ TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if ((ifp->if_flags & IFF_POINTOPOINT) == 0) continue; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != addr->sa_family) continue; if (ifa->ifa_dstaddr != NULL && sa_equal(addr, ifa->ifa_dstaddr)) { ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } ifa = NULL; done: @@ -1651,12 +1651,12 @@ /* * Scan though each interface, looking for ones that have addresses * in this address family. Maintain a reference on ifa_maybe once - * we find one, as we release the IF_ADDR_LOCK() that kept it stable + * we find one, as we release the IF_ADDR_RLOCK() that kept it stable * when we move onto the next interface. */ IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { char *cp, *cp2, *cp3; @@ -1675,7 +1675,7 @@ if (ifa->ifa_dstaddr != NULL && sa_equal(addr, ifa->ifa_dstaddr)) { ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } } else { @@ -1686,7 +1686,7 @@ if (ifa->ifa_claim_addr) { if ((*ifa->ifa_claim_addr)(ifa, addr)) { ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } continue; @@ -1726,7 +1726,7 @@ } } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } ifa = ifa_maybe; ifa_maybe = NULL; @@ -1752,7 +1752,7 @@ if (af >= AF_MAX) return (NULL); - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != af) continue; @@ -1784,7 +1784,7 @@ done: if (ifa != NULL) ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (ifa); } @@ -2334,9 +2334,9 @@ * lose a race while we check if the membership * already exists. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); ifma = if_findmulti(ifp, &ifr->ifr_addr); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (ifma != NULL) error = EADDRINUSE; else @@ -2762,7 +2762,7 @@ } addrs = 0; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct sockaddr *sa = ifa->ifa_addr; @@ -2794,7 +2794,7 @@ if (sbuf_error(sb) == 0) valid_len = sbuf_len(sb); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (addrs == 0) { bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr)); sbuf_bcat(sb, &ifr, sizeof(ifr)); @@ -2952,13 +2952,13 @@ * If the address is already present, return a new reference to it; * otherwise, allocate storage and set up a new address. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); ifma = if_findmulti(ifp, sa); if (ifma != NULL) { ifma->ifma_refcount++; if (retifma != NULL) *retifma = ifma; - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); return (0); } @@ -3024,7 +3024,7 @@ * pointer is still valid. */ rt_newmaddrmsg(RTM_NEWMADDR, ifma); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); /* * We are certain we have added something, so call down to the @@ -3044,7 +3044,7 @@ free(llsa, M_IFMADDR); unlock_out: - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); return (error); } @@ -3078,12 +3078,12 @@ if (ifp == NULL) return (ENOENT); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); lastref = 0; ifma = if_findmulti(ifp, sa); if (ifma != NULL) lastref = if_delmulti_locked(ifp, ifma, 0); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); if (ifma == NULL) return (ENOENT); @@ -3105,10 +3105,10 @@ struct ifmultiaddr *ifma; struct ifmultiaddr *next; - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_FOREACH_SAFE(ifma, &ifp->if_multiaddrs, ifma_link, next) if_delmulti_locked(ifp, ifma, 0); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); } /* @@ -3145,7 +3145,7 @@ * If and only if the ifnet instance exists: Acquire the address lock. */ if (ifp != NULL) - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); lastref = if_delmulti_locked(ifp, ifma, 0); @@ -3155,7 +3155,7 @@ * Release the address lock. * If the group was left: update the hardware hash filter. */ - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); if (lastref && ifp->if_ioctl != NULL) { (void)(*ifp->if_ioctl)(ifp, SIOCDELMULTI, 0); } @@ -3177,7 +3177,7 @@ if (ifp != NULL && ifma->ifma_ifp != NULL) { KASSERT(ifma->ifma_ifp == ifp, ("%s: inconsistent ifp %p", __func__, ifp)); - IF_ADDR_LOCK_ASSERT(ifp); + IF_ADDR_WLOCK_ASSERT(ifp); } ifp = ifma->ifma_ifp; @@ -3250,14 +3250,14 @@ struct ifaddr *ifa; struct ifreq ifr; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); ifa = ifp->if_addr; if (ifa == NULL) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (EINVAL); } ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); sdl = (struct sockaddr_dl *)ifa->ifa_addr; if (sdl == NULL) { ifa_free(ifa); Index: net/rtsock.c =================================================================== --- net/rtsock.c (revision 229479) +++ net/rtsock.c (working copy) @@ -456,7 +456,7 @@ * Try to find an address on the given outgoing interface * that belongs to the jail. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct sockaddr *sa; sa = ifa->ifa_addr; @@ -468,7 +468,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (!found) { /* * As a last resort return the 'default' jail address. @@ -498,7 +498,7 @@ * Try to find an address on the given outgoing interface * that belongs to the jail. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct sockaddr *sa; sa = ifa->ifa_addr; @@ -511,7 +511,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (!found) { /* * As a last resort return the 'default' jail address. @@ -1547,7 +1547,7 @@ TAILQ_FOREACH(ifp, &V_ifnet, if_link) { if (w->w_arg && w->w_arg != ifp->if_index) continue; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); ifa = ifp->if_addr; info.rti_info[RTAX_IFP] = ifa->ifa_addr; len = rt_msg2(RTM_IFINFO, &info, NULL, w); @@ -1614,13 +1614,13 @@ goto done; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); info.rti_info[RTAX_IFA] = info.rti_info[RTAX_NETMASK] = info.rti_info[RTAX_BRD] = NULL; } done: if (ifp != NULL) - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); IFNET_RUNLOCK(); return (error); } @@ -1641,7 +1641,7 @@ continue; ifa = ifp->if_addr; info.rti_info[RTAX_IFP] = ifa ? ifa->ifa_addr : NULL; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (af && af != ifma->ifma_addr->sa_family) continue; @@ -1662,12 +1662,12 @@ ifmam->ifmam_addrs = info.rti_addrs; error = SYSCTL_OUT(w->w_req, w->w_tmem, len); if (error) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto done; } } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } done: IFNET_RUNLOCK(); Index: netinet6/in6_ifattach.c =================================================================== --- netinet6/in6_ifattach.c (revision 229479) +++ netinet6/in6_ifattach.c (working copy) @@ -243,7 +243,7 @@ static u_int8_t allone[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_LINK) continue; @@ -255,7 +255,7 @@ goto found; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; @@ -282,7 +282,7 @@ /* look at IEEE802/EUI64 only */ if (addrlen != 8 && addrlen != 6) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } @@ -292,11 +292,11 @@ * card insertion. */ if (bcmp(addr, allzero, addrlen) == 0) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } if (bcmp(addr, allone, addrlen) == 0) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } @@ -317,11 +317,11 @@ case IFT_ARCNET: if (addrlen != 1) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } if (!addr[0]) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } @@ -345,17 +345,17 @@ * identifier source (can be renumbered). * we don't do this. */ - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; default: - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } /* sanity check: g bit must not indicate "group" */ if (EUI64_GROUP(in6)) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } @@ -368,11 +368,11 @@ */ if ((in6->s6_addr[8] & ~(EUI64_GBIT | EUI64_UBIT)) == 0x00 && bcmp(&in6->s6_addr[9], allzero, 7) == 0) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return -1; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return 0; } @@ -837,9 +837,9 @@ } /* remove from the linked list */ - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); ifa_free(ifa); /* if_addrhead */ IN6_IFADDR_WLOCK(); @@ -954,7 +954,7 @@ * We need to do this as IF_ADDR_LOCK() may be re-acquired * by code further down. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET6 || ifma->ifma_protospec == NULL) @@ -962,7 +962,7 @@ inm = (struct in6_multi *)ifma->ifma_protospec; LIST_INSERT_HEAD(&purgeinms, inm, in6m_entry); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); LIST_FOREACH_SAFE(inm, &purgeinms, in6m_entry, tinm) { LIST_REMOVE(inm, in6m_entry); Index: netinet6/in6_var.h =================================================================== --- netinet6/in6_var.h (revision 229479) +++ netinet6/in6_var.h (working copy) @@ -716,9 +716,9 @@ struct in6_multi *inm; IN6_MULTI_LOCK(); - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); inm = in6m_lookup_locked(ifp, mcaddr); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); IN6_MULTI_UNLOCK(); return (inm); Index: netinet6/icmp6.c =================================================================== --- netinet6/icmp6.c (revision 229479) +++ netinet6/icmp6.c (working copy) @@ -1782,7 +1782,7 @@ IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_list) { addrsofif = 0; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -1833,7 +1833,7 @@ } addrsofif++; /* count the address */ } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (iffound) { *ifpp = ifp; IFNET_RUNLOCK_NOSLEEP(); @@ -1868,7 +1868,7 @@ again: for (; ifp; ifp = TAILQ_NEXT(ifp, if_list)) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -1923,7 +1923,7 @@ /* now we can copy the address */ if (resid < sizeof(struct in6_addr) + sizeof(u_int32_t)) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* * We give up much more copy. * Set the truncate flag and return. @@ -1970,7 +1970,7 @@ resid -= (sizeof(struct in6_addr) + sizeof(u_int32_t)); copied += (sizeof(struct in6_addr) + sizeof(u_int32_t)); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (ifp0) /* we need search only on the specified IF */ break; } Index: netinet6/nd6.c =================================================================== --- netinet6/nd6.c (revision 229479) +++ netinet6/nd6.c (working copy) @@ -692,7 +692,7 @@ struct in6_ifaddr *public_ifa6 = NULL; ifp = ia6->ia_ifa.ifa_ifp; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct in6_ifaddr *it6; @@ -734,7 +734,7 @@ if (public_ifa6 != NULL) ifa_ref(&public_ifa6->ia_ifa); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (public_ifa6 != NULL) { int e; @@ -1366,7 +1366,7 @@ */ int duplicated_linklocal = 0; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -1377,7 +1377,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (duplicated_linklocal) { ND.flags |= ND6_IFF_IFDISABLED; @@ -1395,14 +1395,14 @@ /* Mark all IPv6 address as tentative. */ ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ia = (struct in6_ifaddr *)ifa; ia->ia6_flags |= IN6_IFF_TENTATIVE; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } if (ND.flags & ND6_IFF_AUTO_LINKLOCAL) { @@ -1422,7 +1422,7 @@ */ int haslinklocal = 0; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -1432,7 +1432,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (!haslinklocal) in6_ifattach(ifp, NULL); } Index: netinet6/in6.c =================================================================== --- netinet6/in6.c (revision 229479) +++ netinet6/in6.c (working copy) @@ -978,9 +978,9 @@ ia->ia_ifa.ifa_netmask = (struct sockaddr *)&ia->ia_prefixmask; ia->ia_ifp = ifp; ifa_ref(&ia->ia_ifa); /* if_addrhead */ - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_INSERT_TAIL(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); ifa_ref(&ia->ia_ifa); /* in6_ifaddrhead */ IN6_IFADDR_WLOCK(); @@ -1335,7 +1335,7 @@ * link-local and node-local all-nodes multicast * address routes */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa0, &ifp->if_addrhead, ifa_link) { if ((ifa0->ifa_addr->sa_family != AF_INET6) || memcmp(&satosin6(ifa0->ifa_addr)->sin6_addr, @@ -1347,7 +1347,7 @@ } if (ifa0 != NULL) ifa_ref(ifa0); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* * Remove the loopback route to the interface address. @@ -1517,9 +1517,9 @@ { int s = splnet(); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); ifa_free(&ia->ia_ifa); /* if_addrhead */ /* @@ -1746,7 +1746,7 @@ } } - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -1769,7 +1769,7 @@ } if (ifa != NULL) ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (!ifa) return EADDRNOTAVAIL; ia = ifa2ia6(ifa); @@ -1853,13 +1853,13 @@ * if this is its first address, * and to validate the address if necessary. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ifacount++; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); ia->ia_addr = *sin6; @@ -1930,7 +1930,7 @@ { struct ifaddr *ifa; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -1942,7 +1942,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return ((struct in6_ifaddr *)ifa); } @@ -1957,7 +1957,7 @@ { struct ifaddr *ifa; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -1966,7 +1966,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return ((struct in6_ifaddr *)ifa); } @@ -2207,7 +2207,7 @@ * If two or more, return one which matches the dst longest. * If none, return one of global addresses assigned other ifs. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -2241,7 +2241,7 @@ } if (besta) { ifa_ref(&besta->ia_ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (besta); } @@ -2262,10 +2262,10 @@ if (ifa != NULL) ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); return (struct in6_ifaddr *)ifa; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* use the last-resort values, that are, deprecated addresses */ if (dep[0]) @@ -2285,7 +2285,7 @@ struct ifaddr *ifa; struct in6_ifaddr *ia; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -2301,7 +2301,7 @@ arc4random() % (MAX_RTR_SOLICITATION_DELAY * hz)); } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* * special cases, like 6to4, are handled in in6_ifattach Index: netinet6/mld6.c =================================================================== --- netinet6/mld6.c (revision 229479) +++ netinet6/mld6.c (working copy) @@ -543,7 +543,7 @@ mli = MLD_IFINFO(ifp); if (mli->mli_version == MLD_VERSION_2) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET6 || ifma->ifma_protospec == NULL) @@ -555,7 +555,7 @@ } in6m_clear_recorded(inm); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); SLIST_FOREACH_SAFE(inm, &mli->mli_relinmhead, in6m_nrele, tinm) { SLIST_REMOVE_HEAD(&mli->mli_relinmhead, in6m_nrele); @@ -694,7 +694,7 @@ if (timer == 0) timer = 1; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); if (is_general_query) { /* * For each reporting group joined on this @@ -726,7 +726,7 @@ in6_clearscope(&mld->mld_addr); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); MLD_UNLOCK(); IN6_MULTI_UNLOCK(); @@ -937,10 +937,10 @@ * Queries for groups we are not a member of on this * link are simply ignored. */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); inm = in6m_lookup_locked(ifp, &mld->mld_addr); if (inm == NULL) { - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto out_locked; } if (nsrc > 0) { @@ -948,7 +948,7 @@ &V_mld_gsrdelay)) { CTR1(KTR_MLD, "%s: GS query throttled.", __func__); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); goto out_locked; } } @@ -966,7 +966,7 @@ /* XXX Clear embedded scope ID as userland won't expect it. */ in6_clearscope(&mld->mld_addr); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); } out_locked: @@ -1176,7 +1176,7 @@ IN6_MULTI_LOCK(); MLD_LOCK(); - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); /* * MLDv1 report suppression. @@ -1224,8 +1224,8 @@ } out_locked: + IF_ADDR_RUNLOCK(ifp); MLD_UNLOCK(); - IF_ADDR_UNLOCK(ifp); IN6_MULTI_UNLOCK(); /* XXX Clear embedded scope ID as userland won't expect it. */ @@ -1401,7 +1401,7 @@ IFQ_SET_MAXLEN(&scq, MLD_MAX_STATE_CHANGE_PACKETS); } - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET6 || ifma->ifma_protospec == NULL) @@ -1417,7 +1417,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); switch (mli->mli_version) { case MLD_VERSION_1: @@ -1685,7 +1685,7 @@ ifp = mli->mli_ifp; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET6) continue; @@ -1722,7 +1722,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); SLIST_FOREACH_SAFE(inm, &mli->mli_relinmhead, in6m_nrele, tinm) { SLIST_REMOVE_HEAD(&mli->mli_relinmhead, in6m_nrele); in6m_release_locked(inm); @@ -2996,7 +2996,7 @@ ifp = mli->mli_ifp; - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET6 || ifma->ifma_protospec == NULL) @@ -3027,7 +3027,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); mld_dispatch_queue(&mli->mli_gq, MLD_MAX_RESPONSE_BURST); Index: netinet6/ip6_input.c =================================================================== --- netinet6/ip6_input.c (revision 229479) +++ netinet6/ip6_input.c (working copy) @@ -617,7 +617,7 @@ bad = 1; #define sa_equal(a1, a2) \ (bcmp((a1), (a2), ((a1))->sin6_len) == 0) - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family != dst6.sin6_family) continue; @@ -649,7 +649,7 @@ ip6_sprintf(ip6bufs, &ip6->ip6_src), ip6_sprintf(ip6bufd, &ip6->ip6_dst))); } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); LLE_RUNLOCK(lle); if (bad) goto bad; Index: netinet6/nd6_rtr.c =================================================================== --- netinet6/nd6_rtr.c (revision 229479) +++ netinet6/nd6_rtr.c (working copy) @@ -451,11 +451,11 @@ info.rti_info[RTAX_NETMASK] = rt_mask(rt); ifp = rt->rt_ifp; if (ifp != NULL) { - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); ifa = TAILQ_FIRST(&ifp->if_addrhead); info.rti_info[RTAX_IFP] = ifa->ifa_addr; ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } else ifa = NULL; @@ -1107,7 +1107,7 @@ * consider autoconfigured addresses while RFC2462 simply said * "address". */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct in6_ifaddr *ifa6; u_int32_t remaininglifetime; @@ -1230,7 +1230,7 @@ ifa6->ia6_lifetime = lt6_tmp; ifa6->ia6_updatetime = time_second; } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); if (ia6_match == NULL && new->ndpr_vltime) { int ifidlen; @@ -1588,14 +1588,14 @@ IN6_IFF_NOTREADY | IN6_IFF_ANYCAST); if (ifa == NULL) { /* XXX: freebsd does not have ifa_ifwithaf */ - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family == AF_INET6) break; } if (ifa != NULL) ifa_ref(ifa); - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); /* should we care about ia6_flags? */ } if (ifa == NULL) { Index: netinet6/in6_mcast.c =================================================================== --- netinet6/in6_mcast.c (revision 229479) +++ netinet6/in6_mcast.c (working copy) @@ -400,7 +400,7 @@ * re-acquire around the call. */ IN6_MULTI_LOCK_ASSERT(); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); inm = in6m_lookup_locked(ifp, group); if (inm != NULL) { @@ -424,11 +424,11 @@ * Check if a link-layer group is already associated * with this network-layer group on the given ifnet. */ - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); error = if_addmulti(ifp, (struct sockaddr *)&gsin6, &ifma); if (error != 0) return (error); - IF_ADDR_LOCK(ifp); + IF_ADDR_WLOCK(ifp); /* * If something other than netinet6 is occupying the link-layer @@ -455,7 +455,7 @@ goto out_locked; } - IF_ADDR_LOCK_ASSERT(ifp); + IF_ADDR_WLOCK_ASSERT(ifp); /* * A new in6_multi record is needed; allocate and initialize it. @@ -487,7 +487,7 @@ *pinm = inm; out_locked: - IF_ADDR_UNLOCK(ifp); + IF_ADDR_WUNLOCK(ifp); return (error); } @@ -2719,7 +2719,7 @@ IN6_MULTI_LOCK(); - IF_ADDR_LOCK(ifp); + IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_INET6 || ifma->ifma_protospec == NULL) @@ -2748,7 +2748,7 @@ break; } } - IF_ADDR_UNLOCK(ifp); + IF_ADDR_RUNLOCK(ifp); IN6_MULTI_UNLOCK();