lkml.org 
[lkml]   [1999]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: how do I direct raw packages to a given socket?
From
Date
schuldei@uni-bremen.de (Andreas Schuldei) writes:

>
> Right now I open a socket in userspace and bind it to the devive and
> give it the same protocol as I specified in the kernel-module.
> This way I can communicate with the devices on the bitbus.
> But I want to do so from several processes. Right now all sockets
> could receive all packages. Of cause I can open several raw sockets
> with different file descriptors. Can I direct a package to the userspace
> socket by specifing something like
>
> skb->sock=filedescriptor;

no, this does not work. sock is a pointer. filedescriptor is a index.

if you want to multiplex it you would need to write a kernel
protocol family that can supply multiple sockets.

If the problem is not very performance critical you can get around it
with a small user space library that binds a packet socket to
MCAT_PROTO and then does something like:

/* only receive header */
n = recv(packet_sk, buf, headerlen, MSG_PEEK);
if (n <= headerlen) error();

if (header is for me) {
n = recv(packet_sk, buf, buflen, 0);
....
}

Basically the MSG_PEEK avoids the full data copy if the packet
is not for you. But it would still eat a lot of context switches,
but for low speed networking (e.g. <= 64kbit/s) that should be no
problem for modern CPUs.



-Andi



--
This is like TV. I don't like TV.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.054 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site