From 97e6ec0974fc8d5a112e5db3df30f3f864e619b7 Mon Sep 17 00:00:00 2001 From: Luiz Souza Date: Wed, 24 Jan 2018 13:39:59 -0600 Subject: [PATCH] Fixes a bug in primary DHCPD host detection for failover. Properly detect the master host based on CARP skew at setup time when used with HA. --- src/etc/inc/services.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index f62c25dae2..9617fe9b97 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -593,9 +593,14 @@ EOD; $skew = 110; if (is_array($config['virtualip']['vip'])) { foreach ($config['virtualip']['vip'] as $vipent) { + if ($vipent['mode'] != 'carp') { + continue; + } if ($vipent['interface'] == $dhcpif) { - $carp_nw = gen_subnet($vipent['subnet'], $vipent['subnet_bits']); - if (ip_in_subnet($dhcpifconf['failover_peerip'], "{$carp_nw}/{$vipent['subnet_bits']}")) { + $carp_nw = gen_subnet($config['interfaces'][$dhcpif]['ipaddr'], + $config['interfaces'][$dhcpif]['subnet']); + $carp_nw .= "/{$config['interfaces'][$dhcpif]['subnet']}"; + if (ip_in_subnet($dhcpifconf['failover_peerip'], $carp_nw)) { /* this is the interface! */ if (is_numeric($vipent['advskew']) && (intval($vipent['advskew']) < 20)) { $skew = 0;