From owner-freebsd-bugs@FreeBSD.ORG Tue Apr 6 20:30:07 2010 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 979F610656F3 for ; Tue, 6 Apr 2010 20:30:07 +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 5B0378FC19 for ; Tue, 6 Apr 2010 20:30:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o36KU7pg002770 for ; Tue, 6 Apr 2010 20:30:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o36KU7Ju002769; Tue, 6 Apr 2010 20:30:07 GMT (envelope-from gnats) Resent-Date: Tue, 6 Apr 2010 20:30:07 GMT Resent-Message-Id: <201004062030.o36KU7Ju002769@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, Mark Harrison Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAF511065673 for ; Tue, 6 Apr 2010 20:27:14 +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 90D578FC0C for ; Tue, 6 Apr 2010 20:27:14 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o36KREun032606 for ; Tue, 6 Apr 2010 20:27:14 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o36KREh8032605; Tue, 6 Apr 2010 20:27:14 GMT (envelope-from nobody) Message-Id: <201004062027.o36KREh8032605@www.freebsd.org> Date: Tue, 6 Apr 2010 20:27:14 GMT From: Mark Harrison To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/145440: Multiple fib support (setfib) in /etc/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: Tue, 06 Apr 2010 20:30:07 -0000 >Number: 145440 >Category: misc >Synopsis: Multiple fib support (setfib) in /etc/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: Tue Apr 06 20:30:06 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Mark Harrison >Release: 8.0-RELEASE-p2 >Organization: OmniTI >Environment: FreeBSD gatling.office.omniti.com 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Sat Apr 3 13:15:36 EDT 2010 root@gatling.office.omniti.com:/usr/obj/usr/src/sys/OMNIKERN amd64 >Description: It is not possible to set up static/default routes for alternate fib on startup via rc.conf. The current method is to use rc.local and manually run 'setfib route add ...' >How-To-Repeat: Recompile the kernel with multiple fib support (sysctl net.fibs should be > 1). Try to set up static routes for a fib > 0. >Fix: This patch adds support for setting up static routes in alternate fibs in rc.conf. For fibs other than 0, append _fib to the relevant configuration options normally dealt with by the routing rc script. E.g. static_routes_fib1="foo bar" defaultrouter_fib1="10.0.0.1" This requires that multiple fib support be compiled into the kernel. In addition, the stop function flushes routes for all fibs on the system. Patch attached with submission follows: --- /jails/test/etc/rc.d/routing 2009-11-21 09:31:36.000000000 -0500 +++ /etc/rc.d/routing 2010-04-06 16:12:01.050390660 -0400 @@ -27,36 +27,60 @@ routing_stop() { - route -n flush + fibcount=`sysctl -n net.fibs` + [ -z $fibcount ] && fibcount=1 + i=0 + while [ $i -lt $fibcount ]; do + setfib $i route -n flush + i=$((i + 1)) + done } static_start() { - case ${defaultrouter} in - [Nn][Oo] | '') - ;; - *) - static_routes="default ${static_routes}" - route_default="default ${defaultrouter}" - ;; - esac - - # 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 - # Now ATM static routes - # - if [ -n "${natm_static_routes}" ]; then - for i in ${natm_static_routes}; do - eval route_args=\$route_${i} - atmconfig natm add ${route_args} - done - fi + fib=0 + setfib='' + while : ; do + if [ $fib -gt 0 ]; then + eval defaultrouter=\$defaultrouter_fib${fib} + eval static_routes=\$static_routes_fib${fib} + eval natm_static_routes=\$natm_static_routes_fib${fib} + setfib="setfib $fib" + [ -z "${defaultrouter}" -a -z "${static_routes}" -a \ + -z "${natm_static_routes}" ] && break + fi + + case ${defaultrouter} in + [Nn][Oo] | '') + ;; + *) + static_routes="default ${static_routes}" + route_default="default ${defaultrouter}" + ;; + esac + + # 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} + ${setfib} route add ${route_args} + done + fi + # Now ATM static routes + # + if [ -n "${natm_static_routes}" ]; then + for i in ${natm_static_routes}; do + eval route_args=\$route_${i} + ${setfib} atmconfig natm add ${route_args} + done + fi + + # Loop through all fib configs + # + fib=$((fib + 1)) + done } _ropts_initdone= >Release-Note: >Audit-Trail: >Unformatted: