netgraph question

Julian Elischer julian at
Fri Jul 15 20:09:46 GMT 2005

Nathanael M Van Vorst wrote:

>I have some questions about netgraph. I have been using the framework for
>project for a little while. I am at the point where I want to hand-off
>netgraph items to a kernel thread or a kernel module. Then I want the
>module or thread to do some processing and hand this back to netgraph.

I guess I should answer you on this one..

We do not have a specific facility to allow a netgraph node to
create or run as a separate kernel thread. The code should be able to
pass stuff to a kernel thread in much the same way that it can
pass stuff to a userland thread. i.e. get some lock, put it in a queue, 
drop the lock again
and do a wakeup on the thread to tell it there is something to get.

I guess it could create the thread during node startup or type addition..

there are several examples of threads being created in /sys/kern
look for instances of kthread_create().

>I looked through a little bit, and did not find an easy way. Did I miss it?

tell us more about what you'd like to do..

>Marching on, I wrote up a little module that had two functions that a node
>could call. One to register the hook to pass items back on, and one to pass
>items to to the module. Inside the module I call NG_FWD_ITEM to send the
>item back on the passed in hook. It always crashes in the ITEM_DEBUG
>macro. Help? Where should I go? When I get a kernel core, the stack is
>corrupt so it is f no use.

I don't quite understand what you mean by "register the hook"

>If anyone is curious I can send the little test code I have cobbled
>together to see how I might do this.

send to me directly.

>Nathanael Van Vorst
>   vanvorst at
>“It is intuitively obvious to even the
>              most casual of observers!”
>freebsd-net at mailing list
>To unsubscribe, send any mail to "freebsd-net-unsubscribe at"

More information about the freebsd-net mailing list