From: "Martin Schwenke" <martin@meltin.net>
To: trond.myklebust@fys.uio.no
Cc: linux-kernel@vger.kernel.org, Linus Torvalds <torvalds@transmeta.com>
Subject: [PATCH] Pull NFS server address off root_server_path
Date: Thu, 12 Sep 2002 12:08:17 +1000 [thread overview]
Message-ID: <200209120208.MAA00777@thucydides.inspired.net.au> (raw)
The following patch pulls an NFS server IP address off
root_server_path, if it is present. This is useful, for example, when
root_server_path is obtained via the DHCP root-path option. You can
do this sort of thing in dhcpd.conf:
root-path = 192.168.1.33:/tftpboot/yip.zImage
This lets you mount your root filesystem off a different machine than
you booted from, without needing to use kernel command-line
parameters.
The change is backwards compatible; if the IP address is not present
then the existing behaviour takes place. It is very well tested and
has been accepted into 2.4 and 2.5-dj. FreeBSD allows root-path to
include an IP address in the above format and the description of
root-path in RFC2132 (DHCP Options ...) is general enough to allow an
IP address to be present.
Regards,
Martin
diff -r -u linux-2.5.34/fs/nfs/nfsroot.c linux-2.5.34.work/fs/nfs/nfsroot.c
--- linux-2.5.34/fs/nfs/nfsroot.c 2002-06-17 13:28:46.000000000 +1000
+++ linux-2.5.34.work/fs/nfs/nfsroot.c 2002-09-12 11:34:08.000000000 +1000
@@ -164,37 +164,6 @@
/*
- * Extract IP address from the parameter string if needed. Note that we
- * 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)
-{
- int octets = 0;
- char *cp, *cq;
-
- cp = cq = name;
- while (octets < 4) {
- while (*cp >= '0' && *cp <= '9')
- cp++;
- if (cp == cq || cp - cq > 3)
- break;
- if (*cp == '.' || octets == 3)
- octets++;
- if (octets < 4)
- cp++;
- cq = cp;
- }
- if (octets == 4 && (*cp == ':' || *cp == '\0')) {
- if (*cp == ':')
- *cp++ = '\0';
- root_server_addr = in_aton(name);
- strcpy(name, cp);
- }
-}
-
-
-/*
* Parse option string.
*/
static void __init root_nfs_parse(char *name, char *buf)
@@ -346,7 +315,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_server_addr = ipconfig_parse_addr(nfs_root_name);
return 1;
}
diff -r -u linux-2.5.34/include/net/ipconfig.h linux-2.5.34.work/include/net/ipconfig.h
--- linux-2.5.34/include/net/ipconfig.h 2001-05-02 13:59:24.000000000 +1000
+++ linux-2.5.34.work/include/net/ipconfig.h 2002-09-12 11:34:08.000000000 +1000
@@ -6,6 +6,9 @@
* Automatic IP Layer Configuration
*/
+#ifndef _NET_IPCONFIG_H
+#define _NET_IPCONFIG_H
+
/* The following are initdata: */
extern int ic_enable; /* Enable or disable the whole shebang */
@@ -36,3 +39,10 @@
#define IC_BOOTP 0x01 /* BOOTP (or DHCP, see below) */
#define IC_RARP 0x02 /* RARP */
#define IC_USE_DHCP 0x100 /* If on, use DHCP instead of BOOTP */
+
+#ifdef __KERNEL__
+/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
+extern u32 ipconfig_parse_addr(char *name); /*__init*/
+#endif /* __KERNEL */
+
+#endif
diff -r -u linux-2.5.34/net/ipv4/ipconfig.c linux-2.5.34.work/net/ipv4/ipconfig.c
--- linux-2.5.34/net/ipv4/ipconfig.c 2002-08-28 06:12:28.000000000 +1000
+++ linux-2.5.34.work/net/ipv4/ipconfig.c 2002-09-12 11:34:08.000000000 +1000
@@ -1128,12 +1128,47 @@
#endif /* CONFIG_PROC_FS */
/*
+ * Extract IP address from the parameter string if needed. Note that we
+ * need to have root_server_addr set _before_ IPConfig gets called as it
+ * can override it.
+ */
+u32 __init ipconfig_parse_addr(char *name)
+{
+ u32 addr;
+ int octets = 0;
+ char *cp, *cq;
+
+ cp = cq = name;
+ while (octets < 4) {
+ while (*cp >= '0' && *cp <= '9')
+ cp++;
+ if (cp == cq || cp - cq > 3)
+ break;
+ if (*cp == '.' || octets == 3)
+ octets++;
+ if (octets < 4)
+ cp++;
+ cq = cp;
+ }
+ if (octets == 4 && (*cp == ':' || *cp == '\0')) {
+ if (*cp == ':')
+ *cp++ = '\0';
+ addr = in_aton(name);
+ strcpy(name, cp);
+ } else
+ addr = INADDR_NONE;
+
+ return addr;
+}
+
+/*
* IP Autoconfig dispatcher.
*/
static int __init ip_auto_config(void)
{
unsigned long jiff;
+ u32 addr;
#ifdef CONFIG_PROC_FS
proc_net_create("pnp", 0, pnp_get_info);
@@ -1222,6 +1257,10 @@
ic_dev = ic_first_dev->dev;
}
+ addr = ipconfig_parse_addr(root_server_path);
+ if (root_server_addr == INADDR_NONE)
+ root_server_addr = addr;
+
/*
* Use defaults whereever applicable.
*/
next reply other threads:[~2002-09-12 2:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-12 2:08 Martin Schwenke [this message]
2002-09-12 8:09 ` Alan Cox
2002-09-13 0:28 ` Martin Schwenke
2002-09-13 1:31 ` David Gibson
2002-09-16 8:32 ` Rob Landley
2002-09-13 13:14 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200209120208.MAA00777@thucydides.inspired.net.au \
--to=martin@meltin.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®