Re: (newbie) Questions on kernel thread and socket interface

From: Tigran Aivazian (tigran@sco.COM)
Date: Thu Feb 10 2000 - 05:52:12 EST


Hi Athanasios

You said that you want to create a network service in a kernel thread and
use sys_bind/sys_socket etc. to do that. These functions are the
implementations of the corresponding system calls, which are passed
parameters from userspace, i.e. user virtual addresses. So, what happens,
for example in sys_bind() is that it uses move_addr_to_kernel() to copy to
the kernel address space and then calls the SOP->bind() method.

Therefore, although you could use set_fs(KERNEL_DS)/set_fs(old_fs) trick
to solve this "problem" a proper way of doing is this is the way it is
done by khttpd. Have a look at the

/usr/src/linux/net/khttpd/sockets.c:StartListening() function - it invokes
socket_create() to create the socket and SOP->bind() to bind it to the
port. Since your thread is a kernel thread (assuming you did careful
analysis and decided that you *have* to implement it in the kernel) it
makes more sense to call kernel's internal functions than to go through
the system calls entry points.

Hope this helps,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.ocston.org/~tigran

-
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/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:17 EST