From owner-p4-projects@FreeBSD.ORG Thu Apr 8 18:52:07 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 395DC16A4D0; Thu, 8 Apr 2004 18:52:07 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0C56516A4CE for ; Thu, 8 Apr 2004 18:52:07 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 02F7843D31 for ; Thu, 8 Apr 2004 18:52:07 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i391q6Ge058163 for ; Thu, 8 Apr 2004 18:52:06 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i391q6T5058154 for perforce@freebsd.org; Thu, 8 Apr 2004 18:52:06 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Thu, 8 Apr 2004 18:52:06 -0700 (PDT) Message-Id: <200404090152.i391q6T5058154@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 50685 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Apr 2004 01:52:07 -0000 http://perforce.freebsd.org/chv.cgi?CH=50685 Change 50685 by rwatson@rwatson_paprika on 2004/04/08 18:51:56 Integrate netperf_socket: - Loop back locking of the netatalk AARP code and cache. Affected files ... .. //depot/projects/netperf_socket/sys/netatalk/aarp.c#6 integrate Differences ... ==== //depot/projects/netperf_socket/sys/netatalk/aarp.c#6 (text+ko) ==== @@ -2,7 +2,7 @@ * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. * - * $FreeBSD: src/sys/netatalk/aarp.c,v 1.28 2004/03/22 04:50:36 rwatson Exp $ + * $FreeBSD: src/sys/netatalk/aarp.c,v 1.29 2004/04/09 01:40:12 rwatson Exp $ */ #include "opt_atalk.h" @@ -36,11 +36,20 @@ #define AARPTAB_SIZE (AARPTAB_BSIZ * AARPTAB_NB) static struct aarptab aarptab[AARPTAB_SIZE]; +static struct mtx aarptab_mtx; +MTX_SYSINIT(aarptab_mtx, &aarptab_mtx, "aarptab_mtx", MTX_DEF); + +#define AARPTAB_LOCK() mtx_lock(&aarptab_mtx) +#define AARPTAB_UNLOCK() mtx_unlock(&aarptab_mtx) +#define AARPTAB_LOCK_ASSERT() mtx_assert(&aarptab_mtx, MA_OWNED) +#define AARPTAB_UNLOCK_ASSERT() mtx_assert(&aarptab_mtx, MA_NOTOWNED) + #define AARPTAB_HASH(a) \ ((((a).s_net << 8) + (a).s_node) % AARPTAB_NB) #define AARPTAB_LOOK(aat, addr) { \ int n; \ + AARPTAB_LOCK_ASSERT(); \ aat = &aarptab[ AARPTAB_HASH(addr) * AARPTAB_BSIZ ]; \ for (n = 0; n < AARPTAB_BSIZ; n++, aat++) \ if (aat->aat_ataddr.s_net == (addr).s_net && \ @@ -79,20 +88,20 @@ aarptimer(void *ignored) { struct aarptab *aat; - int i, s; + int i; aarptimer_ch = timeout(aarptimer, (caddr_t)0, AARPT_AGE * hz); aat = aarptab; + AARPTAB_LOCK(); for (i = 0; i < AARPTAB_SIZE; i++, aat++) { if (aat->aat_flags == 0 || (aat->aat_flags & ATF_PERM)) continue; if (++aat->aat_timer < ((aat->aat_flags & ATF_COM) ? AARPT_KILLC : AARPT_KILLI)) continue; - s = splimp(); aarptfree(aat); - splx(s); } + AARPTAB_UNLOCK(); } /* @@ -130,6 +139,7 @@ struct llc *llc; struct sockaddr sa; + AARPTAB_UNLOCK_ASSERT(); if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) { return; } @@ -214,7 +224,6 @@ { struct at_ifaddr *aa; struct aarptab *aat; - int s; if (at_broadcast(destsat)) { m->m_flags |= M_BCAST; @@ -231,7 +240,7 @@ return (1); } - s = splimp(); + AARPTAB_LOCK(); AARPTAB_LOOK(aat, destsat->sat_addr); if (aat == NULL) { /* No entry */ aat = aarptnew(&destsat->sat_addr); @@ -239,8 +248,8 @@ panic("aarpresolve: no free entry"); } aat->aat_hold = m; + AARPTAB_UNLOCK(); aarpwhohas(ac, destsat); - splx(s); return (0); } /* found an entry */ @@ -248,7 +257,7 @@ if (aat->aat_flags & ATF_COM) { /* entry is COMplete */ bcopy((caddr_t)aat->aat_enaddr, (caddr_t)desten, sizeof(aat->aat_enaddr)); - splx(s); + AARPTAB_UNLOCK(); return (1); } /* entry has not completed */ @@ -256,8 +265,8 @@ m_freem(aat->aat_hold); } aat->aat_hold = m; + AARPTAB_UNLOCK(); aarpwhohas(ac, destsat); - splx(s); return (0); } @@ -390,6 +399,7 @@ } } + AARPTAB_LOCK(); AARPTAB_LOOK(aat, spa); if (aat != NULL) { if (op == AARPOP_PROBE) { @@ -399,6 +409,7 @@ * to arp for him. */ aarptfree(aat); + AARPTAB_UNLOCK(); m_freem(m); return; } @@ -409,12 +420,14 @@ if (aat->aat_hold) { struct mbuf *mhold = aat->aat_hold; aat->aat_hold = NULL; + AARPTAB_UNLOCK(); sat.sat_len = sizeof(struct sockaddr_at); sat.sat_family = AF_APPLETALK; sat.sat_addr = spa; (*ac->ac_if.if_output)(&ac->ac_if, mhold, (struct sockaddr *)&sat, NULL); /* XXX */ - } + } else + AARPTAB_UNLOCK(); } else if ((tpa.s_net == ma.s_net) && (tpa.s_node == ma.s_node) && (op != AARPOP_PROBE) @@ -422,7 +435,9 @@ bcopy((caddr_t)ea->aarp_sha, (caddr_t)aat->aat_enaddr, sizeof(ea->aarp_sha)); aat->aat_flags |= ATF_COM; - } + AARPTAB_UNLOCK(); + } else + AARPTAB_UNLOCK(); /* * Don't respond to responses, and never respond if we're @@ -477,6 +492,7 @@ aarptfree(struct aarptab *aat) { + AARPTAB_LOCK_ASSERT(); if (aat->aat_hold) m_freem(aat->aat_hold); aat->aat_hold = NULL; @@ -485,7 +501,7 @@ aat->aat_ataddr.s_node = 0; } - struct aarptab * +struct aarptab * aarptnew(addr) struct at_addr *addr; { @@ -494,6 +510,7 @@ struct aarptab *aat, *aato = NULL; static int first = 1; + AARPTAB_LOCK_ASSERT(); if (first) { first = 0; aarptimer_ch = timeout(aarptimer, (caddr_t)0, hz); @@ -626,10 +643,12 @@ int i; untimeout(aarptimer, 0, aarptimer_ch); + AARPTAB_LOCK(); for (i = 0, aat = aarptab; i < AARPTAB_SIZE; i++, aat++) { if (aat->aat_hold) { m_freem(aat->aat_hold); aat->aat_hold = NULL; } } + AARPTAB_UNLOCK(); }