summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2013-10-04 07:00:59 +0000
committermarkm <markm@FreeBSD.org>2013-10-04 07:00:59 +0000
commit3d04a78b78e941b7b8a2fde753e44a10e838a50b (patch)
treeb22b54c18327a2e1f17c410affe15feccc2f9db5 /etc
parentb28953010e0b4d9208d7f9dcc8933e6d56f16ce3 (diff)
downloadFreeBSD-src-3d04a78b78e941b7b8a2fde753e44a10e838a50b.zip
FreeBSD-src-3d04a78b78e941b7b8a2fde753e44a10e838a50b.tar.gz
MFC - tracking commit.
Diffstat (limited to 'etc')
-rw-r--r--etc/network.subr153
-rwxr-xr-xetc/rc.d/netif31
2 files changed, 130 insertions, 54 deletions
diff --git a/etc/network.subr b/etc/network.subr
index 057fb71..36e0140 100644
--- a/etc/network.subr
+++ b/etc/network.subr
@@ -48,9 +48,11 @@ ifn_start()
ifscript_up ${ifn} && cfg=0
ifconfig_up ${ifn} && cfg=0
- afexists inet && ipv4_up ${ifn} && cfg=0
- afexists inet6 && ipv6_up ${ifn} && cfg=0
- afexists ipx && ipx_up ${ifn} && cfg=0
+ if ! noafif $ifn; then
+ afexists inet && ipv4_up ${ifn} && cfg=0
+ afexists inet6 && ipv6_up ${ifn} && cfg=0
+ afexists ipx && ipx_up ${ifn} && cfg=0
+ fi
childif_create ${ifn} && cfg=0
return $cfg
@@ -68,9 +70,11 @@ ifn_stop()
[ -z "$ifn" ] && err 1 "ifn_stop called without an interface"
- afexists ipx && ipx_down ${ifn} && cfg=0
- afexists inet6 && ipv6_down ${ifn} && cfg=0
- afexists inet && ipv4_down ${ifn} && cfg=0
+ if ! noafif $ifn; then
+ afexists ipx && ipx_down ${ifn} && cfg=0
+ afexists inet6 && ipv6_down ${ifn} && cfg=0
+ afexists inet && ipv4_down ${ifn} && cfg=0
+ fi
ifconfig_down ${ifn} && cfg=0
ifscript_down ${ifn} && cfg=0
childif_destroy ${ifn} && cfg=0
@@ -103,7 +107,7 @@ ifconfig_up()
fi
# inet6 specific
- if afexists inet6; then
+ if ! noafif $1 && afexists inet6; then
if checkyesno ipv6_activate_all_interfaces; then
_ipv6_opts="-ifdisabled"
elif [ "$1" != "lo0" ]; then
@@ -463,6 +467,7 @@ noafif()
case $_if in
pflog[0-9]*|\
pfsync[0-9]*|\
+ usbus[0-9]*|\
an[0-9]*|\
ath[0-9]*|\
ipw[0-9]*|\
@@ -1198,8 +1203,7 @@ ifscript_down()
#
clone_up()
{
- local _prefix _list ifn ifopt _iflist _n tmpargs
- _prefix=
+ local _list ifn ifopt _iflist _n tmpargs
_list=
_iflist=$*
@@ -1211,15 +1215,34 @@ clone_up()
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;;
*) continue ;;
esac
- # Skip if ifn already exists.
- if ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
- continue
- fi
- ${IFCONFIG_CMD} ${ifn} create `get_if_var ${ifn} create_args_IF`
- if [ $? -eq 0 ]; then
- _list="${_list}${_prefix}${ifn}"
- [ -z "$_prefix" ] && _prefix=' '
- fi
+ case $ifn in
+ epair[0-9]*)
+ # epair(4) uses epair[0-9] for creation and
+ # epair[0-9][ab] for configuration.
+ #
+ # Skip if ${ifn}a or ${ifn}b already exist.
+ if ${IFCONFIG_CMD} ${ifn}a > /dev/null 2>&1; then
+ continue
+ elif ${IFCONFIG_CMD} ${ifn}b > /dev/null 2>&1; then
+ continue
+ fi
+ ${IFCONFIG_CMD} ${ifn} create \
+ `get_if_var ${ifn} create_args_IF`
+ if [ $? -eq 0 ]; then
+ _list="$_list ${ifn}a ${ifn}b"
+ fi
+ ;;
+ *)
+ # Skip if ${ifn} already exists.
+ if ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
+ continue
+ fi
+ ${IFCONFIG_CMD} ${ifn} create \
+ `get_if_var ${ifn} create_args_IF`
+ if [ $? -eq 0 ]; then
+ _list="$_list $ifn"
+ fi
+ esac
done
if [ -n "$gif_interfaces" ]; then
warn "\$gif_interfaces is obsolete. Use \$cloned_interfaces instead."
@@ -1245,16 +1268,15 @@ clone_up()
;;
esac
if [ $? -eq 0 ]; then
- _list="${_list}${_prefix}${ifn}"
- [ -z "$_prefix" ] && _prefix=' '
+ _list="$_list $ifn"
fi
tmpargs=$(get_if_var $ifn gifconfig_IF)
eval ifconfig_${ifn}=\"tunnel \$tmpargs\"
done
- if [ -n "${_list}" ]; then
- echo "Created clone interfaces: ${_list}."
+ if [ -n "${_list# }" ]; then
+ echo "Created clone interfaces: ${_list# }."
fi
- debug "Cloned: ${_list}"
+ debug "Cloned: ${_list# }"
}
# clone_down
@@ -1263,8 +1285,7 @@ clone_up()
#
clone_down()
{
- local _prefix _list ifn ifopt _iflist _sticky
- _prefix=
+ local _list ifn _difn ifopt _iflist _sticky
_list=
_iflist=$*
@@ -1286,20 +1307,40 @@ clone_down()
""|$ifn|$ifn\ *|*\ $ifn\ *|*\ $ifn) ;;
*) continue ;;
esac
- # Skip if ifn does not exist.
- if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
- continue
- fi
- ${IFCONFIG_CMD} -n ${ifn} destroy
- if [ $? -eq 0 ]; then
- _list="${_list}${_prefix}${ifn}"
- [ -z "$_prefix" ] && _prefix=' '
- fi
+ case $ifn in
+ epair[0-9]*)
+ # Note: epair(4) uses epair[0-9] for removal and
+ # epair[0-9][ab] for configuration.
+ #
+ # Skip if both of ${ifn}a and ${ifn}b do not exist.
+ if ${IFCONFIG_CMD} ${ifn}a > /dev/null 2>&1; then
+ _difn=${ifn}a
+ elif ${IFCONFIG_CMD} ${ifn}b > /dev/null 2>&1; then
+ _difn=${ifn}b
+ else
+ continue
+ fi
+ ${IFCONFIG_CMD} -n $_difn destroy
+ if [ $? -eq 0 ]; then
+ _list="$_list ${ifn}a ${ifn}b"
+ fi
+ ;;
+ *)
+ # Skip if ifn does not exist.
+ if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then
+ continue
+ fi
+ ${IFCONFIG_CMD} -n ${ifn} destroy
+ if [ $? -eq 0 ]; then
+ _list="$_list $ifn"
+ fi
+ ;;
+ esac
done
- if [ -n "${_list}" ]; then
- echo "Destroyed clone interfaces: ${_list}."
+ if [ -n "${_list# }" ]; then
+ echo "Destroyed clone interfaces: ${_list# }."
fi
- debug "Destroyed clones: ${_list}"
+ debug "Destroyed clones: ${_list# }"
}
# childif_create
@@ -1574,17 +1615,33 @@ list_net_interfaces()
fi
done
_tmplist="${_lo}${_tmplist# }"
- ;;
+ ;;
*)
- _tmplist="${network_interfaces} ${cloned_interfaces}"
-
+ for _if in ${network_interfaces} ${cloned_interfaces}; do
+ # epair(4) uses epair[0-9] for creation and
+ # epair[0-9][ab] for configuration.
+ case $_if in
+ epair[0-9]*)
+ _tmplist="$_tmplist ${_if}a ${_if}b"
+ ;;
+ *)
+ _tmplist="$_tmplist $_if"
+ ;;
+ esac
+ done
+ #
# lo0 is effectively mandatory, so help prevent foot-shooting
#
case "$_tmplist" in
- lo0|'lo0 '*|*' lo0'|*' lo0 '*) ;; # This is fine, do nothing
- *) _tmplist="lo0 ${_tmplist}" ;;
- esac
+ lo0|'lo0 '*|*' lo0'|*' lo0 '*)
+ # This is fine, do nothing
+ _tmplist="${_tmplist# }"
;;
+ *)
+ _tmplist="lo0 ${_tmplist# }"
+ ;;
+ esac
+ ;;
esac
_list=
@@ -1596,14 +1653,14 @@ list_net_interfaces()
_list="${_list# } ${_if}"
fi
done
- ;;
+ ;;
dhcp)
for _if in ${_tmplist} ; do
if dhcpif $_if; then
_list="${_list# } ${_if}"
fi
done
- ;;
+ ;;
noautoconf)
for _if in ${_tmplist} ; do
if ! ipv6_autoconfif $_if && \
@@ -1611,17 +1668,17 @@ list_net_interfaces()
_list="${_list# } ${_if}"
fi
done
- ;;
+ ;;
autoconf)
for _if in ${_tmplist} ; do
if ipv6_autoconfif $_if; then
_list="${_list# } ${_if}"
fi
done
- ;;
+ ;;
*)
_list=${_tmplist}
- ;;
+ ;;
esac
echo $_list
diff --git a/etc/rc.d/netif b/etc/rc.d/netif
index 7aac42d..2cb7754 100755
--- a/etc/rc.d/netif
+++ b/etc/rc.d/netif
@@ -72,7 +72,7 @@ network_start()
ifnet_rename $cmdifn
# Configure the interface(s).
- network_common ifn_start
+ network_common ifn_start $cmdifn
if [ -f /etc/rc.d/ipfilter ] ; then
# Resync ipfilter
@@ -109,7 +109,7 @@ network_stop0()
cmdifn=$*
# Deconfigure the interface(s)
- network_common ifn_stop
+ network_common ifn_stop $cmdifn
# Destroy cloned interfaces
if [ -n "$_clone_down" ]; then
@@ -129,7 +129,7 @@ network_stop0()
# an interface and then calls $routine.
network_common()
{
- local _cooked_list _fail _func _ok _str
+ local _cooked_list _tmp_list _fail _func _ok _str _cmdifn
_func=
@@ -137,26 +137,45 @@ network_common()
err 1 "network_common(): No function name specified."
else
_func="$1"
+ shift
fi
# Set the scope of the command (all interfaces or just one).
#
_cooked_list=
- if [ -n "$cmdifn" ]; then
+ _tmp_list=
+ _cmdifn=$*
+ if [ -n "$_cmdifn" ]; then
# Don't check that the interface(s) exist. We need to run
# the down code even when the interface doesn't exist to
# kill off wpa_supplicant.
# XXXBED: is this really true or does wpa_supplicant die?
# if so, we should get rid of the devd entry
- _cooked_list="$cmdifn"
+ _cooked_list="$_cmdifn"
else
_cooked_list="`list_net_interfaces`"
fi
+ # Expand epair[0-9] to epair[0-9][ab].
+ for ifn in $_cooked_list; do
+ case ${ifn#epair} in
+ [0-9]*[ab]) ;; # Skip epair[0-9]*[ab].
+ [0-9]*)
+ for _str in $_cooked_list; do
+ case $_str in
+ $ifn) _tmp_list="$_tmp_list ${ifn}a ${ifn}b" ;;
+ *) _tmp_list="$_tmp_list ${ifn}" ;;
+ esac
+ done
+ _cooked_list=${_tmp_list# }
+ ;;
+ esac
+ done
+
_dadwait=
_fail=
_ok=
- for ifn in ${_cooked_list}; do
+ for ifn in ${_cooked_list# }; do
# Skip if ifn does not exist.
case $_func in
ifn_stop)
OpenPOWER on IntegriCloud