summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-02-09 09:36:50 +0000
committerErmal <eri@pfsense.org>2013-02-09 09:36:50 +0000
commitf934af33e33c74246c3ec0f621798eb14d4b76bd (patch)
tree662b364439e60f25b1597496070d7832d775849f /etc/inc
parent8be135cd114fbc9294ec9dafed2125d0e553956c (diff)
downloadpfsense-f934af33e33c74246c3ec0f621798eb14d4b76bd.zip
pfsense-f934af33e33c74246c3ec0f621798eb14d4b76bd.tar.gz
Optimize and cleanup routing function
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/system.inc55
1 files changed, 23 insertions, 32 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 295c6eb..31643e0 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -373,40 +373,31 @@ function system_routing_configure($interface = "") {
if (is_array($config['gateways']['gateway_item'])) {
mwexec("/bin/rm {$g['tmp_path']}/*_defaultgw", true);
foreach ($config['gateways']['gateway_item'] as $gateway) {
- if (isset($gateway['defaultgw']) && (is_ipaddrv4($gateway['gateway']) || $gateway['gateway'] == "dynamic")) {
- if ($gateway['ipprotocol'] == "inet6")
- continue;
- if(strstr($gateway['gateway'], ":"))
- continue;
- if ($gateway['gateway'] == "dynamic")
- $gateway['gateway'] = get_interface_gateway($gateway['interface']);
- $gatewayip = $gateway['gateway'];
- $interfacegw = $gateway['interface'];
- if (!empty($interfacegw)) {
- $defaultif = get_real_interface($gateway['interface']);
- if ($defaultif)
- @file_put_contents("{$g['tmp_path']}/{$defaultif}_defaultgw", $gatewayip);
+ if (isset($gateway['defaultgw'])) {
+ if ($gateway['ipprotocol'] != "inet6" && (is_ipaddrv4($gateway['gateway']) || $gateway['gateway'] == "dynamic")) {
+ if(strstr($gateway['gateway'], ":"))
+ continue;
+ if ($gateway['gateway'] == "dynamic")
+ $gateway['gateway'] = get_interface_gateway($gateway['interface']);
+ if (!empty($gateway['interface'])) {
+ $defaultif = get_real_interface($gateway['interface']);
+ if ($defaultif)
+ @file_put_contents("{$g['tmp_path']}/{$defaultif}_defaultgw", $gateway['gateway']);
+ }
+ $foundgw = true;
+ } else if ($gateway['ipprotocol'] == "inet6" && (is_ipaddrv6($gateway['gateway']) || $gateway['gateway'] == "dynamic6")) {
+ if ($gateway['gateway'] == "dynamic6")
+ $gateway['gateway'] = get_interface_gateway_v6($gateway['interface']);
+ if (!empty($gateway['interface'])) {
+ $defaultifv6 = get_real_interface($gateway['interface']);
+ if ($defaultifv6)
+ @file_put_contents("{$g['tmp_path']}/{$defaultifv6}_defaultgwv6", $gateway['gateway']);
+ }
+ $foundgwv6 = true;
}
- $foundgw = true;
- break;
}
- }
- foreach ($config['gateways']['gateway_item'] as $gateway) {
- if (isset($gateway['defaultgw']) && ((is_ipaddrv6($gateway['gateway'])) || ($gateway['gateway'] == "dynamic6"))) {
- if ($gateway['ipprotocol'] != "inet6")
- continue;
- if ($gateway['gateway'] == "dynamic6")
- $gateway['gateway'] = get_interface_gateway_v6($gateway['interface']);
- $gatewayipv6 = $gateway['gateway'];
- $interfacegwv6 = $gateway['interface'];
- if (!empty($interfacegwv6)) {
- $defaultifv6 = get_real_interface($gateway['interface']);
- if ($defaultifv6)
- @file_put_contents("{$g['tmp_path']}/{$defaultifv6}_defaultgwv6", $gatewayipv6);
- }
- $foundgwv6 = true;
+ if ($foundgw === true && $foundgwv6 === true)
break;
- }
}
}
if ($foundgw == false) {
@@ -423,7 +414,7 @@ function system_routing_configure($interface = "") {
}
$dont_add_route = false;
/* if OLSRD is enabled, allow WAN to house DHCP. */
- if($config['installedpackages']['olsrd']) {
+ if (is_array($config['installedpackages']['olsrd'])) {
foreach($config['installedpackages']['olsrd']['config'] as $olsrd) {
if(($olsrd['enabledyngw'] == "on") && ($olsrd['enable'] == "on")) {
$dont_add_route = true;
OpenPOWER on IntegriCloud