Hi!

This is my first attempt to track a bug in the kernel. I'm sorry if I'm doing
something bad.

While trying to remote boot an I386 with 2.1.125 I wondered why the supplied
default route wasn't set. net/ipv4/ipconfig.c bailed out with -22 (EINVAL)
when it tried to set the *guessed* netmask. 

It seems IN_CLASS[ABC] and IN_CLASS[ABC]_NET work with host byteorder, while
ic_{myaddr,servaddr,netmask,gateway} seem to be used as if they are network
byte order. Therefore ipconfig.c decided my 192.168.2.22 is on a class A net
and set the netmask according to that - in host byteorder!

Attached patch works for me. Output with IPCONFIG_DEBUG looks much better
this way :-)

I'm not sure I changed the right thing. Maybe the other involved parts are
broken and this is the correct one. At least you should be able to guess
what I mean.


Rainer

-- 
KeyID=58341901 fingerprint=A5 57 04 B3 69 88 A1 FB  78 1D B5 64 E0 BF 72 EB
--- -   Tue Oct 20 19:47:34 1998
+++ net/ipv4/ipconfig.c Tue Oct 20 19:46:52 1998
@@ -260,12 +260,12 @@
                root_server_addr = ic_servaddr;
 
        if (ic_netmask == INADDR_NONE) {
-               if (IN_CLASSA(ic_myaddr))
-                       ic_netmask = IN_CLASSA_NET;
-               else if (IN_CLASSB(ic_myaddr))
-                       ic_netmask = IN_CLASSB_NET;
-               else if (IN_CLASSC(ic_myaddr))
-                       ic_netmask = IN_CLASSC_NET;
+               if (IN_CLASSA(ntohl(ic_myaddr)))
+                       ic_netmask = htonl(IN_CLASSA_NET);
+               else if (IN_CLASSB(ntohl(ic_myaddr)))
+                       ic_netmask = htonl(IN_CLASSB_NET);
+               else if (IN_CLASSC(ntohl(ic_myaddr)))
+                       ic_netmask = htonl(IN_CLASSC_NET);
                else {
                        printk(KERN_ERR "IP-Config: Unable to guess netmask for 
address %08x\n", ic_myaddr);
                        return -1;

Reply via email to