From owner-freebsd-stable@FreeBSD.ORG Tue Apr 27 03:02:49 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65EEE1065670 for ; Tue, 27 Apr 2010 03:02:49 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from qmta08.westchester.pa.mail.comcast.net (qmta08.westchester.pa.mail.comcast.net [76.96.62.80]) by mx1.freebsd.org (Postfix) with ESMTP id 1160D8FC16 for ; Tue, 27 Apr 2010 03:02:46 +0000 (UTC) Received: from omta21.westchester.pa.mail.comcast.net ([76.96.62.72]) by qmta08.westchester.pa.mail.comcast.net with comcast id AQKi1e0071ZXKqc58T2m16; Tue, 27 Apr 2010 03:02:46 +0000 Received: from koitsu.dyndns.org ([98.248.46.159]) by omta21.westchester.pa.mail.comcast.net with comcast id AT2l1e00M3S48mS3hT2mKH; Tue, 27 Apr 2010 03:02:46 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 6F6F49B425; Mon, 26 Apr 2010 20:02:44 -0700 (PDT) Date: Mon, 26 Apr 2010 20:02:44 -0700 From: Jeremy Chadwick To: Phil Message-ID: <20100427030244.GA70237@icarus.home.lan> References: <20100418213727.GA98129@icarus.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-stable@freebsd.org Subject: Re: rc(8) script -- waiting for the network to become usable X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2010 03:02:49 -0000 On Tue, Apr 27, 2010 at 09:48:41AM +1000, Phil wrote: > Jeremy, > A good proposal to improve start-up robustness. If I may suggest, > waitnetwork_ip should include a short list of alternate IP's in > the event of a local network outage, or DOS, etc. Something like: > waitnetwork_ip="IP1 IP2 IP3" > > Having multiple target IP's will improve the likelihood of timely > booting when silly/nasty things happen on the wider network. > > Good idea to have incorporated into the base system. Phil, I brought this point up in my post on -rc and -net, actually. I've since extended the script to support multiple IPs in $waitnetwork_ip (wasn't that hard). The logic is that if any of the IPs pass the ping test, then the network connection is considered usable. Attached is the modified script. I'll be updating the version on my server (HTTP) momentarily. -- | Jeremy Chadwick jdc@parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB | #!/bin/sh # # $FreeBSD: $ # # PROVIDE: waitnetwork # REQUIRE: NETWORKING # BEFORE: mountcritremote # KEYWORD: nojail # XXX - Once/if committed to base, it's better to have mountcritremote # XXX - REQUIRE waitnetwork, rather than use the above BEFORE line. . /etc/rc.subr name="waitnetwork" rc_var=`set_rcvar` start_cmd="waitnetwork_start" stop_cmd=":" # XXX - Once/if committed to base, the following defaults should # XXX - be placed into src/etc/defaults/rc.conf instead of here # XXX - Also be sure to keep waitnetwork_ip="" commented out! waitnetwork_enable="NO" # Wait for network availability before # continuing with NETWORKING rc scripts #waitnetwork_ip="" # IP address to ping waitnetwork_count="5" # ping count (see ping(8) -c flag) waitnetwork_timeout="60" # ping timeout (see ping(8) -t flag) waitnetwork_start() { local ip rc success success=0 if [ -z "${waitnetwork_ip}" ]; then warn "You must define one or more IP addresses in waitnetwork_ip" return fi for ip in ${waitnetwork_ip}; do echo "Waiting for ${ip} to respond to ICMP..." if [ -z "${waitnetwork_timeout}" ]; then /sbin/ping -c ${waitnetwork_count} ${ip} >/dev/null 2>&1 rc=$? else info "Using timeout of ${waitnetwork_timeout} seconds" /sbin/ping -t ${waitnetwork_timeout} -c ${waitnetwork_count} ${ip} >/dev/null 2>&1 rc=$? fi if [ $rc -eq 0 ]; then echo "Host reachable; network considered available." return else echo "No response from host." fi done echo "Exhausted IP list. Continuing with startup, but be aware you may" echo "not have a fully functional networking layer at this point." } load_rc_config $name run_rc_command "$1"