summaryrefslogtreecommitdiffstats
path: root/etc/inc/system.inc
diff options
context:
space:
mode:
authorsmos <seth.mos@dds.nl>2010-05-17 11:23:47 +0200
committersmos <seth.mos@dds.nl>2010-05-17 11:23:47 +0200
commitb61154fbf9bd480ba78c51baaee408854bfbaec3 (patch)
tree82e72ccdb78a3892b05eea8e1a3f9ed77b8e8cbb /etc/inc/system.inc
parentbcbcc2f815a789bd7eb476d8a7df25674eaba8b1 (diff)
downloadpfsense-b61154fbf9bd480ba78c51baaee408854bfbaec3.zip
pfsense-b61154fbf9bd480ba78c51baaee408854bfbaec3.tar.gz
Reduce the amount of logic in system_routing_configure to check for existing routes. This code is in the same style as used
by Ermal. Ticket #507
Diffstat (limited to 'etc/inc/system.inc')
-rw-r--r--etc/inc/system.inc23
1 files changed, 5 insertions, 18 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 1d31a77..41f3b8b 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -289,29 +289,19 @@ function system_routing_configure() {
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++;
+ $route_arr[$item[0]] = array($items[0], $items[1], $items[5]);
}
if($dont_add_route == false) {
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 = "add";
+ if(isset($route_arr['default'])) {
$action = "change";
}
- log_error("$action default route to $gatewayip");
+ log_error("ROUTING: $action default route to $gatewayip");
mwexec("/sbin/route {$action} default " . escapeshellarg($gatewayip));
} else {
/* Adding gateway for 1.2-style configs without the new
@@ -327,9 +317,6 @@ function system_routing_configure() {
}
if (is_array($config['staticroutes']['route'])) {
- $route_str = array();
- exec("/usr/bin/netstat -rnf inet | /usr/bin/cut -d \" \" -f 1", $route_str);
- $route_str = array_flip($route_str);
$gateways_arr = return_gateways_array();
foreach ($config['staticroutes']['route'] as $rtent) {
@@ -345,7 +332,7 @@ function system_routing_configure() {
}
$action = "add";
- if (isset($route_str[$rtent['network']]))
+ if (isset($route_arr[$rtent['network']]))
$action = "change";
if (is_ipaddr($gatewayip)) {
OpenPOWER on IntegriCloud