Skip site navigation (1)Skip section navigation (2)
Date:      28 Sep 2003 21:09:32 -0000
From:      Per Kristian Hove <Per.Hove@math.ntnu.no>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Per Kristian Hove <Per.Hove@math.ntnu.no>
Subject:   kern/57328: [patch] -current loader uses wrong IP address for kernel and NFSROOT
Message-ID:  <20030928210932.74023.qmail@torx.math.ntnu.no>
Resent-Message-ID: <200309282110.h8SLAC8D088300@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         57328
>Category:       kern
>Synopsis:       [patch] -current loader uses wrong IP address for kernel and NFSROOT
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 28 14:10:12 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Per Kristian Hove
>Release:        FreeBSD 5.1-CURRENT sparc64
>Organization:
>Environment:
System: FreeBSD 5.1-CURRENT sparc64


	
>Description:
When netbooting FreeBSD 5.1-CURRENT on sparc64, the loader tries to
download the kernel and mount the NFS root file system from the wrong
server address. This isn't noticeable unless you have separate DHCP,
TFTP and NFS servers, but if you do, the loader tries to load the
kernel and mount the root file system from the TFTP server.

The problem doesn't seem to be sparc64-specific, it probably affects
all non-PXE netbooting.
>How-To-Repeat:
Use a separate DHCP server (10.0.0.10), TFTP server (10.0.0.20) and
NFS server (10.0.0.30). Put the following in dhcpd.conf:
        host hostname.example.com {
                [...]
                next-server 10.0.0.20;
                filename "loader";
                option root-path "10.0.0.30:/export/install";
        }
Then netboot the sparc64 computer with "boot net:dhcp". The loader says:
   net_open: server addr: 10.0.0.20
   net_open: server path: /export/install
The first line should read
   net_open: server addr: 10.0.0.30
>Fix:
Apply the following patch.
Tested on: sparc64 buildworld (on i386 with TARGET_ARCH=sparc64).

--- dev_net.c.diff begins here ---
--- /sys/boot/common/dev_net.c.orig	Tue Aug 26 01:30:41 2003
+++ /sys/boot/common/dev_net.c	Sun Sep 28 22:41:47 2003
@@ -270,22 +270,21 @@
 	return (EIO);
     }
  exit:
-    printf("net_open: server addr: %s\n", inet_ntoa(rootip));
-
-    /*  
-     * If present, strip the server's address off of the rootpath
-     * before passing it along.  This allows us to be compatible with
-     * the kernel's diskless (BOOTP_NFSROOT) booting conventions
+    /*
+     * Now that the loader loads the kernel via NFS, we should
+     * honor the IP address given in the rootpath.
      */
-
-    for(i=0; i<FNAME_SIZE; i++)
-	    if(rootpath[i] == ':')
+    for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
+	    if (rootpath[i] == ':')
 		    break;
-    if(i && i != FNAME_SIZE) {
-	    i++;
+    if (i && i != FNAME_SIZE && rootpath[i] == ':') {
+	    rootpath[i++] = '\0';
+	    if (inet_addr(&rootpath[0]) != INADDR_NONE)
+		    rootip.s_addr = inet_addr(&rootpath[0]);
 	    bcopy(&rootpath[i], &temp[0], strlen(&rootpath[i])+1);
 	    bcopy(&temp[0], &rootpath[0], strlen(&rootpath[i])+1);	    
     }
+    printf("net_open: server addr: %s\n", inet_ntoa(rootip));
     printf("net_open: server path: %s\n", rootpath);	    
 
     d = socktodesc(sock);
@@ -294,6 +293,8 @@
     setenv("boot.netif.netmask", intoa(netmask), 1);
     setenv("boot.netif.gateway", inet_ntoa(gateip), 1);
     setenv("boot.netif.hwaddr", temp, 1);
+    setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
+    setenv("boot.nfsroot.path", rootpath, 1);
 
     return (0);
 }
--- dev_net.c.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030928210932.74023.qmail>