conf/132476: [rc.d] [patch] add support setfib(1) in rc.d/routing

Sergey Matveychuk sem at FreeBSD.org
Mon Mar 9 10:40:13 PDT 2009


>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:


More information about the freebsd-bugs mailing list