summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2014-11-10 16:03:43 (GMT)
committerErmal <eri@pfsense.org>2014-11-10 16:03:43 (GMT)
commit894a0159a011a68df51f3d58df638b7db484899c (patch)
tree5ca4a45505aebbd65916924f361c206d488ca7c7
parentd3c269d3933f71a24f60375f56fdf67a7194ace1 (diff)
downloadunivnautes-894a0159a011a68df51f3d58df638b7db484899c.zip
univnautes-894a0159a011a68df51f3d58df638b7db484899c.tar.gz
univnautes-894a0159a011a68df51f3d58df638b7db484899c.tar.bz2
Tighten checks here to avoid overriding the default gw with garbage
-rw-r--r--etc/inc/gwlb.inc16
1 files changed, 8 insertions, 8 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index c2c61d0..e0d4c2d 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -732,7 +732,8 @@ function fixup_default_gateway($ipprotocol, $gateways_status, $gateways_arr) {
* NOTE: The code below is meant to replace the default gateway when it goes down.
* This facilitates services running on pfSense itself and are not handled by a PBR to continue working.
*/
- $upgw = "";
+ $upgw = '';
+ $dfltgwname = '';
$dfltgwdown = false;
$dfltgwfound = false;
foreach ($gateways_arr as $gwname => $gwsttng) {
@@ -766,15 +767,14 @@ function fixup_default_gateway($ipprotocol, $gateways_status, $gateways_arr) {
}
mwexec("/sbin/route change {$inetfamily} default {$gateways_arr[$upgw]['gateway']}");
}
- } else {
+ } else if (!empty($dftgwname)) {
$defaultgw = trim(exec("/sbin/route -n get -{$ipprotocol} default | /usr/bin/awk '/gateway:/ {print $2}'"), " \n");
- if(is_ipaddrv6($gateways_arr[$dfltgwname]['gateway'])) {
- $inetfamily = "-inet6";
- } else {
- $inetfamily = "-inet";
- }
+ if ($ipprotocol == 'inet6' && !is_ipaddrv6($gateways_arr[$dfltgwname]['gateway']))
+ return;
+ if ($ipprotocol == 'inet' && !is_ipaddrv4($gateways_arr[$dfltgwname]['gateway']))
+ return;
if ($defaultgw != $gateways_arr[$dfltgwname]['gateway'])
- mwexec("/sbin/route change {$inetfamily} default {$gateways_arr[$dfltgwname]['gateway']}");
+ mwexec("/sbin/route change -{$ipprotocol} default {$gateways_arr[$dfltgwname]['gateway']}");
}
}