summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/interfaces.inc30
-rw-r--r--etc/inc/system.inc12
-rwxr-xr-xusr/local/www/system_gateways_edit.php5
3 files changed, 42 insertions, 5 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index d86b20e..c31e259 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -2034,7 +2034,20 @@ EOD;
set iface name {$realif}
EOD;
- if ($interface == "wan")
+ $setdefaultgw = false;
+ $founddefaultgw = false;
+ if (is_array($config['gateways']['gateway_item'])) {
+ foreach($config['gateways']['gateway_item'] as $gateway) {
+ if($interface == $gateway['interface'] && isset($gateway['defaultgw'])) {
+ $setdefaultgw = true;
+ break;
+ } else if (isset($gateway['defaultgw'])) {
+ $founddefaultgw = true;
+ break;
+ }
+ }
+ }
+ if (($interface == "wan" && $founddefaultgw == false) || $setdefaultgw == true)
$mpdconf .= <<<EOD
set iface route default
@@ -2183,7 +2196,20 @@ EOD;
set iface name {$realif}
EOD;
- if ($interface == "wan")
+ $setdefaultgw = false;
+ $founddefaultgw = false;
+ if (is_array($config['gateways']['gateway_item'])) {
+ foreach($config['gateways']['gateway_item'] as $gateway) {
+ if($interface == $gateway['interface'] && isset($gateway['defaultgw'])) {
+ $setdefaultgw = true;
+ break;
+ } else if (isset($gateway['defaultgw'])) {
+ $founddefaultgw = true;
+ break;
+ }
+ }
+ }
+ if (($interface == "wan" && $founddefaultgw == false) || $setdefaultgw == true)
$mpdconf .= <<<EOD
set iface route default
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 4f194be..c5329f2 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -314,6 +314,10 @@ function system_routing_configure() {
if(isset($gateway['defaultgw'])) {
$gatewayip = $gateway['gateway'];
$interfacegw = $gateway['interface'];
+ /* This handles the case where a dynamic gateway is choosen as default. */
+ if (!is_ipaddr($gatewayip))
+ $gatewayip = get_interface_gateway($interfacegw);
+ break;
}
}
if(($interfacegw <> "bgpd") && (is_ipaddr($gatewayip))) {
@@ -353,13 +357,17 @@ function system_routing_configure() {
if($rtent['gateway'] == $gateway['name']) {
$gatewayip = $gateway['gateway'];
$interfacegw = $gateway['interface'];
+ /* This handles the case where a dynamic gateway is choosen. */
+ if (!is_ipaddr($gatewayip))
+ $gatewayip = get_interface_gateway($interfacegw);
+ break;
}
}
}
- if((is_ipaddr($rtent['gateway'])) && ($gatewayip == "")) {
+ if((is_ipaddr($rtent['gateway'])) && empty($gatewayip)) {
$gatewayip = $rtent['gateway'];
$interfacegw = $rtent['interface'];
- }
+ }
if((isset($rtent['interfacegateway'])) && (! is_ipaddr($gatewayip))) {
mwexec("/sbin/route add " . escapeshellarg($rtent['network']) .
" -iface " . escapeshellarg(convert_friendly_interface_to_real_interface_name($interfacegw)));
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php
index b562579..fe9c4f9 100755
--- a/usr/local/www/system_gateways_edit.php
+++ b/usr/local/www/system_gateways_edit.php
@@ -164,6 +164,7 @@ if ($_POST) {
/* Manual gateways are handled differently */
/* rebuild the array with the manual entries only */
+ $reloadif = false;
$gateway = array();
$gateway['interface'] = $_POST['interface'];
$gateway['name'] = $_POST['name'];
@@ -181,6 +182,7 @@ if ($_POST) {
$i++;
}
$gateway['defaultgw'] = true;
+ $reloadif = true;
} else {
unset($gateway['defaultgw']);
}
@@ -200,7 +202,8 @@ if ($_POST) {
if($_REQUEST['isAjax']) {
echo $_POST['name'];
exit;
- }
+ } else if ($reloadif == true)
+ interface_configure($_POST['interface']);
header("Location: system_gateways.php");
exit;
OpenPOWER on IntegriCloud