Initialisation of a networking protocol
Robert Watson
rwatson at FreeBSD.org
Mon Sep 29 22:17:50 UTC 2008
On Mon, 29 Sep 2008, Ryan French wrote:
> I'm having a bit of trouble with my MPLS protocol code at the moment. I have
> the code written and compiling (mostly based on some OpenBSD code I was
> shown) but when an MPLS packet is received it doesnt appear as thou my
> mpls_input routine is being called. I believe this is because I have not
> initialised the protocol properly. I have created protosw structure for MPLS
> as well as created an mpls_init(void) function which registers the protocol
> with netisr via netisr_register. Other than that I am not really sure where
> I tell the kernel to call the mpls_init function so that the protocol is
> initialised, and a couple of hours of googling/looking through ip6 code
> hasnt really helped at all. If anyone can help and needs to see the code it
> can be viewed on Perforce at
> http://perforce.freebsd.org/depotTreeBrowser.cgi?FSPC=//depot/projects/soc2008/rfrench_mpls&HIDEDEL=NO
Hi Ryan:
netisr is just a dispatch facility consisting of a series of named queues,
worker thread(s), and a dispatch model -- it is the responsibility of some
other piece of driver or protocol code to inject packets using netisr_queue()
or netisr_dispatch(). Typically this occurs in the decapsulation code for the
layer below the dispatched layer -- often the link layer. You can take a look
at current dispatch points here:
http://fxr.watson.org/fxr/ident?im=bigexcerpts;i=netisr_queue
http://fxr.watson.org/fxr/ident?im=bigexcerpts;i=netisr_dispatch
A typical dispatch point is ether_demux(), which switches on the etherhet
frame header's protocol field and then hands off the packet to netisr for
dispatch. If the dispatch may lead to recursion, then you may need to use
netisr_queue() rather than netisr_direct() to disallow direct dispatch.
Robert N M Watson
Computer Laboratory
University of Cambridge
More information about the freebsd-net
mailing list