[Q] More on protocol modules!

Nicholas J. Leon (nicholas@binary9.net)
Tue, 16 Sep 1997 19:02:00 -0400 (EDT)


Ok,

This continues to concern me installing a protocol driver. After
scratching my head for a while, I decided to add some debugging code
to the kernel proper.

I modified net/ipv4/protocol.c with the following:

--- protocol.c.~1~ Tue Apr 8 11:47:47 1997
+++ protocol.c Tue Sep 16 18:35:27 1997
@@ -1,3 +1,5 @@
+#define NJL_DEBUG
+
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
@@ -135,8 +137,18 @@
struct inet_protocol *p;

hash = prot & (MAX_INET_PROTOS - 1);
+
+#ifdef NJL_DEBUG
+ printk(KERN_DEBUG "i_g_p: hash = %d\n",hash);
+#endif
+
+
for (p = inet_protos[hash] ; p != NULL; p=p->next)
{
+#ifdef NJL_DEBUG
+ printk(KERN_DEBUG "i_g_p: name = '%s', prot = %d\n",
+ p->name,p->protocol);
+#endif
if (p->protocol == prot)
return((struct inet_protocol *) p);
}
@@ -153,6 +165,12 @@
struct inet_protocol *p2;

hash = prot->protocol & (MAX_INET_PROTOS - 1);
+
+#ifdef NJL_DEBUG
+ printk(KERN_DEBUG "i_a_p: name = '%s', hash = %d, prot = %d\n",
+ prot->name,hash,prot->protocol);
+#endif
+
prot ->next = inet_protos[hash];
inet_protos[hash] = prot;
prot->copy = 0;

The first two debugs are in inet_get_protocol, the second in
inet_add_protocol.

When loading my module, sure enough, I get

Sep 16 18:41:15 neko kernel: i_a_p: name = 'vpn', hash = 11, prot = 43

However, when a packet with type 43 makes it to my box,
inet_get_protocol isn't being called. This really confuses me.

Isn't that its purpose? When an IP packet of a certain protocol gets
into the kernel, inet_get_protocol is called to find the inet_protocol
structure that's associate with it? But its not being called! :(

Could someone explain this to me? And another small question, how do
you debug (using gdb) a running module?

----

Since I'm not getting any responses from my multiple questions on this
topic, I have to assume that I'm asking something /really/ dumb,
... aren't I?

Ah well, that's quite OK. I'm struggling my way through this
myself. At least I've gotten past the part where I lock up my kernel
:) [ and then have to reboot only to find that my changes to my code
weren't flushed before the kernel died :) ]. Sometimes writing aids
you in focusing. Plus, I'm sure there are lurkers about who _might_
actually get something from this.

So if you know anything about this, a one-liner even, I'd be much
appreciated.

------------------------------------------------------------------------------
Nicholas J. Leon <nicholas@binary9.net>
"Elegance through Simplicity" http://mrnick.binary9.net/
PGP:finger nicholas@neko.binary9.net Shinanyaku:[Chronx/War2/XvT]
------------------------------------------------------------------------------
He who laughs last thinks slowest

--
Please ignore the following addresses, they are intended to determine and
catch bulk emailers that scan newsgroups and mailing lists.

>> svpn_belegost.mit.edu@catcher.binary9.net >> linux-kernel_vger.rutgers.edu@catcher.binary9.net