From nobody@FreeBSD.org  Mon Mar 10 15:26:46 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E515A1065671
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 10 Mar 2008 15:26:46 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E55158FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 10 Mar 2008 15:26:46 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m2AFNYft066712
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 10 Mar 2008 15:23:34 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m2AFNYQh066711;
	Mon, 10 Mar 2008 15:23:34 GMT
	(envelope-from nobody)
Message-Id: <200803101523.m2AFNYQh066711@www.freebsd.org>
Date: Mon, 10 Mar 2008 15:23:34 GMT
From: Robert Schulze <rs@bytecamp.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ethernet iface should be brought up when booting from a mfs_root over nfs
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         121566
>Category:       kern
>Synopsis:       [nfs] [request] [patch] ethernet iface should be brought up when booting from a mfs_root over nfs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 10 15:30:00 UTC 2008
>Closed-Date:    
>Last-Modified:  Tue Mar 25 11:00:05 UTC 2008
>Originator:     Robert Schulze
>Release:        6.2/7.0
>Organization:
bytecamp
>Environment:
FreeBSD freebsd.localdomain 6.2-RELEASE-p7 FreeBSD 6.2-RELEASE-p7 #0: Thu Aug 16 16:45:18 CEST 2007     root@freebsd.localdomain:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
When booting a diskless client through a NFS-root, the code in
/usr/src/sys/nfsclient/nfs_vfsops.c fires up an interface with the data
from the previous DHCP-request, so it can mount the nfs-share.

When booting the same diskless client through a NFS-shared root-RAM-disk,
these settings do not become applied. The functionality of
/etc/rc.initdiskless is then obviously broken, because it can't get the
right templates to process and can't mount anything (see diskless_remount)
from a NFS-server.


>How-To-Repeat:

>Fix:
Maybe the code which initializes the interface with the help of the
DHCP-Parameters should be issued by vfs_mountroot_try() before mounting
anything else.

Or one could copy the code to /dev/md/md.c and bring out a kernel-option
to en/disable this code, when using a MD_ROOT.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: linimon 
State-Changed-When: Mon Mar 10 23:25:39 UTC 2008 
State-Changed-Why:  
Mark suspended awaiting patches. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121566 

From: Robert Schulze <rs@bytecamp.net>
To: bug-followup@FreeBSD.org, rs@bytecamp.net
Cc:  
Subject: Re: kern/121566: [nfs] [request] ethernet iface should be brought
 up when booting from a mfs_root over nfs
Date: Wed, 19 Mar 2008 11:30:39 +0100

 This is a multi-part message in MIME format.
 --------------080908080007060209020005
 Content-Type: text/plain; charset=ISO-8859-15; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hi,
 
 I found a workaround to simulate the behaviour of 
 /sys/nfsclient/nfs_vfsops.c in rc.initdiskless.
 
 The patch in "diff -Naur" format is attached.
 
 with kind regards,
 Robert Schulze
 
 --------------080908080007060209020005
 Content-Type: text/x-patch;
  name="rc.initdiskless.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="rc.initdiskless.patch"
 
 --- rc.initdiskless.dflt	Thu Mar 13 10:08:51 2008
 +++ rc.initdiskless	Wed Mar 19 11:21:32 2008
 @@ -163,6 +163,30 @@
      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()
 +{
 +echo "trying to up an interface with options from kenv..."
 +
 +IF=`kenv | grep 'boot.netif.name' | awk 'BEGIN {FS="="} {print $2}' | sed 's/"//g'`
 +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'`
 +
 +if [ ! "$1" = "$IF" ]; then
 +	return 0
 +fi
 +
 +echo "kenv: IF=$IF GW=$GW IP=$IP MASK=$NM"
 +ifconfig $IF $IP netmask $NM up
 +route add default $GW
 +
 +}
 +
  # DEBUGGING
  #
  # set -v
 @@ -176,6 +200,12 @@
  if [ ${dlv:=0} -ne 0 ] ; then
  	iflist=`ifconfig -l`
  	for i in ${iflist} ; do
 +
 +	    ifconfig ${i} | grep -q inet
 +	    if [ $? -ne "0" ] ; then
 +		ifconfig_kenv ${i}
 +	    fi
 +
  	    set -- `ifconfig ${i}`
  	    while [ $# -ge 1 ] ; do
  		if [ "${bootp_ifc}" = "" -a "$1" = "inet" ] ; then
 
 --------------080908080007060209020005--
State-Changed-From-To: suspended->open 
State-Changed-By: linimon 
State-Changed-When: Wed Mar 19 20:59:06 UTC 2008 
State-Changed-Why:  
Patch received. 


Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Mar 19 20:59:06 UTC 2008 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=121566 

From: Robert Schulze <rs@bytecamp.net>
To: bug-followup@FreeBSD.org, rs@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--
>Unformatted:
