diff options
author | Bill Nottingham <notting@redhat.com> | 2011-03-11 12:06:09 -0500 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2011-03-11 12:06:09 -0500 |
commit | fc73bbccaae3858ea3f895e746467a758e6b5593 (patch) | |
tree | b8e53bf304b8a026f7f5916c5dfbd5c52753beb1 | |
parent | 89032e9049921024fa65c292adb48bc8eba1e5a0 (diff) | |
download | initscripts-fc73bbccaae3858ea3f895e746467a758e6b5593.tar initscripts-fc73bbccaae3858ea3f895e746467a758e6b5593.tar.gz initscripts-fc73bbccaae3858ea3f895e746467a758e6b5593.tar.bz2 initscripts-fc73bbccaae3858ea3f895e746467a758e6b5593.tar.xz initscripts-fc73bbccaae3858ea3f895e746467a758e6b5593.zip |
Support ipv6 routing rules by merging IPv4/IPv6, and route/rule code. (#680872, <tobiasoed@hotmail.com>)
-rwxr-xr-x | sysconfig/network-scripts/ifdown-routes | 10 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-ipv6 | 7 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-routes | 39 |
3 files changed, 30 insertions, 26 deletions
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 |