Accessing tcp socket information from within a module
Hi all,
I am trying to write a module in the 2.4.20 kernel, which will do pretty much a small subset of what netstat does from the user-space. All netstat does is read from /proc/net/tcp to get hold of info regarding TCP sockets in the system.
I want to be able to find out what are all the open tcp sockets in the system and the states they are in. In the TCP implementation in the kernel, this information lies in a set of hash tables. I tried to access one of these hash tables "tcp_hashinfo" from within my kernel moule. But this symbol is exported by netsyms.c in the kernel only if IPV6 or KHTTPD or is turned on, and since I have my kernel built without IPV6 or KHTTPD, I cannot access these hashtables.
Is there some way of accessing the information of all open tcp sockets in the system, other than having to turn one of IPV6 or KHTTPD on?
Thanks in advance for any help.
-Vishwas.
Quoted 2 lines · On Fri, 03 Oct 2003 17:02:07 -0700 Vishwas Raman <[email protected]>…
Is there some way of accessing the information of all open tcp sockets in the system, other than having to turn one of IPV6 or KHTTPD on?
You don't even need to write your kernel module, there is already a special netlink socket provided to userspace exactly for this purpose, to get info on all TCP sockets efficiently.
See net/ipv4/tcp_diag.c
Quoted 4 lines · David S. Miller
On Fri, 03 Oct 2003 17:02:07 -0700
Vishwas Raman <[email protected]> wrote:
Quoted 9 lines
Quoted 1 line
Is there some way of accessing the information of all open tcp sockets in the system, other than having to turn one of IPV6 or KHTTPD on?
You don't even need to write your kernel module, there is already a special netlink socket provided to userspace exactly for this purpose, to get info on all TCP sockets efficiently.
See
net/ipv4/tcp_diag.c
But what if I am interested in doing the same in kernel space and not user space? The module I am writing is going to sit between the tcp and ip layers of the networking stack. And I need to get info on all TCP sockets and create/modify certain data structures of my own in the module based on that information.
Quoted 3 lines · On Sat, 04 Oct 2003 16:07:00 -0700 Vishwas Raman <[email protected]>…
And I need to get info on all TCP
sockets and create/modify certain data structures of my own in the module based on that information.
Well, then, you're going to have to study and learn the entire TCP stack in order to learn how to do this and furthermore to be able to do this safely.
I'm a bit skeptical of what you actually want to use this for, so I'm going to choose not to help you with this until you give some more details of what you're exactly up to.
Onboard LAN Asus A7V8X-X (VT6102 [Rhine-II])
This motherboard has source included (but has an unfortunate advertising clause) at the website for the onboard nic, but I can't make it work in 2.4.22 - is this nic supported natively, or will it be? I didn't find an option for it in 2.4.22 or 2.6.0-test6. Is there any interest in a driver for this board? It's a VIA VT6102 [Rhine-II].
--
/"\ / For information and quotes, email us at
\ / ASCII RIBBON CAMPAIGN / [email protected] X AGAINST HTML MAIL / http://www.lrsehosting.com/ / \ AND POSTINGS / [email protected]
-------------------------------------------------------------------------
Re: Onboard LAN Asus A7V8X-X (VT6102 [Rhine-II])
Quoted 5 lines · William Scott Lockwood III
This motherboard has source included (but has an unfortunate advertising clause) at the website for the onboard nic, but I can't make it work in 2.4.22 - is this nic supported natively, or will it be? I didn't find an option for it in 2.4.22 or 2.6.0-test6. Is there any interest in a driver for this board? It's a VIA VT6102 [Rhine-II].
CONFIG_VIA_RHINE should do the trick, though with the same chip on a different board in 2.4.22, I had to boot with "acpi=off noapic" This is now fixed in 2.4.23 iirc.
Dave
Signature · 1 line
Dave Jones http://www.codemonkey.org.uk