summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/config.lib.inc18
-rw-r--r--etc/inc/gwlb.inc24
-rwxr-xr-xusr/local/www/system_gateways.php9
-rwxr-xr-xusr/local/www/system_gateways_edit.php11
4 files changed, 53 insertions, 9 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index bbd6fec..ddcfd9b 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -384,14 +384,16 @@ function convert_config() {
/* special case upgrades */
/* fix every minute crontab bogons entry */
- $cron_item_count = count($config['cron']['item']);
- for($x=0; $x<$cron_item_count; $x++) {
- if(stristr($config['cron']['item'][$x]['command'], "rc.update_bogons.sh")) {
- if($config['cron']['item'][$x]['hour'] == "*" ) {
- $config['cron']['item'][$x]['hour'] = "3";
- write_config(gettext("Updated bogon update frequency to 3am"));
- log_error(gettext("Updated bogon update frequency to 3am"));
- }
+ if (is_array($config['cron'])) {
+ $cron_item_count = count($config['cron']['item']);
+ for($x=0; $x<$cron_item_count; $x++) {
+ if(stristr($config['cron']['item'][$x]['command'], "rc.update_bogons.sh")) {
+ if($config['cron']['item'][$x]['hour'] == "*" ) {
+ $config['cron']['item'][$x]['hour'] = "3";
+ write_config(gettext("Updated bogon update frequency to 3am"));
+ log_error(gettext("Updated bogon update frequency to 3am"));
+ }
+ }
}
}
if ($config['version'] == $g['latest_config'])
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index 1adc751..e61d8da 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -162,6 +162,18 @@ EOD;
$gwifip = find_interface_ip($gateway['interface'], true);
if (!is_ipaddrv4($gwifip))
continue; //Skip this target
+
+ /*
+ * If the gateway is the same as the monitor we do not add a
+ * route as this will break the routing table.
+ * Add static routes for each gateway with their monitor IP
+ * not strictly necessary but is a added level of protection.
+ */
+ if (is_ipaddrv4($gateway['gateway']) && $gateway['monitor'] != $gateway['gateway']) {
+ log_error("Removing static route for monitor {$gateway['monitor']} and adding a new route through {$gateway['gateway']}");
+ mwexec("/sbin/route change -host " . escapeshellarg($gateway['monitor']) .
+ " " . escapeshellarg($gateway['gateway']), true);
+ }
} else if (is_ipaddrv6($gateway['gateway'])) {
/* link locals really need a different src ip */
if(is_linklocal($gateway['gateway'])) {
@@ -173,6 +185,18 @@ EOD;
$gateway['monitor'] .= "%{$gateway['interface']}";
if (!is_ipaddrv6($gwifip))
continue; //Skip this target
+
+ /*
+ * If the gateway is the same as the monitor we do not add a
+ * route as this will break the routing table.
+ * Add static routes for each gateway with their monitor IP
+ * not strictly necessary but is a added level of protection.
+ */
+ if (is_ipaddrv6($gateway['gateway']) && $gateway['monitor'] != $gateway['gateway']) {
+ log_error("Removing static route for monitor {$gateway['monitor']} and adding a new route through {$gateway['gateway']}");
+ mwexec("/sbin/route change -host -inet6 " . escapeshellarg($gateway['monitor']) .
+ " " . escapeshellarg($gateway['gateway']), true);
+ }
} else
continue;
diff --git a/usr/local/www/system_gateways.php b/usr/local/www/system_gateways.php
index 016ed45..5fdec7f 100755
--- a/usr/local/www/system_gateways.php
+++ b/usr/local/www/system_gateways.php
@@ -104,6 +104,15 @@ if ($_GET['act'] == "del") {
}
}
if ($remove == true) {
+ /* NOTE: Cleanup static routes for the monitor ip if any */
+ if (!empty($a_gateways[$_GET['id']]['monitor']) && $a_gateways[$_GET['id']]['monitor'] != "dynamic" && is_ipaddr($a_gateways[$_GET['id']]['monitor']) &&
+ $a_gateways[$_GET['id']]['monitor'] != $a_gateways[$_GET['id']]['monitor'] && $a_gateways[$_GET['id']]['gateway'] != $a_gateways[$_GET['id']]['monitor']) {
+ if (is_ipaddrv4($a_gateways[$_GET['id']]['monitor']))
+ mwexec("/sbin/route delete " . escapeshellarg($a_gateways[$_GET['id']]['monitor']));
+ else
+ mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateways[$_GET['id']]['monitor']));
+ }
+
if ($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway'] == $a_gateways[$_GET['id']]['name'])
unset($config['interfaces'][$a_gateways[$_GET['id']]['friendlyiface']]['gateway']);
$changedesc .= "removed gateway {$realid}";
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php
index 417184c..7abd1f4 100755
--- a/usr/local/www/system_gateways_edit.php
+++ b/usr/local/www/system_gateways_edit.php
@@ -384,8 +384,17 @@ if ($_POST) {
$gateway['descr'] = $_POST['descr'];
if ($_POST['monitor_disable'] == "yes")
$gateway['monitor_disable'] = true;
- else if (is_ipaddr($_POST['monitor']))
+ else if (is_ipaddr($_POST['monitor'])) {
+ /* NOTE: If monitor ip is changed need to cleanup the old static route */
+ if ($_POST['monitor'] != "dynamic" && !empty($a_gateway_item[$id]) && is_ipaddr($a_gateway_item[$id]['monitor']) &&
+ $_POST['monitor'] != $a_gateway_item[$id]['monitor'] && $gateway['gateway'] != $a_gateway_item[$id]['monitor']) {
+ if (is_ipaddrv4($a_gateway_item[$id]['monitor']))
+ mwexec("/sbin/route delete " . escapeshellarg($a_gateway_item[$id]['monitor']));
+ else
+ mwexec("/sbin/route delete -inet6 " . escapeshellarg($a_gateway_item[$id]['monitor']));
+ }
$gateway['monitor'] = $_POST['monitor'];
+ }
if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
$i = 0;
OpenPOWER on IntegriCloud