summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/gwlb.inc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-10-18 11:01:47 -0200
committerRenato Botelho <renato@netgate.com>2016-10-18 11:01:47 -0200
commit94bd7fb3a52e375dcd25c416e36389f96060a8fd (patch)
treed0f3eee6ef938b6c45721aa628393d215a2908a0 /src/etc/inc/gwlb.inc
parent6172f3dedbf1fbcc0991f1ab5ec3b1636a4eb7c7 (diff)
downloadpfsense-94bd7fb3a52e375dcd25c416e36389f96060a8fd.zip
pfsense-94bd7fb3a52e375dcd25c416e36389f96060a8fd.tar.gz
Fix #6828
Until 2.3.x pfSense carried a patch that changed the behavior of 'route change' command, making it add the route when it fails to change. On 2.4 this patch was removed and will not be added back. This change adjust PHP code to deal with route add / change and make it work without the patch
Diffstat (limited to 'src/etc/inc/gwlb.inc')
-rw-r--r--src/etc/inc/gwlb.inc18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc
index e31092a..6a5378e 100644
--- a/src/etc/inc/gwlb.inc
+++ b/src/etc/inc/gwlb.inc
@@ -223,12 +223,11 @@ function setup_gateways_monitor() {
*/
if (is_ipaddrv4($gateway['gateway']) && $gateway['monitor'] != $gateway['gateway']) {
log_error(sprintf(gettext('Removing static route for monitor %1$s and adding a new route through %2$s'), $gateway['monitor'], $gateway['gateway']));
+ $route_to = "-host {$gateway['monitor']}";
if (interface_isppp_type($gateway['friendlyiface'])) {
- mwexec("/sbin/route change -host " . escapeshellarg($gateway['monitor']) .
- " -iface " . escapeshellarg($gateway['interface']), true);
+ route_add_or_change("{$route_to} -iface {$gateway['interface']}");
} else {
- mwexec("/sbin/route change -host " . escapeshellarg($gateway['monitor']) .
- " " . escapeshellarg($gateway['gateway']), true);
+ route_add_or_change("{$route_to} {$gateway['gateway']}");
}
pfSense_kill_states("0.0.0.0/0", $gateway['monitor'], $gateway['interface'], "icmp");
@@ -265,12 +264,11 @@ function setup_gateways_monitor() {
*/
if ($gateway['gateway'] != $gateway['monitor']) {
log_error(sprintf(gettext('Removing static route for monitor %1$s and adding a new route through %2$s'), $gateway['monitor'], $gateway['gateway']));
+ $route_to = "-host -inet6 {$gateway['monitor']}";
if (interface_isppp_type($gateway['friendlyiface'])) {
- mwexec("/sbin/route change -host -inet6 " . escapeshellarg($gateway['monitor']) .
- " -iface " . escapeshellarg($gateway['interface']), true);
+ route_add_or_change("{$route_to} -iface {$gateway['interface']}");
} else {
- mwexec("/sbin/route change -host -inet6 " . escapeshellarg($gateway['monitor']) .
- " " . escapeshellarg($gateway['gateway']), true);
+ route_add_or_change("{$route_to} {$gateway['gateway']}");
}
pfSense_kill_states("::0.0.0.0/0", $gateway['monitor'], $gateway['interface'], "icmpv6");
@@ -842,7 +840,7 @@ function fixup_default_gateway($ipprotocol, $gateways_status, $gateways_arr) {
} else {
$inetfamily = "-inet";
}
- mwexec("/sbin/route change {$inetfamily} default {$gateways_arr[$upgw]['gateway']}");
+ route_add_or_change("{$inetfamily} default {$gateways_arr[$upgw]['gateway']}");
}
} else if (!empty($dfltgwname)) {
$defaultgw = trim(exec("/sbin/route -n get -{$ipprotocol} default | /usr/bin/awk '/gateway:/ {print $2}'"), " \n");
@@ -861,7 +859,7 @@ function fixup_default_gateway($ipprotocol, $gateways_status, $gateways_arr) {
}
}
if ($defaultgw != $gateways_arr[$dfltgwname]['gateway']) {
- mwexec("/sbin/route change -{$ipprotocol} default {$gateways_arr[$dfltgwname]['gateway']}");
+ route_add_or_change("-{$ipprotocol} default {$gateways_arr[$dfltgwname]['gateway']}");
}
}
}
OpenPOWER on IntegriCloud