From owner-freebsd-hackers Fri Oct 3 13:52:53 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id NAA12159 for hackers-outgoing; Fri, 3 Oct 1997 13:52:53 -0700 (PDT) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id NAA12154 for ; Fri, 3 Oct 1997 13:52:49 -0700 (PDT) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id NAA16929 for ; Fri, 3 Oct 1997 13:52:11 -0700 (PDT) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma016924; Fri Oct 3 13:51:41 1997 Received: (from archie@localhost) by bubba.whistle.com (8.8.5/8.6.12) id NAA23325 for freebsd-hackers@freebsd.org; Fri, 3 Oct 1997 13:51:40 -0700 (PDT) From: Archie Cobbs Message-Id: <199710032051.NAA23325@bubba.whistle.com> Subject: bpfattach() bug To: freebsd-hackers@freebsd.org Date: Fri, 3 Oct 1997 13:51:40 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk FYI- The bpfattach() routine makes an assumption that it will only ever be called at boot time (specifically, before any /dev/bpf* devices are opened). This assumption is false, for example, in any case where an interface can be created dynamically (such as ours). The following patch fixes this in both -stable and -current. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com *** /usr/src/sys/net/bpf.c Wed Apr 9 00:31:05 1997 --- bpf.c Fri Oct 3 13:11:44 1997 *************** *** 115,120 **** --- 115,121 ---- */ static struct bpf_if *bpf_iflist; static struct bpf_d bpf_dtab[NBPFILTER]; + static int bpf_dtab_init; static int bpf_allocbufs __P((struct bpf_d *)); static void bpf_attachd __P((struct bpf_d *d, struct bpf_if *bp)); *************** *** 1293,1301 **** /* * Mark all the descriptors free if this hasn't been done. */ ! if (!D_ISFREE(&bpf_dtab[0])) for (i = 0; i < NBPFILTER; ++i) D_MARKFREE(&bpf_dtab[i]); if (bootverbose) printf("bpf: %s%d attached\n", ifp->if_name, ifp->if_unit); --- 1294,1304 ---- /* * Mark all the descriptors free if this hasn't been done. */ ! if (!bpf_dtab_init) { for (i = 0; i < NBPFILTER; ++i) D_MARKFREE(&bpf_dtab[i]); + bpf_dtab_init = 1; + } if (bootverbose) printf("bpf: %s%d attached\n", ifp->if_name, ifp->if_unit);