From cbd7fe2b24d8f0b3ad6d6dad1cc3804f62921b2d Mon Sep 17 00:00:00 2001 From: hrs Date: Sun, 4 Aug 2013 06:36:17 +0000 Subject: - Reimplement $gif_interfaces as a variant of $cloned_interfaces. Newly-configured systems should use $cloned_interfaces. - Call clone_{up,down}() and ifnet_rename() in rc.d/netif {start,stop}. ifnet_rename() now accepts an interface name list as its argument. - Add rc.d/netif clear. The "clear" subcommand is basically equivalent to "stop" but it does not call clone_down(). - Add "ifname:sticky" keyword into $cloned_interfaces. If :sticky is specified, the interface will not be destroyed in rc.d/netif stop. - Add cloned_interfaces_sticky={YES,NO}. This variable globally sets :sticky keyword above for all interfaces. The default value is NO. When cloned_interfaces_sticky=YES, :nosticky keyword can be used to override it on per interface basis. --- etc/rc.d/netif | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'etc/rc.d') diff --git a/etc/rc.d/netif b/etc/rc.d/netif index d623503..7aac42d 100755 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -38,7 +38,8 @@ start_cmd="network_start" stop_cmd="network_stop" cloneup_cmd="clone_up" clonedown_cmd="clone_down" -extra_commands="cloneup clonedown" +clear_cmd="doclear" +extra_commands="cloneup clonedown clear" cmdifn= set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces @@ -60,18 +61,15 @@ network_start() # disable SIGINT (Ctrl-c) when running at startup trap : 2 - # Create cloned interfaces - clone_up - # Create Fast EtherChannel interfaces fec_up + fi - # Create IPv6<-->IPv4 tunnels - gif_up + # Create cloned interfaces + clone_up $cmdifn - # Rename interfaces. - ifnet_rename - fi + # Rename interfaces. + ifnet_rename $cmdifn # Configure the interface(s). network_common ifn_start @@ -92,6 +90,18 @@ network_start() network_stop() { + _clone_down=1 + network_stop0 $* +} + +doclear() +{ + _clone_down= + network_stop0 $* +} + +network_stop0() +{ local _if # Set the list of interfaces to work on. @@ -101,6 +111,11 @@ network_stop() # Deconfigure the interface(s) network_common ifn_stop + # Destroy cloned interfaces + if [ -n "$_clone_down" ]; then + clone_down $cmdifn + fi + if [ -f /etc/rc.d/routing -a -n "$cmdifn" ] ; then for _if in $cmdifn; do /etc/rc.d/routing stop any $_if @@ -142,6 +157,16 @@ network_common() _fail= _ok= for ifn in ${_cooked_list}; do + # Skip if ifn does not exist. + case $_func in + ifn_stop) + if ! ${IFCONFIG_CMD} $ifn > /dev/null 2>&1; then + warn "$ifn does not exist. Skipped." + _fail="${_fail} ${ifn}" + continue + fi + ;; + esac if ${_func} ${ifn} $2; then _ok="${_ok} ${ifn}" if ipv6if ${ifn}; then -- cgit v1.1