Date: Thu, 31 Oct 2002 11:46:04 +1100 From: Gregory Bond <gnb@itga.com.au> To: Andriy Gapon <avg@icyb.net.ua> Cc: freebsd-bugs@FreeBSD.ORG Subject: Re: kern/44417: ipfw layer2 rules are not checked for ether_output_frame() on bridged interface Message-ID: <200210310046.LAA06800@lightning.itga.com.au> In-Reply-To: Your message of Wed, 30 Oct 2002 16:20:03 -0800.
next in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210310046.LAA06800>
