From fc73bbccaae3858ea3f895e746467a758e6b5593 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 11 Mar 2011 12:06:09 -0500 Subject: Support ipv6 routing rules by merging IPv4/IPv6, and route/rule code. (#680872, ) --- sysconfig/network-scripts/ifdown-routes | 10 ++++++--- sysconfig/network-scripts/ifup-ipv6 | 7 ------ sysconfig/network-scripts/ifup-routes | 39 +++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 26 deletions(-) (limited to 'sysconfig') diff --git a/sysconfig/network-scripts/ifdown-routes b/sysconfig/network-scripts/ifdown-routes index 00e592f7..3c62498a 100755 --- a/sysconfig/network-scripts/ifdown-routes +++ b/sysconfig/network-scripts/ifdown-routes @@ -12,16 +12,20 @@ fi MATCH='^[[:space:]]*(\#.*)?$' # Routing rules -FILES="/etc/sysconfig/network-scripts/rule-$1" +FILES="/etc/sysconfig/network-scripts/rule-$1 /etc/sysconfig/network-scripts/rule6-$1" if [ -n "$2" -a "$2" != "$1" ]; then - FILES="$FILES /etc/sysconfig/network-scripts/rule-$2" + FILES="$FILES /etc/sysconfig/network-scripts/rule-$2 /etc/sysconfig/network-scripts/rule6-$2" fi for file in $FILES; do if [ -f "$file" ]; then + proto= + if [ "$file" != "${file##*/rule6-}" ]; then + proto="-6" + fi { cat "$file" ; echo ; } | while read line; do if [[ ! "$line" =~ $MATCH ]]; then - /sbin/ip rule del $line + /sbin/ip $proto rule del $line fi done fi diff --git a/sysconfig/network-scripts/ifup-ipv6 b/sysconfig/network-scripts/ifup-ipv6 index 6f104dc5..93a55d6e 100755 --- a/sysconfig/network-scripts/ifup-ipv6 +++ b/sysconfig/network-scripts/ifup-ipv6 @@ -160,13 +160,6 @@ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then done fi -# Setup additional static IPv6 routes (newer config style) -if [ -f "/etc/sysconfig/network-scripts/route6-$DEVICE" ]; then - sed -ne 's/#.*//' -e '/[^[:space:]]/p' "/etc/sysconfig/network-scripts/route6-$DEVICE" | while read line; do - /sbin/ip -6 route add $line - done -fi - # Setup of 6to4, if configured if [ "$IPV6TO4INIT" = "yes" ]; then valid6to4config="yes" diff --git a/sysconfig/network-scripts/ifup-routes b/sysconfig/network-scripts/ifup-routes index db3e51ea..ff8d5b56 100755 --- a/sysconfig/network-scripts/ifup-routes +++ b/sysconfig/network-scripts/ifup-routes @@ -6,6 +6,8 @@ if [ -z "$1" ]; then exit 1 fi +MATCH='^[[:space:]]*(\#.*)?$' + handle_file () { . $1 routenum=0 @@ -21,13 +23,26 @@ handle_file () { done } -FILES="/etc/sysconfig/network-scripts/route-$1" +handle_ip_file() { + local f t type= file=$1 proto="-4" + f=${file##*/} + t=${f%%-*} + type=${t%%6} + if [ "$type" != "$t" ]; then + proto="-6" + fi + { cat "$file" ; echo ; } | while read line; do + if [[ ! "$line" =~ $MATCH ]]; then + /sbin/ip $proto $type add $line + fi + done +} + +FILES="/etc/sysconfig/network-scripts/route-$1 /etc/sysconfig/network-scripts/route6-$1" if [ -n "$2" -a "$2" != "$1" ]; then - FILES="$FILES /etc/sysconfig/network-scripts/route-$2" + FILES="$FILES /etc/sysconfig/network-scripts/route-$2 /etc/sysconfig/network-scripts/route6-$2" fi -MATCH='^[[:space:]]*(\#.*)?$' - for file in $FILES; do if [ -f "$file" ]; then if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $file ; then @@ -35,11 +50,7 @@ for file in $FILES; do handle_file $file ${1%:*} else # older format - { cat "$file" ; echo ; } | while read line; do - if [[ ! "$line" =~ $MATCH ]]; then - /sbin/ip route add $line - fi - done + handle_ip_file $file fi fi done @@ -52,17 +63,13 @@ CONFIG="/etc/sysconfig/network-scripts/$NICK.route" # Routing rules -FILES="/etc/sysconfig/network-scripts/rule-$1" +FILES="/etc/sysconfig/network-scripts/rule-$1 /etc/sysconfig/network-scripts/rule6-$1" if [ -n "$2" -a "$2" != "$1" ]; then - FILES="$FILES /etc/sysconfig/network-scripts/rule-$2" + FILES="$FILES /etc/sysconfig/network-scripts/rule-$2 /etc/sysconfig/network-scripts/rule6-$2" fi for file in $FILES; do if [ -f "$file" ]; then - { cat "$file" ; echo ; } | while read line; do - if [[ ! "$line" =~ $MATCH ]]; then - /sbin/ip rule add $line - fi - done + handle_ip_file $file fi done -- cgit v1.2.1