diff --git a/Shorewall/Perl/prog.header b/Shorewall/Perl/prog.header index 817d5206f..1bffd1b86 100644 --- a/Shorewall/Perl/prog.header +++ b/Shorewall/Perl/prog.header @@ -518,7 +518,11 @@ save_default_route() { # # Restore the default route that was in place before the initial 'shorewall start' # -replace_default_route() { +replace_default_route() # $1 = USE_DEFAULT_RT +{ + # + # default_route and result are inherited from the caller + # if [ -n "$default_route" ]; then case "$default_route" in *metric*) @@ -540,12 +544,12 @@ replace_default_route() { restore_default_route() # $1 = USE_DEFAULT_RT { local result + result=1 if [ -z "$g_noroutes" -a -f ${VARDIR}/default_route ]; then local default_route default_route= local route - result=1 while read route ; do case $route in diff --git a/Shorewall/Perl/prog.header6 b/Shorewall/Perl/prog.header6 index f8f0d71ee..4caa49b3b 100644 --- a/Shorewall/Perl/prog.header6 +++ b/Shorewall/Perl/prog.header6 @@ -506,41 +506,43 @@ save_default_route() { # # Restore the default route that was in place before the initial 'shorewall start' # -replace_default_route() { - qt $IP -6 route replace $default_route && \ - result=0 && \ - progress_message "Default Route (${default_route# }) restored" +replace_default_route() # $1 = USE_DEFAULT_RT +{ + # + # default_route and result are inherited from the caller + # + if [ -n "$default_route" ]; then + case "$default_route" in + *metric*) + # + # Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes. Otherwise, we only replace the one with metric 0 + # + [ -n "$1" ] && qt $IP -6 route replace $default_route && progress_message "Default Route (${default_route# }) restored" + default_route= + ;; + *) + qt $IP -6 route replace $default_route && progress_message "Default Route (${default_route# }) restored" + result=0 + default_route= + ;; + esac + fi } restore_default_route() # $1 = USE_DEFAULT_RT { local result + result=1 if [ -z "$g_noroutes" -a -f ${VARDIR}/default_route ]; then local default_route default_route= local route - result=1 while read route ; do case $route in default*) - if [ -n "$default_route" ]; then - case "$default_route" in - *metric*) - # - # Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes. Otherwise, we only replace the one with metric 0 - # - [ -n "$1" ] && replace_default_route - default_route= - ;; - *) - replace_default_route - default_route= - ;; - esac - fi - + replace_default_route $1 default_route="$default_route $route" ;; *) @@ -549,9 +551,9 @@ restore_default_route() # $1 = USE_DEFAULT_RT esac done < ${VARDIR}/default_route - if [ -n "$default_route" ]; then - replace_default_route - elif [ $result = 1 ]; then + replace_default_route $1 + + if [ $result = 1 ]; then # # We added a default route with metric 0 but there wasn't one previously #