diff --git a/Shorewall/Perl/Shorewall/Providers.pm b/Shorewall/Perl/Shorewall/Providers.pm index 3f97666a7..63ae6bca5 100644 --- a/Shorewall/Perl/Shorewall/Providers.pm +++ b/Shorewall/Perl/Shorewall/Providers.pm @@ -625,7 +625,7 @@ sub add_a_provider( $$ ) { if ( $balance || $default ) { $tbl = $default || $config{USE_DEFAULT_RT} ? DEFAULT_TABLE : MAIN_TABLE; - $weight = $balance ? $balance : $default; + $weight = $balance ? $balance : $default; if ( $gateway ) { emit qq(add_gateway "nexthop via $gateway dev $physical weight $weight $realm" ) . $tbl; @@ -642,6 +642,7 @@ sub add_a_provider( $$ ) { pop_indent; emit( 'else', + qq( echo $weight > \${VARDIR}/${physical}_weight), qq( progress_message " Provider $table ($number) Started"), "fi\n" ); @@ -700,7 +701,7 @@ sub add_a_provider( $$ ) { $via .= " weight $weight"; $via .= " $realm" if $realm; - emit( qq( delete_gateway "$via" ) . $tbl ); + emit( qq( delete_gateway "$via" $tbl $physical) ); } emit( '', diff --git a/Shorewall/Perl/prog.header b/Shorewall/Perl/prog.header index c75e387e1..8f9ed401b 100644 --- a/Shorewall/Perl/prog.header +++ b/Shorewall/Perl/prog.header @@ -608,21 +608,21 @@ add_gateway() # $1 = Delta $2 = Table Number local route local weight local delta + local dev route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/default //; s/[\]//g'` if [ -z "$route" ]; then run_ip route add default scope global table $2 $1 - find_weight $1 > ${VARDIR}/weight else delta=$1 if ! echo $route | fgrep -q ' nexthop '; then route=`echo $route | sed 's/via/nexthop via/'` - if [ -f ${VARDIR}/weight ]; then - weight=`cat ${VARDIR}/weight` + dev=$(find_device $route) + if [ -f ${VARDIR}/${dev}_weight ]; then + weight=`cat ${VARDIR}/${dev}_weight` route="$route weight $weight" - rm -f ${VARDIR}/weight fi fi @@ -633,11 +633,11 @@ add_gateway() # $1 = Delta $2 = Table Number # # Remove a gateway from the default route # -delete_gateway() # $! = Description of the Gateway $2 = table number +delete_gateway() # $! = Description of the Gateway $2 = table number $3 = device { local route local gateway - local newroute + local dev route=`$IP -4 -o route ls table $2 | grep ^default | sed 's/[\]//g'` gateway=$1 @@ -645,22 +645,11 @@ delete_gateway() # $! = Description of the Gateway $2 = table number if [ -n "$route" ]; then if echo $route | fgrep -q ' nexthop '; then gateway="nexthop $gateway" - fi - - eval route=\`echo $route \| sed \'s/$gateway/ /\'\` - - if echo $route | fgrep -q ' via '; then + eval route=\`echo $route \| sed \'s/$gateway/ /\'\` run_ip route replace table $2 $route else - run_ip route delete default table $2 - fi - - newroute=`$IP -4 -o route ls table $2 | grep ^default` - - if echo $newroute | fgrep -q ' nexthop '; then - rm -f ${VARDIR}/weight - else - find_weight $route > ${VARDIR}/weight + dev=$(find_device $route) + [ "$dev" = "$3" ] && run_ip route delete default table $2 fi fi }