From: Arkadiusz Miśkiewicz Date: Thu, 8 Jan 2004 02:43:46 +0000 (+0000) Subject: When shutting down ip rule and ip route, clear rules using current kernel tables... X-Git-Tag: 0.4.0.7~2 X-Git-Url: https://git.pld-linux.org/?a=commitdiff_plain;h=492f0ebcf2c0bf242503c1bf53121099c66c0e4f;p=projects%2Frc-scripts.git When shutting down ip rule and ip route, clear rules using current kernel tables configuration not data stored in configuration files so we always end in clean state (by Arkadiusz Chomicki ). svn-id: @3133 --- diff --git a/sysconfig/network-scripts/functions.network b/sysconfig/network-scripts/functions.network index f5469d64..703d4053 100644 --- a/sysconfig/network-scripts/functions.network +++ b/sysconfig/network-scripts/functions.network @@ -64,23 +64,22 @@ if [ -n "$domain" ] ; then fi } -# PLD Linux Distribution network functions -# Copyright (C) 1999, 2000 Arkadiusz Mi¶kiewicz - # Setup Network Address Translation (NAT) setup_nat() { typeset src via dst if [ -r /etc/sysconfig/static-nat ]; then - grep "^[0-9]" /etc/sysconfig/static-nat | while read src via dst; do - if [ "$1" = "on" ]; then + if [ "$1" = "on" ]; then + grep "^[0-9]" /etc/sysconfig/static-nat | while read src via dst; do /sbin/ip route add nat $dst via $src /sbin/ip rule add from $src nat $dst - elif [ "$1" = "off" ]; then + done + elif [ "$1" = "off" ]; then + /sbin/ip route show table all | egrep "^nat[[:blank:]]" | while read nat dst via src args; do /sbin/ip rule del from $src nat $dst /sbin/ip route del nat $dst via $src + done fi - done fi } @@ -410,16 +409,16 @@ fi # following function setups advanced routing rules # Olgierd Pieczul setup_ip_rules () { -typeset args +typeset args prio from src if [ -f /etc/sysconfig/static-routes ] ; then if is_yes "$1"; then - egrep "^(from|to|iif|tos|fwmark|dev|pref)[[:blank:]]" /etc/sysconfig/static-routes | while read args; do + egrep "^(from|to|iif|tos|fwmark|dev|pref|priority|prio)[[:blank:]]" /etc/sysconfig/static-routes | while read args; do /sbin/ip rule add $args done elif is_no "$1"; then - egrep "^(from|to|iif|tos|fwmark|dev|pref)[[:blank:]]" /etc/sysconfig/static-routes | while read args; do - /sbin/ip rule del $args - done + /sbin/ip rule show | egrep -v -e "from all lookup (main|default|local) \$" -e " map-to " | while read prio from src args; do + [ "$src" == "all" ] && ip rule delete $args || ip rule delete $from $src $args + done fi fi }