diff options
author | smos <seth.mos@dds.nl> | 2010-05-14 16:45:31 +0200 |
---|---|---|
committer | smos <seth.mos@dds.nl> | 2010-05-14 16:47:21 +0200 |
commit | 07b54e8cf72ce96d5a38691636e5c7b0ffb97374 (patch) | |
tree | 6cc3103c0e7af1818730d68d7d267d32e8ba071d /etc/inc/system.inc | |
parent | ba374e4b298709d53aaa61bd6d61717a1211fc3e (diff) | |
download | pfsense-07b54e8cf72ce96d5a38691636e5c7b0ffb97374.zip pfsense-07b54e8cf72ce96d5a38691636e5c7b0ffb97374.tar.gz |
Do not unconditionaly remove the default route and readd it. This should make system_routing_configure more
reliably. Ticket #507
stability
Diffstat (limited to 'etc/inc/system.inc')
-rw-r--r-- | etc/inc/system.inc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 369d181..1d31a77 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -283,10 +283,37 @@ function system_routing_configure() { } } } + /* Create a array from the existing route table */ + exec("/usr/bin/netstat -rnf inet", $route_str); + array_shift($route_str); + array_shift($route_str); + array_shift($route_str); + array_shift($route_str); + $i = 0; + $route_arr = array(); + foreach($route_str as $routeline) { + $items = preg_split("/[ ]+/i", $routeline); + $route_arr[$i] = array($items[0], $items[1], $items[5]); + $i++; + } + if($dont_add_route == false) { - if (($interfacegw <> "bgpd") && (is_ipaddr($gatewayip))) - mwexec("/sbin/route delete default; /sbin/route add default " . escapeshellarg($gatewayip), true); - else { + if (($interfacegw <> "bgpd") && (is_ipaddr($gatewayip))) { + $route_count = 0; + foreach($route_arr as $route_item) { + if($route_item[0] == "default") { + $route_count = 1; + continue; + } + } + if($route_count == 0) { + $action = "add"; + } else { + $action = "change"; + } + log_error("$action default route to $gatewayip"); + mwexec("/sbin/route {$action} default " . escapeshellarg($gatewayip)); + } else { /* Adding gateway for 1.2-style configs without the new * gateway setup configured. * Force WAN to be default gateway because that is the 1.2 behavior. |