From owner-freebsd-net@FreeBSD.ORG Wed Apr 13 19:55:58 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 029131065673 for ; Wed, 13 Apr 2011 19:55:58 +0000 (UTC) (envelope-from peterjeremy@acm.org) Received: from mail36.syd.optusnet.com.au (mail36.syd.optusnet.com.au [211.29.133.76]) by mx1.freebsd.org (Postfix) with ESMTP id 889FF8FC13 for ; Wed, 13 Apr 2011 19:55:57 +0000 (UTC) Received: from server.vk2pj.dyndns.org (c220-239-116-103.belrs4.nsw.optusnet.com.au [220.239.116.103]) by mail36.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p3DJtsXt013967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 14 Apr 2011 05:55:55 +1000 X-Bogosity: Ham, spamicity=0.000000 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.4/8.14.4) with ESMTP id p3DJtsXA081900 for ; Thu, 14 Apr 2011 05:55:54 +1000 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.4/8.14.4/Submit) id p3DJtrMt081899 for freebsd-net@freebsd.org; Thu, 14 Apr 2011 05:55:53 +1000 (EST) (envelope-from peter) Date: Thu, 14 Apr 2011 05:55:53 +1000 From: Peter Jeremy To: freebsd-net@freebsd.org Message-ID: <20110413195553.GA6773@server.vk2pj.dyndns.org> References: <20110410211012.GA82480@server.vk2pj.dyndns.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PmA2V3Z32TCmWXqI" Content-Disposition: inline In-Reply-To: <20110410211012.GA82480@server.vk2pj.dyndns.org> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: Diskless booting issues X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Apr 2011 19:55:58 -0000 --PmA2V3Z32TCmWXqI Content-Type: multipart/mixed; boundary="ZGiS0Q5IWpPtfppv" Content-Disposition: inline --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I've managed to resolve one of the problems I raised. On 2011-Apr-11 07:10:12 +1000, Peter Jeremy wrote: >For various reasons, I occasionally boot my netbook as a diskless >client of my main server (this is a quick/easy way to test upgrades >without needing to install them). Since I got a query about this, this is "diskless" in the old Sun diskless workstation sense - the filesystem is mounted RW so the netbook behaves normally except that the filesystem is remote rather than the local SSD. This is different to the approach assumed by /etc/rc.initdiskless where the remote filesystem is RO with some magic directory trees that are copied to a local RW ramdisk. >First problem: If it loses network connectivity (ie, I unplug the >network cable) for more than a minute or so, it seems to lockup and >need a hard reboot, even if the network is restored. I haven't gotten anywhere with this. >Second problem: When running on the local SSD, I have lagg setup so >it seamlessly switches between wired and wifi (this is really nice). >Partially to resolve the above and partially to improve portability, >I'd like to do the same when running diskless but can't work out how >to make it work. > >The relevant bits of my native rc.conf look like: > ifconfig_re0=3D"up" > ifconfig_ath0=3D"ether XX:XX:XX:XX:XX:XX" > wlans_ath0=3D"wlan0" > ifconfig_wlan0=3D"WPA" > cloned_interfaces=3D"lagg0" > ifconfig_lagg0=3D"SYNCDHCP laggproto failover laggport re0 laggport wlan0" > >Gluing this in the diskless rc.conf gives me a hang during startup, as >does changing 'SYNCDHCP' to 'inet MYHOST' and adding 'up'. Turns out that > ifconfig lagg0 inet MYHOST laggproto failover laggport re0 laggport wlan= 0 up results in MYHOST existing on both re0 and lagg0 and this causes the network to completely stop - even if you later remove one of the IP addresses. You need to remove the IP address from re0 before adding it to lagg0. This presents a bit of a catch-22 since once I remove the IP address from re0, I no longer have access to a filesystem to run an ifconfig to add the IP adddress to lagg0. My solution was to use a temporary ramdisk to hold a statically-linked copy of ifconfig in a new rc.d script (see attached) to handle moving the IP address from re0 to lagg0 and then let the existing netif handle the wifi side with te following rc.conf entries (cf above): ifconfig_ath0=3D"ether XX:XX:XX:XX:XX:XX" wlans_ath0=3D"wlan0" ifconfig_wlan0=3D"WPA" ifconfig_lagg0=3D"laggport wlan0" --=20 Peter Jeremy --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=lagg #!/bin/sh # # Create lagg0 if necessary and flip current IP address from re0 to lagg0 # PROVIDE: lagg # REQUIRE: FILESYSTEMS # BEFORE: netif # KEYWORD: nojail . /etc/rc.subr . /etc/network.subr name="lagg" start_cmd="lagg_start" stop_cmd=":" cmdifn= : ${lagg_phys:=re0} : ${lagg_dev:=lagg0} : ${lagg_tmp:=/mnt} lagg_start() { # Ensure that the lagg device exists ifexists "$lagg_dev" || ifconfig "$lagg_dev" create # Create a ramdisk to temporarily hold a copy of ifconfig md_dev=$(/sbin/mdconfig -a -t swap -s 8m) mdmfs -S -s 8m -o async $md_dev "$lagg_tmp" # Copy /rescue (because it's statically linked) tar -cf - -C /rescue . | tar -xf - -C "$lagg_tmp" ### Actually flip the interface # Wanted IP address addr=$(/mnt/ifconfig "$lagg_phys" | grep 'inet ') # Delete address from existing interface /mnt/ifconfig "$lagg_phys" delete # Setup new interface /mnt/ifconfig "$lagg_dev" $addr laggport "$lagg_phys" up # Unwind ramdisk umount /mnt mdconfig -d -u ${md_dev#md} } load_rc_config $name run_rc_command "$@" --ZGiS0Q5IWpPtfppv-- --PmA2V3Z32TCmWXqI Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) iEYEARECAAYFAk2l/8kACgkQ/opHv/APuIcULwCfQNFMbVTbmddOhQj20YS72iI7 1R4AmwVzQz4azeA/XfMPfQC4VWK09BWH =Tt0e -----END PGP SIGNATURE----- --PmA2V3Z32TCmWXqI--