Hi,

I am trying to implement an KLM, which accesses Network within the
Kernel. In this way, the KLM hides transport mechanism used from user
space software.

Within Kernel, the BSD socket interface layer seats on top of INET
socket interface layer, and INET socket interface layer seats on top
of TCP/IP layer. I tried to access the Network from BSD socket
interface layer. The reason is it is close to user space. The obvious
entry points seem to be where Kernel handles various system calls for
user space socket operations, for example, sys_socket, sys_bind,
sys_sendto, sys_recvfrom, and sys_setsocketopt.

For example, when user space applications calls a system call,
"socket", to create a socket, inside the Kernel, a corresponding
procedure, "sys_socket", is called. However my KLM can not directly
use "sys_socket" because it does more than I want. It creates a file
descriptor and a socket, associates the socket with the file
descriptor, then returns the file descriptor to user space. In Kernel
space, we do not need file descriptor, so it is necessary to implement
our own version of "sys_socket", for example, my_sys_socket. It trims
unwanted stuff, and makes necessary modifications to sys_socket to
suit my needs. Similar to sys_socket, I implemented my versions of
sys_bind, sys_sendto, sys_recvfrom, and sys_setsocketopt.

An experimental KLM was created which uses my versions of those
functions. But the experimental software does not work. No packets
were received by a server program in user space.

I am wondering if this is the right way to access Network in Kernel.
Could some experts give me a hint? Second, I do not know how to debug
this to make it work. Are there any utilities for me to use for this
purpose?

Thanks in advance!
Gary