From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 9 17:40:01 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B60EA1065978 for ; Mon, 9 Mar 2009 17:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 791698FC1A for ; Mon, 9 Mar 2009 17:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n29He1Is076306 for ; Mon, 9 Mar 2009 17:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n29He112076305; Mon, 9 Mar 2009 17:40:01 GMT (envelope-from gnats) Resent-Date: Mon, 9 Mar 2009 17:40:01 GMT Resent-Message-Id: <200903091740.n29He112076305@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Sergey Matveychuk Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 484861065B8B for ; Mon, 9 Mar 2009 17:36:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 1DA9C8FC1B for ; Mon, 9 Mar 2009 17:36:16 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n29HaFWN093681 for ; Mon, 9 Mar 2009 17:36:15 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n29HaFYe093680; Mon, 9 Mar 2009 17:36:15 GMT (envelope-from nobody) Message-Id: <200903091736.n29HaFYe093680@www.freebsd.org> Date: Mon, 9 Mar 2009 17:36:15 GMT From: Sergey Matveychuk To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: conf/132476: [rc.d] [patch] add support setfib(1) in rc.d/routing X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2009 17:40:13 -0000 >Number: 132476 >Category: conf >Synopsis: [rc.d] [patch] add support setfib(1) in rc.d/routing >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Mar 09 17:40:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Sergey Matveychuk >Release: CURRENT >Organization: >Environment: >Description: Add support of setfib(1) in rc.d routing script. setfib works only with IPv4 so it's useless for IPv6. >How-To-Repeat: >Fix: Patch attached with submission follows: --- etc/rc.d/routing.orig 2009-03-04 12:36:15.000000000 +0300 +++ etc/rc.d/routing 2009-03-04 12:36:22.000000000 +0300 @@ -27,28 +27,44 @@ routing_stop() { - route -n flush + _fibs_num=`sysctl -n net.fibs` + for i in `jot ${_fibs_num} 0`; do + setfib -F $i route -n flush + done } static_start() { - case ${defaultrouter} in - [Nn][Oo] | '') - ;; - *) - static_routes="default ${static_routes}" - route_default="default ${defaultrouter}" - ;; - esac + _fibs_num=`sysctl -n net.fibs` + if [ -n "${static_routes}" ]; then + static_routes_fib0=${static_routes} + fi + if [ -n "${defaultrouter}" ]; then + defaultrouter_fib0=${defaultrouter} + fi # Setup static routes. This should be done before router discovery. # - if [ -n "${static_routes}" ]; then - for i in ${static_routes}; do - eval route_args=\$route_${i} - route add ${route_args} - done - fi + for n in `jot ${_fibs_num} 0`; do + eval _drouter=\$defaultrouter_fib${n} + eval _routes=\$static_routes_fib${n} + + case ${_drouter} in + [Nn][Oo] | '') + ;; + *) + _routes="default ${_routes}" + route_default="default ${_drouter}" + ;; + esac + + if [ -n "${_routes}" ]; then + for i in ${_routes}; do + eval route_args=\$route_${i} + setfib -F $n route add ${route_args} + done + fi + done # Now ATM static routes # if [ -n "${natm_static_routes}" ]; then --- share/man/man5/rc.conf.5.orig 2009-03-04 12:41:55.000000000 +0300 +++ share/man/man5/rc.conf.5 2009-03-09 20:19:45.000000000 +0300 @@ -2187,7 +2187,14 @@ .Dq Li NO , create a default route to this host name or IP address (use an IP address if this router is also required to get to the -name server!). +name server!). It's an equivalent of +.Va defaultrouter_fib0 . +.It Va defaultrouter_fibN +.Pq Vt str +If not set to +.Dq Li NO , +create a default route to this host name or IP address in FIB +number N. See the setfib(1). .It Va ipv6_defaultrouter .Pq Vt str The IPv6 equivalent of @@ -2195,10 +2202,9 @@ .It Va static_routes .Pq Vt str Set to the list of static routes that are to be added at system -boot time. -If not set to -.Dq Li NO -then for each whitespace separated +boot time. (It's an equivalent of +.Va static_routes_fib0 ) +If not empty then for each whitespace separated .Ar element in the value, a .Va route_ Ns Aq Ar element @@ -2212,6 +2218,10 @@ route_mcast="-net 224.0.0.0/4 -iface gif0" route_gif0local="-host 169.254.1.1 -iface lo0" .Ed +.It Va static_routes_fibN +.Pq Vt str +Set to the list of static routes that are to be added in FIB +number N. See setfib(1). .It Va ipv6_static_routes .Pq Vt str The IPv6 equivalent of >Release-Note: >Audit-Trail: >Unformatted: