From owner-svn-src-all@FreeBSD.ORG Fri Oct 2 20:19:53 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B28671065695; Fri, 2 Oct 2009 20:19:53 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 97D518FC08; Fri, 2 Oct 2009 20:19:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n92KJrr6012167; Fri, 2 Oct 2009 20:19:53 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n92KJrRo012165; Fri, 2 Oct 2009 20:19:53 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <200910022019.n92KJrRo012165@svn.freebsd.org> From: Hiroki Sato Date: Fri, 2 Oct 2009 20:19:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197719 - head/etc/rc.d X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2009 20:19:53 -0000 Author: hrs Date: Fri Oct 2 20:19:53 2009 New Revision: 197719 URL: http://svn.freebsd.org/changeset/base/197719 Log: - Enable an afexists() check only when no AF argument is specified. - Simplify helper functions. Discussed with: ume Modified: head/etc/rc.d/routing Modified: head/etc/rc.d/routing ============================================================================== --- head/etc/rc.d/routing Fri Oct 2 20:15:47 2009 (r197718) +++ head/etc/rc.d/routing Fri Oct 2 20:19:53 2009 (r197719) @@ -13,26 +13,80 @@ . /etc/network.subr name="routing" -start_cmd="routing_start" +start_cmd="routing_start doall" stop_cmd="routing_stop" extra_commands="options static" -static_cmd="static_start" -options_cmd="options_start" +static_cmd="routing_start static" +options_cmd="routing_start options" + +afcheck() +{ + case $_af in + ""|inet|inet6|ipx|atm) + ;; + *) + err 1 "Unsupported address family: $_af." + ;; + esac +} routing_start() { - static_start "$@" - options_start "$@" + local _cmd _af _a + _cmd=$1 + _af=$2 + + afcheck + + case $_af in + inet|inet6|ipx|atm) + setroutes $_cmd $_af + ;; + "") + for _a in inet inet6 ipx atm; do + afexists $_a && setroutes $_cmd $_a + done + ;; + esac + [ -n "${_ropts_initdone}" ] && echo '.' } routing_stop() { - local _af + local _af _a + _af=$1 - static_stop "$@" - for _af in inet inet6; do - afexists ${_af} && eval routing_stop_${_af} - done + afcheck + + case $_af in + inet|inet6|ipx|atm) + eval static_${_af} delete + eval routing_stop_${_af} + ;; + "") + for _a in inet inet6 ipx atm; do + afexists $_a || continue + eval static_${_a} delete + eval routing_stop_${_a} + done + ;; + esac +} + +setroutes() +{ + case $1 in + static) + static_$2 add + ;; + options) + options_$2 + ;; + doall) + static_$2 add + options_$2 + ;; + esac } routing_stop_inet() @@ -50,45 +104,14 @@ routing_stop_inet6() done } -static_start() -{ - local _af - _af=$1 - - case ${_af} in - inet|inet6|atm) - do_static add ${_af} - ;; - "") - do_static add inet inet6 atm - ;; - esac -} - -static_stop() +routing_stop_atm() { - local _af - _af=$1 - - case ${_af} in - inet|inet6|atm) - do_static delete ${_af} - ;; - "") - do_static delete inet inet6 atm - ;; - esac + return 0 } -do_static() +routing_stop_ipx() { - local _af _action - _action=$1 - - shift - for _af in "$@"; do - afexists ${_af} && eval static_${_af} ${_action} - done + return 0 } static_inet() @@ -233,6 +256,10 @@ static_atm() fi } +static_ipx() +{ +} + _ropts_initdone= ropts_init() { @@ -242,16 +269,6 @@ ropts_init() fi } -options_start() -{ - local _af - - for _af in inet inet6 ipx; do - afexists ${_af} && eval options_${_af} - done - [ -n "${_ropts_initdone}" ] && echo '.' -} - options_inet() { if checkyesno icmp_bmcastecho; then @@ -322,6 +339,10 @@ options_inet6() fi } +options_atm() +{ +} + options_ipx() { if checkyesno ipxgateway_enable; then