From c0f5182ce0b30aa61b02df3dbe3d45fcda0961db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=E7i?= Date: Tue, 9 Mar 2010 20:34:51 +0000 Subject: Correctly configure the default route addition when interfaces are configured for pppoe/pptp. Handle in system routing configure dynamic interfaces. Also when chaning or configuring the defaultgw reconfigure the underlying interface, this helps when this interfaces are dynamics one. --- etc/inc/interfaces.inc | 30 ++++++++++++++++++++++++++++-- etc/inc/system.inc | 12 ++++++++++-- usr/local/www/system_gateways_edit.php | 5 ++++- 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 .= << "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; -- cgit v1.1