select/poll for sockets in kernel space

Julian Elischer julian at elischer.org
Tue May 25 16:41:07 UTC 2010


On 5/25/10 5:55 AM, John Baldwin wrote:
> On Tuesday 25 May 2010 5:02:35 am Dmitry Krivenok wrote:
>> Hello Hackers!
>>
>> I'm developing a module for FreeBSD-8 and encountered the problem with
>> polling sockets.
[...]
>>
>> Thanks in advance!
>>
>> P.S.
>> I know about kqueue, but I have to use select/poll is this task.
>
> Why do you have to use select/poll?  If these are dedicated sockets that you
> create internally, then the right thing to do is probably to install your own
> upcalls that get called when data for a socket arrives.  This is what the in-
> kernel NFS client does to handle incoming data.

It's also what netgraph does.
An incoming packet is sent to the ksocket node and immediately
passed to whatever node is attached to the ksocket node.

If your project is of high throughput requirement, then you might
look ad duplicating what it does (in /sys/netgraph/ng_ksocket.c),
or alternatively, if your project is of medium throughput,
(or lower) you might consider simply implementing it as a
netgraph node and make use of the configuration
framework etc. that already exists, and actually use a netgraph
ksocket node to do the work for you.

>



More information about the freebsd-hackers mailing list