head	1.12;
access;
symbols
	RELENG_8_4:1.12.0.2
	RELENG_9_1_0_RELEASE:1.11.2.1.4.2
	RELENG_9_1:1.11.2.1.0.4
	RELENG_9_1_BP:1.11.2.1
	RELENG_8_3_0_RELEASE:1.6.2.2.6.1
	RELENG_8_3:1.6.2.2.0.6
	RELENG_8_3_BP:1.6.2.2
	RELENG_9_0_0_RELEASE:1.11.2.1.2.1
	RELENG_9_0:1.11.2.1.0.2
	RELENG_9_0_BP:1.11.2.1
	RELENG_9:1.11.0.2
	RELENG_9_BP:1.11
	RELENG_8_2_0_RELEASE:1.6.2.2.4.1
	RELENG_8_2:1.6.2.2.0.4
	RELENG_8_2_BP:1.6.2.2
	RELENG_8_1_0_RELEASE:1.6.2.2.2.1
	RELENG_8_1:1.6.2.2.0.2
	RELENG_8_1_BP:1.6.2.2
	RELENG_8_0_0_RELEASE:1.6.2.1.2.1
	RELENG_8_0:1.6.2.1.0.2
	RELENG_8_0_BP:1.6.2.1
	RELENG_8:1.6.0.2
	RELENG_8_BP:1.6;
locks; strict;
comment	@# @;


1.12
date	2012.11.17.01.49.04;	author svnexp;	state Exp;
branches
	1.12.2.1;
next	1.11;

1.11
date	2010.09.29.13.08.23;	author emaste;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2010.05.14.04.53.57;	author dougb;	state Exp;
branches;
next	1.9;

1.9
date	2009.10.02.02.24.25;	author hrs;	state Exp;
branches;
next	1.8;

1.8
date	2009.09.26.19.00.20;	author hrs;	state Exp;
branches;
next	1.7;

1.7
date	2009.09.12.22.13.41;	author hrs;	state Exp;
branches;
next	1.6;

1.6
date	2009.02.17.11.55.50;	author mtm;	state Exp;
branches
	1.6.2.1;
next	1.5;

1.5
date	2009.02.11.09.18.09;	author mtm;	state Exp;
branches;
next	1.4;

1.4
date	2009.02.02.15.33.22;	author mtm;	state Exp;
branches;
next	1.3;

1.3
date	2009.01.30.03.41.45;	author imp;	state Exp;
branches;
next	1.2;

1.2
date	2008.12.17.17.35.26;	author svn;	state Exp;
branches;
next	1.1;

1.1
date	2008.06.05.17.26.47;	author brooks;	state Exp;
branches;
next	;

1.12.2.1
date	2012.11.17.01.49.04;	author svnexp;	state dead;
branches;
next	1.12.2.2;

1.12.2.2
date	2013.03.28.13.02.43;	author svnexp;	state Exp;
branches;
next	;

1.11.2.1
date	2011.09.23.00.51.37;	author kensmith;	state Exp;
branches
	1.11.2.1.2.1
	1.11.2.1.4.1;
next	1.11.2.2;

1.11.2.2
date	2012.11.17.11.36.11;	author svnexp;	state Exp;
branches;
next	;

1.11.2.1.2.1
date	2011.11.11.04.20.22;	author kensmith;	state Exp;
branches;
next	1.11.2.1.2.2;

1.11.2.1.2.2
date	2012.11.17.08.36.11;	author svnexp;	state Exp;
branches;
next	;

1.11.2.1.4.1
date	2012.08.05.23.54.33;	author kensmith;	state Exp;
branches;
next	1.11.2.1.4.2;

1.11.2.1.4.2
date	2012.11.17.08.47.01;	author svnexp;	state Exp;
branches;
next	;

1.6.2.1
date	2009.08.03.08.13.06;	author kensmith;	state Exp;
branches
	1.6.2.1.2.1;
next	1.6.2.2;

1.6.2.2
date	2010.05.14.19.28.16;	author dougb;	state Exp;
branches
	1.6.2.2.2.1
	1.6.2.2.4.1
	1.6.2.2.6.1;
next	1.6.2.3;

1.6.2.3
date	2012.11.17.10.35.56;	author svnexp;	state Exp;
branches;
next	;

1.6.2.1.2.1
date	2009.10.25.01.10.29;	author kensmith;	state Exp;
branches;
next	;

1.6.2.2.2.1
date	2010.06.14.02.09.06;	author kensmith;	state Exp;
branches;
next	;

1.6.2.2.4.1
date	2010.12.21.17.09.25;	author kensmith;	state Exp;
branches;
next	;

