kern/121566: [nfs] [request] [patch] ethernet iface should be
brought up when booting from a mfs_root over nfs
Robert Schulze
rs at bytecamp.net
Tue Mar 25 04:00:07 PDT 2008
The following reply was made to PR kern/121566; it has been noted by GNATS.
From: Robert Schulze <rs at bytecamp.net>
To: bug-followup at FreeBSD.org, rs at bytecamp.net
Cc:
Subject: Re: kern/121566: [nfs] [request] [patch] ethernet iface should be
brought up when booting from a mfs_root over nfs
Date: Tue, 25 Mar 2008 11:54:38 +0100
This is a multi-part message in MIME format.
--------------000406030500060509050702
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
First sorry for the first "proof-of-concept"-like patch.
I now appended one that does some more checking and sets nfsroot
according to variables from kenv to accomplish relative paths in
diskless_remount.
with kind regards,
Robert Schulze
--------------000406030500060509050702
Content-Type: text/x-patch;
name="rc.initdiskless.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="rc.initdiskless.patch"
--- rc.initdiskless.dflt Tue Mar 25 11:49:22 2008
+++ rc.initdiskless Tue Mar 25 11:25:09 2008
@@ -163,6 +163,47 @@
fi
}
+# Fire up an interface to do nfs-mounts if this machine
+# was booted from a md_root
+# Use kenv to get the configuration vom dhcp like
+# /sys/nfsclient/nfs_vfsops.c does
+
+ifconfig_kenv()
+{
+IF=`kenv | grep 'boot.netif.name' | awk 'BEGIN {FS="="} {print $2}' | sed 's/"//g'`
+
+# check if ifname is nonempty
+#
+if [ "x$IF" = "x" ]; then
+ return 0
+fi
+
+# check if interface is already up
+#
+ifcfg=`ifconfig ${IF} | grep -q inet`
+if [ $? -eq "0" ]; then
+ return 0
+fi
+
+GW=`kenv | grep 'boot.netif.gateway' | awk 'BEGIN {FS="="} {print $2}' | sed 's/"//g'`
+IP=`kenv | grep 'boot.netif.ip' | awk 'BEGIN {FS="="} {print $2}' | sed 's/"//g'`
+NM=`kenv | grep 'boot.netif.netmask' | awk 'BEGIN {FS="="} {print $2}' | sed 's/"//g'`
+
+echo "configuring $IF from kenv: $IP netmask $NM gw $GW"
+ifconfig $IF $IP netmask $NM up
+route add default $GW
+
+# setting nfsroot to accomplish relative paths
+# in diskless_remount
+
+nfsroot=`kenv | grep 'boot.nfsroot.path' | awk 'BEGIN {FS="="} {print $2}' | sed 's/"//g'`
+nfsserver=`kenv | grep 'boot.nfsroot.server' | awk 'BEGIN {FS="="} {print $2}' | sed 's/"//g'`
+
+nfsroot="$nfsserver:$nfsroot"
+
+
+}
+
# DEBUGGING
#
# set -v
@@ -175,6 +216,8 @@
class=""
if [ ${dlv:=0} -ne 0 ] ; then
iflist=`ifconfig -l`
+ ifconfig_kenv
+
for i in ${iflist} ; do
set -- `ifconfig ${i}`
while [ $# -ge 1 ] ; do
--------------000406030500060509050702--
More information about the freebsd-rc
mailing list