aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifup-routes
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2011-03-11 12:06:09 -0500
committerBill Nottingham <notting@redhat.com>2011-03-11 12:06:09 -0500
commitfc73bbccaae3858ea3f895e746467a758e6b5593 (patch)
treeb8e53bf304b8a026f7f5916c5dfbd5c52753beb1 /sysconfig/network-scripts/ifup-routes
parent89032e9049921024fa65c292adb48bc8eba1e5a0 (diff)
downloadinitscripts-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>)
Diffstat (limited to 'sysconfig/network-scripts/ifup-routes')
-rwxr-xr-xsysconfig/network-scripts/ifup-routes39
1 files changed, 23 insertions, 16 deletions
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