From owner-p4-projects@FreeBSD.ORG Thu Dec 18 15:52:21 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6234816A4D0; Thu, 18 Dec 2003 15:52:21 -0800 (PST) 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 3E09416A4CE for ; Thu, 18 Dec 2003 15:52:21 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4DFAA43D1D for ; Thu, 18 Dec 2003 15:52:20 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id hBINqK0B003547 for ; Thu, 18 Dec 2003 15:52:20 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id hBINqJhI003541 for perforce@freebsd.org; Thu, 18 Dec 2003 15:52:19 -0800 (PST) (envelope-from sam@freebsd.org) Date: Thu, 18 Dec 2003 15:52:19 -0800 (PST) Message-Id: <200312182352.hBINqJhI003541@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 44078 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: Thu, 18 Dec 2003 23:52:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=44078 Change 44078 by sam@sam_ebb on 2003/12/18 15:51:22 several cleanups/fixups to bpfwrite: o eliminate use of static sockaddr; it was being manaaged wrong meaning subsequent writes might inherit bogus bits from a previous one o remove Giant locking around if_output call; not sure what this was supposed to do but it's not useful and Giant is already held because bpfwrite is only invoked from the VFS layer which already grabs Giant o add locking under #ifdef MAC to protect it's work Affected files ... .. //depot/projects/netperf+sockets/sys/net/bpf.c#3 edit Differences ... ==== //depot/projects/netperf+sockets/sys/net/bpf.c#3 (text+ko) ==== @@ -557,7 +557,7 @@ struct ifnet *ifp; struct mbuf *m; int error; - static struct sockaddr dst; + struct sockaddr dst; int datlen; if (d->bd_bif == 0) @@ -568,6 +568,7 @@ if (uio->uio_resid == 0) return (0); + bzero(&dst, sizeof(dst)); error = bpf_movein(uio, (int)d->bd_bif->bif_dlt, &m, &dst, &datlen); if (error) return (error); @@ -578,16 +579,13 @@ if (d->bd_hdrcmplt) dst.sa_family = pseudo_AF_HDRCMPLT; - mtx_lock(&Giant); #ifdef MAC + BPFD_LOCK(d); mac_create_mbuf_from_bpfdesc(d, m); + BPFD_UNLOCK(d); #endif - error = (*ifp->if_output)(ifp, m, &dst, (struct rtentry *)0); - mtx_unlock(&Giant); - /* - * The driver frees the mbuf. - */ - return (error); + /* NB: the driver frees the mbuf */ + return (*ifp->if_output)(ifp, m, &dst, (struct rtentry *)0); } /*