1.6.2.2.6.1
date	2012.03.03.06.15.13;	author kensmith;	state Exp;
branches;
next	1.6.2.2.6.2;

1.6.2.2.6.2
date	2012.11.17.08.24.38;	author svnexp;	state Exp;
branches;
next	;


desc
@@


1.12
log
@Switching exporter and resync
@
text
@#!/bin/sh
#
# Wait for the default route to be up if DHCP is in use
#
# $FreeBSD: head/etc/rc.d/defaultroute 213270 2010-09-29 13:08:23Z emaste $
#

# PROVIDE: defaultroute
# REQUIRE: devd faith netif stf
# KEYWORD: nojail

. /etc/rc.subr
. /etc/network.subr

name="defaultroute"
start_cmd="defaultroute_start"
stop_cmd=":"

# Does any interface have a carrier?
defaultroute_carrier()
{
	local carrier nocarrier

	carrier=1
	for _if in ${dhcp_interfaces}; do
		output=`/sbin/ifconfig ${_if}`
		nocarrier=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'`
		[ -z "${nocarrier}" ] && carrier=0
	done
	return ${carrier}
}

defaultroute_start()
{
	local nl waited

	afexists inet || return 0

	# Return without waiting if we don't have dhcp interfaces or
	# if none of the dhcp interfaces is plugged in.
	dhcp_interfaces=`list_net_interfaces dhcp`
	[ -z "${dhcp_interfaces}" ] && return

	# Wait for a default route
	waited=0
	while [ ${waited} -lt ${defaultroute_delay} ]; do
		defif=`get_default_if -inet`
		if [ -n "${defif}" ]; then
			if [ ${waited} -ne 0 ]; then
				echo -n "($defif)"
				nl=1
			fi
			break
		fi
		if [ ${waited} -eq 0 ]; then
			echo -n "Waiting ${defaultroute_delay}s for the default route interface: "
		else
			echo -n .
		fi
		if [ ${waited} -eq ${defaultroute_carrier_delay} ] && ! defaultroute_carrier; then
			echo -n "(no carrier)"
			break
		fi
		nl=1
		sleep 1
		waited=$(($waited + 1))
	done

	[ -n "$nl" ] && echo
}

load_rc_config $name
run_rc_command "$1"
@


1.12.2.1
log
@file defaultroute was added on branch RELENG_8_4 on 2013-03-28 13:02:43 +0000
@
text
@d1 73
@


1.12.2.2
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/248810
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a0 60
#!/bin/sh
#
# Wait for the default route to be up
#
# $FreeBSD: releng/8.4/etc/rc.d/defaultroute 208094 2010-05-14 19:28:16Z dougb $
#

# PROVIDE: defaultroute
# REQUIRE: devd netif network_ipv6
# KEYWORD: nojail

. /etc/rc.subr
. /etc/network.subr

name="defaultroute"
start_cmd="defaultroute_start"
stop_cmd=":"

defaultroute_start()
{
	local output carrier nocarrier

	# Return without waiting if we don't have dhcp interfaces or
	# if none of the dhcp interfaces is plugged in.
	dhcp_interfaces=`list_net_interfaces dhcp`
	[ -z "${dhcp_interfaces}" ] && return
	carrier=false
	for _if in ${dhcp_interfaces}; do
		output=`/sbin/ifconfig ${_if}`
		nocarrier=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'`
		[ -z "${nocarrier}" ] && carrier=true
	done
	if ! ${carrier}; then
		return
	fi

	# Wait for a default route
	delay=${defaultroute_delay}
	while [ ${delay} -gt 0 ]; do
		defif=`get_default_if -inet`
		if [ -n "${defif}" ]; then
			if [ ${delay} -ne ${defaultroute_delay} ]; then
				echo -n "($defif)"
			fi
			break
		fi
		if [ ${delay} -eq ${defaultroute_delay} ]; then
			echo -n "Waiting ${delay}s for the default route interface: "
		else
			echo -n .
		fi
		sleep 1
		delay=`expr $delay - 1`
	done

	echo
}

load_rc_config $name
run_rc_command "$1"
@


1.11
log
@SVN rev 213270 on 2010-09-29 13:08:23Z by emaste

/etc/rc.d/defaultroute currently bails immediately if all interfaces
set to use DHCP have no carrier.  This can cause grief as it may take
some time for link to be established, and defaultroute may terminate
before this happens.

Introduce a defaultroute_carrier_delay variable and then wait that long
in defaultroute before bailing if no interfaces have carrier.  With the
default settings defaultroute will wait for five seconds for this, and
the original 30 second wait for a default route to appear is unchanged.
Note that there is in discussion an alternative approach to the broader
problem of waiting for DHCP-configured routes.  However, this change
addresses a real problem in the current defaultroute script.

