linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND-2: Pl. Help] questions regarding sending/receiving udp packets in kernel
@ 2002-10-06 10:30 devnetfs
  0 siblings, 0 replies; only message in thread
From: devnetfs @ 2002-10-06 10:30 UTC (permalink / raw)
  To: linux-kernel

Resending it again to the Gurus. Can somebody *please* help me with
these networking+kernel issues?

thanks once again,
Abhi.

Hello,

I am trying to write a kernel module, to send and receive udp packets. 
I have the following questions/problems:

[1] 
I wish to receive packets asynchronously (thru a callback), rather 
than polling [i.e calling udp_recvmsg() periodically to check for
packtets]. 

To get this done, presently after creating a socket (sock_create), I 
replace sk->data_ready with my own function, which when called (by the
kernel) wakes up a kernel thread that does skb_recv_datagram() to get a
udp sk_buff.

Is this the correct approach? or is there a better way to register a
callback with the core-networking subsystem, which will get called and
deliver the pkt, when a udp pkt arrives on an ip/port?


[2]
The memory allocted for the sk_buff (which i get thru
skb_recv_datagram() is charged to the socket (i created). But I wish to
use this sk_buff in my module (for processing etc.) so i dont call
kfree_skb for a long time (hence the rmem_alloc does not get
decremented). I tried to unlink the sk_buff from the socket list by
calling skb_unlink() but that does NOT decrease 'rmem_alloc'.

How do I cleanly (and truly) unlink a sk_buff from a socket list and
decrease equivalent memory charged to this socket? I would be calling
kfree_skb() later though which will eventually decrease rmem_alloc, but
I wish to do it as part of skb_unlink(). Please advice.


[3]
My kernel module sends/recvs UDP pkts process and store these packets
internally sk_buffs only. But udp_sendmsg() requires an iovec.
I can construct an iovec from an sk_buff and give it to udp_sendmsg()
but that will involve an additional COPYING from one kernel memory 
space (sk_buff data buffer) to another new buffer (for iovec). I want 
to avoid this xtra copying.

Am I missing something? 
And if above approach does involve extra copying is there a way to
transmit a udp packet if one has the data in form of sk_buff (assuming
there is head space for ether+ip+udp header)?


Thanks in advance,

Regards,
Abhi.

I am not subscribed to this list. Please Cc: me the replies. -- thanks.



__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-06 10:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-06 10:30 [RESEND-2: Pl. Help] questions regarding sending/receiving udp packets in kernel devnetfs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).