aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/network-functions
diff options
context:
space:
mode:
authorMiloslav Trmac <mitr@volny.cz>2006-05-10 00:08:02 +0000
committerMiloslav Trmac <mitr@volny.cz>2006-05-10 00:08:02 +0000
commit906238c891d3f02b4c706457783694e3a01d91ce (patch)
tree4e2003e9100435d47a727d23dfdcb3f182b987f7 /sysconfig/network-scripts/network-functions
parent3bd074fd404b4863d811d0a50e9ef484523c6b57 (diff)
downloadinitscripts-906238c891d3f02b4c706457783694e3a01d91ce.tar
initscripts-906238c891d3f02b4c706457783694e3a01d91ce.tar.gz
initscripts-906238c891d3f02b4c706457783694e3a01d91ce.tar.bz2
initscripts-906238c891d3f02b4c706457783694e3a01d91ce.tar.xz
initscripts-906238c891d3f02b4c706457783694e3a01d91ce.zip
Add METRIC= support for default routes (#124045)
* ifup-ppp, network-functions: Save all default routes, lose no data. * network-functions: - (find_gateway_dev): Fix - it should find the device while $GATEWAY is not the default route - (add_default_route): Don't use configuration for the device that is being brought down; document function purpose and bugs.
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r--sysconfig/network-scripts/network-functions22
1 files changed, 14 insertions, 8 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index d2372d00..aea5f0c9 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -314,15 +314,19 @@ find_gateway_dev ()
{
. /etc/sysconfig/network
if [ -n "${GATEWAY}" -a "${GATEWAY}" != "none" ] ; then
- dev=`LC_ALL=C /sbin/ip route | \
- grep ${GATEWAY} | \
- sed -e 's/.* dev \([:alnum:]*\)/\1/'`
+ dev=$(LC_ALL=C /sbin/ip route get to "${GATEWAY}" 2>/dev/null | \
+ sed -n 's/.* dev \([[:alnum:]]*\) .*/\1/p')
if [ -n "$dev" ]; then
GATEWAYDEV="$dev"
fi
fi
}
+# After the device $1 goes away, restore the standard default route; typically
+# used for ppp with DEFROUTE temporarily replacing the "standard" default
+# route.
+# FIXME: This function doesn't support some newer features (GATEWAY in ifcfg,
+# $WINDOW, $METRIC)
add_default_route ()
{
. /etc/sysconfig/network
@@ -332,14 +336,16 @@ add_default_route ()
"${GATEWAY}" != "none" ]; then
if ! check_device_down $1; then
if [ "$GATEWAY" = "0.0.0.0" ]; then
- /sbin/ip route add default ${WINDOW:+window $WINDOW} dev ${GATEWAYDEV}
+ /sbin/ip route add default dev ${GATEWAYDEV}
else
- /sbin/ip route add default ${WINDOW:+window $WINDOW} via ${GATEWAY}
+ /sbin/ip route add default via ${GATEWAY}
fi
fi
- elif [ -f /etc/default-route ]; then
- /sbin/ip route add default ${WINDOW:+window $WINDOW} via `cat /etc/default-route`
- rm -f /etc/default-route
+ elif [ -f /etc/default-routes ]; then
+ while read spec; do
+ /sbin/ip route add $spec
+ done < /etc/default-routes
+ rm -f /etc/default-routes
fi
}