PERFORCE change 44078 for review
Sam Leffler
sam at FreeBSD.org
Thu Dec 18 15:52:21 PST 2003
http://perforce.freebsd.org/chv.cgi?CH=44078
Change 44078 by sam at 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);
}
/*
More information about the p4-projects
mailing list