Date: Thu, 18 Dec 2003 15:52:19 -0800 (PST) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 44078 for review Message-ID: <200312182352.hBINqJhI003541@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200312182352.hBINqJhI003541>