Accessing tcp socket information from within a module

Vishwas Raman
2003-10-04T00:06:40Z

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.