From f03e9bcc8815d76a69d1eb87ff970e59eb0db8e5 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 12 Jan 2022 13:39:53 +0100 Subject: ifup-routes: Log when using `ip $type replace` (cherry picked from commit a31060817ef8b03814b240442811ea5caa082d1c) Resolves: #2040679 --- network-scripts/ifup-routes | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/network-scripts/ifup-routes b/network-scripts/ifup-routes index e88ea9d5..5cc9187b 100755 --- a/network-scripts/ifup-routes +++ b/network-scripts/ifup-routes @@ -2,6 +2,8 @@ # # adds static routes which go through device $1 +. /etc/sysconfig/network-scripts/network-functions + if [ -z "$1" ]; then echo $"usage: ifup-routes []" exit 1 @@ -19,7 +21,12 @@ handle_file () { line="$line via $(eval echo '$'GATEWAY$routenum)" fi line="$line dev $2" - /sbin/ip route replace $line + + /sbin/ip route add "$line" || { + net_log $"Failed to add route ${line}, using ip route replace instead." warning + /sbin/ip route replace "$line" + } + routenum=$(($routenum+1)) done } @@ -34,7 +41,10 @@ handle_ip_file() { fi { cat "$file" ; echo ; } | while read line; do if [[ ! "$line" =~ $MATCH ]]; then - /sbin/ip $proto $type replace $line + /sbin/ip $proto "$type" add "$line" || { + net_log $"Failed to add ${type} ${line}, using ip ${type} replace instead." warning + /sbin/ip $proto "$type" replace "$line" + } fi done } -- cgit v1.2.1