From nobody@FreeBSD.org  Sun Aug 22 04:39:38 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 906CC10656A4
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 22 Aug 2010 04:39:38 +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 655CF8FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 22 Aug 2010 04:39:38 +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 o7M4dctw091739
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 22 Aug 2010 04:39:38 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o7M4dbx6091738;
	Sun, 22 Aug 2010 04:39:37 GMT
	(envelope-from nobody)
Message-Id: <201008220439.o7M4dbx6091738@www.freebsd.org>
Date: Sun, 22 Aug 2010 04:39:37 GMT
From: Allan Jude <freebsd@nearsourceit.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] rc.d script to manage multiple FIBS (kern options ROUTETABLES) from rc.conf
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         149867
>Category:       conf
>Synopsis:       [patch] rc.fibs(5): new rc.d script to manage multiple FIBS (kern options ROUTETABLES)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 22 04:40:01 UTC 2010
>Closed-Date:    
>Last-Modified:  Sun May 04 03:48:07 UTC 2014
>Originator:     Allan Jude
>Release:        8.1-RELEASE
>Organization:
Near Source IT
>Environment:
FreeBSD LAX1-1.CDN.ScaleEngine.net 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
When you use the kernel option ROUTETABLES to enable multiple FIBs, there
is not clean way to manage the static routes (including default gateway)
for those FIBs

this is an /etc/rc.d script to do that, based on /etc/rc.d/routing and
static_routes in /etc/rc.conf

>How-To-Repeat:

>Fix:
in /etc/rc.conf or the like, configure like this:

fib_1_routes="default sitea"
fib_1_default="default 192.168.0.1"
fib_1_sitea="-net 192.168.1.0/24 192.168.0.2"

fib_2_routes="gate"
fib_2_gate="default 10.0.0.254"


Patch attached with submission follows:

#!/bin/sh
#
# Configure multiple FIBs for ROUTETABLES
#
# $Id$
#

# PROVIDE: fibs
# REQUIRE: netif ppp routing FILESYSTEMS
# KEYWORD: nojail

. /etc/rc.subr
. /etc/network.subr

name="fibs"
start_cmd="fibs_start"
stop_cmd="fibs_stop"

fibs_start()
{

        # Setup static routes for each FIB.
        #
        _numfibs=`sysctl -n net.fibs`
        _fiblist=`jot ${_numfibs} 0 ${_numfibs} 1`
        for n in ${_fiblist}; do
                eval _fibroutes=\$fib_${n}_routes
                if [ -n "${_fibroutes}" ]; then
                        for i in ${_fibroutes}; do
                                eval _fib_args=\$fib_${n}_${i}
                                setfib ${n} route add ${_fib_args}
                        done
                fi
        done
}

fibs_stop()
{
        _numfibs=`sysctl -n net.fibs`
        _fiblist=`jot ${_numfibs} 0 ${_numfibs} 1`
        for n in ${_fiblist}; do
                setfib ${n} route -n flush
        done
}

load_rc_config $name
run_rc_command "$1"


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Aug 22 04:47:16 UTC 2010 
Responsible-Changed-Why:  
New script.  Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=149867 
>Unformatted:
