questions regarding sending/recving udp packets in kernel

questions regarding sending/recving udp packets in kernel

Post by devnetf » Sun, 06 Oct 2002 09:40:04



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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. questions regarding sending/receiving udp packets in 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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. CDR Backups.

3. query about sending udp packets in kernel mode

4. Tivoli Address Required

5. Sending UDP Packets from a kernel thread/module

6. NT / Unix Networking

7. send and recv function for UDP

8. Netscape bus error

9. Core Dump error!!!! UDP send/recv..ANS?

10. Seeing large amounts of data on udp recv-q, only sending 1 byte of data

11. Send/Recv of ethernet packets useing raw sockets

12. SPAK(Send PAcKets)- tools to send arbitrary packets

13. Sending UDP packets at a specified rate