From owner-freebsd-hackers Thu Mar 7 15:44:16 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by hub.freebsd.org (Postfix) with ESMTP id 795A437B405 for ; Thu, 7 Mar 2002 15:44:08 -0800 (PST) Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.11.0/8.11.0) id g27Nhjs03688; Thu, 7 Mar 2002 15:43:45 -0800 Date: Thu, 7 Mar 2002 15:43:45 -0800 From: Brooks Davis To: David Boggs Cc: FreeBSD-hackers@FreeBSD.ORG Subject: Re: Berkeley Packet Filter question Message-ID: <20020307154345.A2084@Odin.AC.HMC.Edu> References: <200203072329.PAA15449@gw.wa3dbj.vix.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i 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 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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