Skip to contentSkip to conversation

Patch to pull NFS server address off root_server_path

PATCH In review Rusty Russell 2 participants 2 messages Mar 6, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Patch to pull NFS server address off root_server_path

This patch was submitted to the trivial patch daemon. Looks OK to me, Trond?

Thanks,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

------- Forwarded Message

Date: Wed, 6 Mar 2002 14:06:46 +1100
To: [email protected]
Subject: Patch to pull NFS server address off root_server_path
X-Mailer: VM 7.03 under Emacs 21.1.90.1
From: "Martin Schwenke" <[email protected]>

The following patch pulls an NFS server IP address off root_server_path (handed out via the DHCP root-path option), if it is present. For example, you can do this sort of thing in dhcpd.conf:

root-path = 192.168.1.33:/tftpboot/yip.zImage

The patch appears to be backwards compatible.

RFC2132 says this about the root-path option:

This option specifies the path-name that contains the client's root disk. The path is formatted as a character string consisting of characters from the NVT ASCII character set.

This is sufficiently vague to allow the path-name to include an IP-address. Also, I found some documentation for FreeBSD saying it does this too, so it must be right, because those FreeBSD guys are really smart... :-)

peace & happiness,
martin

fs/nfs/nfsroot.c +3 -3
diff -r -u linux.orig/fs/nfs/nfsroot.c linux/fs/nfs/nfsroot.c
@@ -167,7 +167,7 @@
  *  need to have root_server_addr set _before_ IPConfig gets called as it
  *  can override it.
  */
-static void __init root_nfs_parse_addr(char *name)
+void __init root_nfs_parse_addr(char *name, u32 *addr)
 {
 	int octets = 0;
 	char *cp, *cq;
@@ -187,7 +187,7 @@
 	if (octets == 4 && (*cp == ':' || *cp == '\0')) {
 		if (*cp == ':')
 			*cp++ = '\0';
-		root_server_addr = in_aton(name);
+		*addr = in_aton(name);
 		strcpy(name, cp);
 	}
 }
@@ -344,7 +344,7 @@
 			line[sizeof(nfs_root_name) - strlen(NFS_ROOT) - 1] = '\0';
 		sprintf(nfs_root_name, NFS_ROOT, line);
 	}
-	root_nfs_parse_addr(nfs_root_name);
+	root_nfs_parse_addr(nfs_root_name, &root_server_addr);
 	return 1;
 }
 
net/ipv4/ipconfig.c +10 -0
diff -r -u linux.orig/net/ipv4/ipconfig.c linux/net/ipv4/ipconfig.c
@@ -1197,6 +1197,16 @@
 		ic_dev = ic_first_dev->dev;
 	}
 
+#ifdef CONFIG_ROOT_NFS
+	{
+		extern void __init root_nfs_parse_addr(char *name, u32 *addr);
+		u32 addr = INADDR_NONE;
+		root_nfs_parse_addr(root_server_path, &addr);
+		if (root_server_addr == INADDR_NONE)
+			root_server_addr = addr;
+	}
+#endif
+
 	/*
 	 * Use defaults whereever applicable.
 	 */
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

" " == Rusty Russell <[email protected]> writes:

     > This patch was submitted to the trivial patch daemon.  Looks OK
     > to me, Trond?

     > --- linux.orig/net/ipv4/ipconfig.c Tue Feb 26 07:14:51 2002
     > +++ linux/net/ipv4/ipconfig.c Wed Mar 6 14:01:10 2002
     > @@ -1197,6 +1197,16 @@
     >  		ic_dev = ic_first_dev->dev;
     >  	}
 
     > +#ifdef CONFIG_ROOT_NFS
     > + {
     > + extern void __init root_nfs_parse_addr(char *name, u32
     >  		*addr);
     > + u32 addr = INADDR_NONE;
     > + root_nfs_parse_addr(root_server_path, &addr);
     > + if (root_server_addr == INADDR_NONE)
     > + root_server_addr = addr;
     > + }
     > +#endif +

Erm... Is this __init declaration here correct?

Wouldn't it really be better to move root_nfs_parse_addr() into the ipconfig code? Since, CONFIG_ROOT_NFS depends on CONFIG_IP_PNP being set, you could also get rid of your #ifdef above...

Cheers,
Trond