Date: Sun, 22 Aug 2010 04:39:37 GMT From: Allan Jude <freebsd@nearsourceit.com> To: freebsd-gnats-submit@FreeBSD.org Subject: conf/149867: [PATCH] rc.d script to manage multiple FIBS (kern options ROUTETABLES) from rc.conf Message-ID: <201008220439.o7M4dbx6091738@www.freebsd.org> Resent-Message-ID: <201008220440.o7M4e11Y020374@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 149867 >Category: conf >Synopsis: [PATCH] rc.d script to manage multiple FIBS (kern options ROUTETABLES) from rc.conf >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: Sun Aug 22 04:40:01 UTC 2010 >Closed-Date: >Last-Modified: >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: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008220439.o7M4dbx6091738>