Discussed on:	freebsd-rc@@
@
text
@d5 1
a5 1
# $FreeBSD$
@


1.11.2.1
log
@SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.11.2.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242902
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242902 | dteske | 2012-11-11 23:29:45 +0000 (Sun, 11 Nov 2012) | 10 lines
## SVN ##
## SVN ## Fix a regression introduced by SVN r211417 that saw the breakage of a feature
## SVN ## documented in usr.sbin/sysinstall/help/shortcuts.hlp (reproduced below):
## SVN ##
## SVN ## If /usr/sbin/sysinstall is linked to another filename, say
## SVN ## `/usr/local/bin/configPackages', then the basename will be used
## SVN ## as an implicit command name.
## SVN ##
## SVN ## Reviewed by:	adrian (co-mentor)
## SVN ## Approved by:	adrian (co-mentor)
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d5 1
a5 1
# $FreeBSD: stable/9/etc/rc.d/defaultroute 213270 2010-09-29 13:08:23Z emaste $
@


1.11.2.1.4.1
log
@SVN rev 239080 on 2012-08-05 23:54:33Z by kensmith

Copy stable/9 to releng/9.1 as part of the 9.1-RELEASE release process.

Approved by:	re (implicit)
@
text
@@


1.11.2.1.4.2
log
@Switch importer
@
text
@d5 1
a5 1
# $FreeBSD: releng/9.1/etc/rc.d/defaultroute 213270 2010-09-29 13:08:23Z emaste $
@


1.11.2.1.2.1
log
@SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)
@
text
@@


1.11.2.1.2.2
log
@Switch importer
@
text
@d5 1
a5 1
# $FreeBSD: releng/9.0/etc/rc.d/defaultroute 213270 2010-09-29 13:08:23Z emaste $
@


1.10
log
@SVN rev 208060 on 2010-05-14 04:53:57Z by dougb

Remove trailing white space. No functional changes.
@
text
@d3 1
a3 1
# Wait for the default route to be up
d19 14
d35 1
a35 1
	local output carrier nocarrier nl
a42 9
	carrier=false
	for _if in ${dhcp_interfaces}; do
		output=`/sbin/ifconfig ${_if}`
		nocarrier=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'`
		[ -z "${nocarrier}" ] && carrier=true
	done
	if ! ${carrier}; then
		return
	fi
d45 2
a46 2
	delay=${defaultroute_delay}
	while [ ${delay} -gt 0 ]; do
d49 1
a49 1
			if [ ${delay} -ne ${defaultroute_delay} ]; then
d55 2
a56 2
		if [ ${delay} -eq ${defaultroute_delay} ]; then
			echo -n "Waiting ${delay}s for the default route interface: "
d60 4
d66 1
a66 1
		delay=$(($delay - 1))
@


1.9
log
@SVN rev 197697 on 2009-10-02 02:24:25Z by hrs

- Add AF_IPX and AF_NATM to afexists().

- Add afexists() check to address family specific rc.d scripts.  A
  script for an AF will be silently ignored if the kernel has no
  support for the AF.
@
text
@d31 1
a31 1
		output=`/sbin/ifconfig ${_if}` 
@


1.8
log
@SVN rev 197527 on 2009-09-26 19:00:20Z by hrs

Move rc.d/{stf,faith} to just before rc.d/routing.

Pointed out by:	tegge
@
text
@d23 2
@


1.7
log
@SVN rev 197139 on 2009-09-12 22:13:41Z by hrs

Integrate rc.d/network_ipv6 into rc.d/netif:

- Add rc.d/stf and rc.d/faith for stf(4) and faith(4).
- Remove rc.d/auto_linklocal and rc.d/network_ipv6.
- Move rc.d/sysctl to just before FILESYSTEMS because rc.d/netif
  depends on some sysctl variables.

Reviewed by:	brooks
MFC after:	3 days
@
text
@d9 1
a9 1
# REQUIRE: devd netif
@


1.6
log
@SVN rev 188710 on 2009-02-17 11:55:50Z by mtm

Rename the rc.conf(5) knob if_up_delay to defaultroute_delay to better
reflect its purpose.
@
text
@d9 1
a9 1
# REQUIRE: devd netif network_ipv6
d21 1
a21 1
	local output carrier nocarrier
d44 1
d53 1
d55 1
a55 1
		delay=`expr $delay - 1`
d58 1
a58 1
	echo
@


1.6.2.1
log
@SVN rev 196045 on 2009-08-03 08:13:06Z by kensmith

Copy head to stable/8 as part of 8.0 Release cycle.

Approved by:	re (Implicit)
@
text
@@


1.6.2.2
log
@SVN rev 208094 on 2010-05-14 19:28:16Z by dougb

MFC 208060:

Remove trailing white space. No functional changes.
@
text
@d29 1
a29 1
		output=`/sbin/ifconfig ${_if}`
@


1.6.2.3
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242909
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242909 | dim | 2012-11-12 07:47:19 +0000 (Mon, 12 Nov 2012) | 20 lines
## SVN ##
## SVN ## MFC r242625:
## SVN ##
## SVN ## Remove duplicate const specifiers in many drivers (I hope I got all of
## SVN ## them, please let me know if not).  Most of these are of the form:
## SVN ##
## SVN ## static const struct bzzt_type {
## SVN ##       [...list of members...]
## SVN ## } const bzzt_devs[] = {
## SVN ##       [...list of initializers...]
## SVN ## };
## SVN ##
## SVN ## The second const is unnecessary, as arrays cannot be modified anyway,
## SVN ## and if the elements are const, the whole thing is const automatically
## SVN ## (e.g. it is placed in .rodata).
## SVN ##
## SVN ## I have verified this does not change the binary output of a full kernel
## SVN ## build (except for build timestamps embedded in the object files).
## SVN ##
## SVN ## Reviewed by:	yongari, marius
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d5 1
a5 1
# $FreeBSD: stable/8/etc/rc.d/defaultroute 208094 2010-05-14 19:28:16Z dougb $
@


1.6.2.2.6.1
log
@SVN rev 232438 on 2012-03-03 06:15:13Z by kensmith

Copy stable/8 to releng/8.3 as part of 8.3-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.6.2.2.6.2
log
@Switch importer
@
text
@d5 1
a5 1
# $FreeBSD: releng/8.3/etc/rc.d/defaultroute 208094 2010-05-14 19:28:16Z dougb $
@


1.6.2.2.4.1
log
@SVN rev 216617 on 2010-12-21 17:09:25Z by kensmith

Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.

Approved by:	re (implicit)
@
text
@@


1.6.2.2.2.1
log
@SVN rev 209145 on 2010-06-14 02:09:06Z by kensmith

Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.

Approved by:	re (implicit)
@
text
@@


1.6.2.1.2.1
log
@SVN rev 198460 on 2009-10-25 01:10:29Z by kensmith

Copy stable/8 to releng/8.0 as part of 8.0-RELEASE release procedure.

Approved by:	re (implicit)
@
text
@@


1.5
log
@SVN rev 188478 on 2009-02-11 09:18:09Z by mtm

Reword informational message by rc.d/defaultroute.

PR:		conf/131458
@
text
@d38 1
a38 1
	delay=${if_up_delay}
d42 1
a42 1
			if [ ${delay} -ne ${if_up_delay} ]; then
d47 1
a47 1
		if [ ${delay} -eq ${if_up_delay} ]; then
@


1.4
log
@SVN rev 188009 on 2009-02-02 15:33:22Z by mtm

The 30 second wait for network interfaces to show up effectively makes the
time to boot an unplugged system 30 sec. longer for no good reason. Therefore,
add a check to make sure that any DHCP interfaces are plugged in before
waiting.
@
text
@d48 1
a48 1
			echo -n "Waiting ${delay}s for an interface to come up: "
@


1.3
log
@SVN rev 187909 on 2009-01-30 03:41:45Z by imp

Spawn one fewer shells on startup.  We don't use dhcp_interfaces at
all in this function, and grep shows no other instances of it
(besides, this is a function, and in a sub-shell, so all changes are
local).
@
text
@d21 15
a35 4
	# Return without waiting if we don't have dhcp interfaces.
	# Once we can test that the link is actually up, we should
	# remove this test and always wait.
	[ -z "`list_net_interfaces dhcp`" ] && return
@


1.2
log
@SVN rev 186237 on 2008-12-17 17:35:26Z by svn

Correct a bug where /etc/rc.d/defaultroute fails to finish by printing a
newline when it fails to obtain an address via DHCP. This made the next
rc script begin its output on the same line.

PR:		conf
Submitted by:	Bruce Cran <bruce at cran dot org dot uk>
MFC after:	3 days
@
text
@a23 1
	dhcp_interfaces=`list_net_interfaces dhcp`
@


1.1
log
@SVN rev 179566 on 2008-06-05 17:26:47Z by brooks

Fix the wait for default route change I made a few weeks ago by creating
a new defaultroute script that just does the wait.  The previous attempt
created a circular dependency through network_ipv6.

Pointy hat to:	brooks
@
text
@d33 1
a33 1
				echo "($defif)"
d45 2
@

