[RFC] setfib support in routing script
Sergey Matveychuk
sem at FreeBSD.org
Wed Mar 4 02:37:56 PST 2009
Hi.
There is a lack of setfib support in routing script. I've made a patch
for the script. It allows use the syntax in rc.conf file:
defaultrouter_fibN="..."
static_routes_fibN="..."
Where N is a fid number.
If there will be no objections, I'll make the same for ipv6_* and fill a PR.
BTW. Why ipv4 routing setting up in rc.d/routing script, but ipv6 using
network.subr subroutine?
--
Dixi.
Sem.
-------------- next part --------------
--- 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 _droute=\$defaultrouter_fib${n}
+ eval _routes=\$static_routes_fib${n}
+
+ case ${_droute} in
+ [Nn][Oo] | '')
+ ;;
+ *)
+ _routes="default ${_routes}"
+ route_default="default ${_droute}"
+ ;;
+ 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
More information about the freebsd-rc
mailing list