]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
Reuse function and value for default GW
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 8 Jan 2012 03:36:56 +0000 (11:36 +0800)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 13 Jan 2012 22:01:22 +0000 (09:01 +1100)
Remove duplicated code to get default GW and
use existing get_default_gw().

Reuse default GW value just obtained, don't
call get_default_gw() twice.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
vpnc-script

index 4c502c2da1b51c3427a6bd619e4cccba9325ea23..b5ea1b4e76e68e0575cffbfbd288168b856d772a 100755 (executable)
@@ -232,14 +232,13 @@ else # use route command
        }
 
        del_vpngateway_route() {
-               vpngw_route=`netstat -r -n | awk '/:/ { next; } /^(default|0\.0\.0\.0)/ { print $2; }'`
-               route $route_syntax_del -host "$VPNGATEWAY" $route_syntax_gw "$vpngw_route"
+               route $route_syntax_del -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`"
        }
 
        set_default_route() {
                DEFAULTGW="`get_default_gw`"
                echo "$DEFAULTGW" > "$DEFAULT_ROUTE_FILE"
-               route $route_syntax_del default $route_syntax_gw "`get_default_gw`"
+               route $route_syntax_del default $route_syntax_gw "$DEFAULTGW"
                route add default $route_syntax_gw "$INTERNAL_IP4_ADDRESS" $route_syntax_interface
        }