From owner-freebsd-bugs Wed Oct 30 16:46:21 2002 Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3B49937B401 for ; Wed, 30 Oct 2002 16:46:20 -0800 (PST) Received: from ns.itga.com.au (ns.itga.com.au [202.53.40.210]) by mx1.FreeBSD.org (Postfix) with ESMTP id DFF7043E3B for ; Wed, 30 Oct 2002 16:46:16 -0800 (PST) (envelope-from gnb@itga.com.au) Received: from lightning.itga.com.au (lightning.itga.com.au [192.168.71.20]) by ns.itga.com.au (8.9.3/8.9.3) with ESMTP id LAA13998; Thu, 31 Oct 2002 11:46:05 +1100 (EST) (envelope-from gnb@itga.com.au) Received: from lightning.itga.com.au (localhost [127.0.0.1]) by lightning.itga.com.au (8.9.3/8.9.3) with ESMTP id LAA06800; Thu, 31 Oct 2002 11:46:04 +1100 (EST) Message-Id: <200210310046.LAA06800@lightning.itga.com.au> X-Mailer: exmh version 2.4 05/15/2001 with nmh-1.0.4 From: Gregory Bond To: Andriy Gapon Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: kern/44417: ipfw layer2 rules are not checked for ether_output_frame() on bridged interface In-reply-to: Your message of Wed, 30 Oct 2002 16:20:03 -0800. Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 31 Oct 2002 11:46:04 +1100 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > Btw, could you please educate me a little bit about this splXXX() stuff ? > I've tried to understand it from man page, but failed... > What purpose does it serve here ? Is this like some kind of locking ? Yep. If you have data structures that might be modified by both system calls and interrupts (e.g. send/receive lists from network adaptors), then you need to make sure the interrupt doesn't happen while the system call is in the middle of modifying the data. This is achieved by 3 steps: - Choosing a "name" for this spl ("splnet" in this case) - Making the interrupt only happen when "splnet" is not active. This is actually done (I think) by checking the spl list in the hardware interrupt routine and dispatching to the interrupt handler if splnet is not active, or queueing an interrupt service request if splnet is active. The association of hardware device interrupt to spl is done via the config file (the "tty" or "net" keywords, tho these days they are almost all just defaulted based on device type.) In the old days, on the early PDP-11 Unix versions, this was done with hardware interrupt masks, and the various splXXX() levels had a strict hierarchy, so spltty() meant "don't enable tty interrupts, but let net and bio interrupts happen", but splbio() meant "Don't enable any interrupts at all." - The code called from the system calls then does the following: s = splnet() // Do stuff with data structures splx(s) This ensures the interrupt can't be services while the data structures are being updated by the system calls. The splXXX() routines return the current spl status, then set the named spl as active. splx() means "return to the previous interrupt state" and (I think) will also cause any device interrupts that were queued while splnet() was active to be processed. Note that there are no actual semaphores/spinlocks here, it's all done either with hardware interrupt masks or simple queues. Of course, in an SMP system, this all gets much harder. I dunno how the FreeBSD 5 kernel handles SPLs. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message