Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Mar 2002 15:43:45 -0800
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        David Boggs <boggs@boggs.palo-alto.ca.us>
Cc:        FreeBSD-hackers@FreeBSD.ORG
Subject:   Re: Berkeley Packet Filter question
Message-ID:  <20020307154345.A2084@Odin.AC.HMC.Edu>
In-Reply-To: <200203072329.PAA15449@gw.wa3dbj.vix.com>; from boggs@boggs.palo-alto.ca.us on Thu, Mar 07, 2002 at 03:29:44PM -0800
References:  <200203072329.PAA15449@gw.wa3dbj.vix.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--9jxsPFA5p3P2qPhR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Mar 07, 2002 at 03:29:44PM -0800, David Boggs wrote:
> Attached below is some BPF code.  As I read it, bpfattach() is passed
> an ifp (struct ifnet *).  It mallocs a 'bpf_if' (1) and installs the ifp
> in it (2).  Then it uses this pointer to ZERO a pointer in the ifp named
> if_bpf (3) (presumably a back-pointer).  Later, bpf_mtap() is called,
> and it picks up the back-pointer to the if_bpf (4) (which has been ZEROed)
> and dereferences it (5), causing a type 12 trap.
>=20
> Grepping through other device drivers, I note that most of them don't
> call bpfattach(), but two or three do.  Those that do, are NOT passing
> a struct ifnet * as the first argument.  What's going on here?

I'm not sure where you're looking for drivers, but every instance of
bpfattach I can find passes in a struct ifnet * at the first argument.
Take a look at sys/net/if_loop.c for a trivial example of bpf usage.
The key thing is that in the input phase you check the if_bpf pointer
and only call bpf_mtap if it's non-NULL and hence there is a listener.

-- Brooks

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--9jxsPFA5p3P2qPhR
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8h/swXY6L6fI4GtQRAtMdAJ4oFaITy/IoDMBIR+9zvK5KoY9rOwCgj+LS
7hl78O9Do1u1FwMR95VOjFk=
=INr8
-----END PGP SIGNATURE-----

--9jxsPFA5p3P2qPhR--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020307154345.A2084>