SVN: rc-scripts/trunk/lib/functions.network

arekm arekm at pld-linux.org
Fri Feb 3 20:23:29 CET 2012


Author: arekm
Date: Fri Feb  3 20:23:29 2012
New Revision: 12474

Modified:
   rc-scripts/trunk/lib/functions.network
Log:
Adding rule by rule causes reverse order to be applied by kernel. We want rules from sysconfig/static-rules to be working in the same order as these were added in that file. The one solution is to use '/usr/bin/tac static-routes' or to use own priorities. We use prio 20000 with step 10 down, to get holes for other, manually added rules.

Modified: rc-scripts/trunk/lib/functions.network
==============================================================================
--- rc-scripts/trunk/lib/functions.network	(original)
+++ rc-scripts/trunk/lib/functions.network	Fri Feb  3 20:23:29 2012
@@ -469,12 +469,19 @@
 # Olgierd Pieczul <wojrus at pld-linux.org>
 setup_ip_rules ()
 {
-	local args prio from src
+	local args prio from src i prio
 
 	if [ -f /etc/sysconfig/static-routes ]; then
 		if is_yes "$1"; then
+			i=20000
 			grep -E "^(from|to|iif|tos|fwmark|dev|pref|priority|prio)[[:blank:]]" /etc/sysconfig/static-routes | while read args; do
-				/sbin/ip rule add $args
+				prio=""
+				if [ "${args##* prio }" = "$args" ]; then
+					# no "prio" used in rule, use own prio
+					prio="prio $i"
+					i=$((i - 10))
+				fi
+				/sbin/ip rule add $args $prio
 			done
 		elif is_no "$1"; then
 			LC_ALL=C /sbin/ip rule show | grep -vE -e "from all lookup (main|default|local|253|254|255) \$" -e " map-to " | while read prio from src args; do
@@ -485,8 +492,15 @@
 	is_no "$IPV6_NETWORKING" && return
 	if [ -f /etc/sysconfig/static-routes6 ]; then
 		if is_yes "$1"; then
+			i=20000
 			grep -E "^(from|to|iif|tos|fwmark|dev|pref|priority|prio)[[:blank:]]" /etc/sysconfig/static-routes6 | while read args; do
-				/sbin/ip -6 rule add $args
+				prio=""
+				if [ "${args##* prio }" = "$args" ]; then
+					# no "prio" used in rule, use own prio
+					prio="prio $i"
+					i=$((i - 10))
+				fi
+				/sbin/ip -6 rule add $args $prio
 			done
 		elif is_no "$1"; then
 			LC_ALL=C /sbin/ip -6 rule show | grep -vE -e "from all lookup (main|default|local|253|254|255) \$" -e " map-to " | while read prio from src args; do


More information about the pld-cvs-commit mailing list