From 85d2657ce68e74b4375e5acf4edd8e40251ec087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20R=C3=B6nnvall?= Date: Sun, 3 Feb 2019 09:07:57 +0100 Subject: [PATCH 1/2] Fix behaviour of determining dhcp primary/secondary When there is more than one CARP address per interface with different skews, check only the first CARP if and skew in order to determine primary. This prevents a misconfiguration where both hosts are configured as dhcp primary. --- src/etc/inc/services.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 045d4c58b..e331710b5 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -533,8 +533,8 @@ EOD; /* this is the interface! */ if (is_numeric($vipent['advskew']) && (intval($vipent['advskew']) < 20)) { $skew = 0; - break; } + break; } } } From f2be8ad1b635c5c8c563eadf7580eca75c3953d9 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 8 Feb 2019 16:15:48 +0100 Subject: [PATCH 2/2] fix failover_peerip logic in services_dhcpdv4_configure() --- src/etc/inc/services.inc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index e331710b5..927d4df97 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -524,7 +524,7 @@ EOD; * yep, failover peer is defined. * does it match up to a defined vip? */ - $skew = 110; + $failover_primary=false; if (!empty($config['virtualip']['vip'])) { foreach ($config['virtualip']['vip'] as $vipent) { if ($vipent['interface'] == $dhcpif) { @@ -532,7 +532,7 @@ EOD; if (ip_in_subnet($dhcpifconf['failover_peerip'], "{$carp_nw}/{$vipent['subnet_bits']}")) { /* this is the interface! */ if (is_numeric($vipent['advskew']) && (intval($vipent['advskew']) < 20)) { - $skew = 0; + $failover_primary=true; } break; } @@ -542,16 +542,16 @@ EOD; log_error('Warning! DHCP Failover setup and no CARP virtual IPs defined!'); } $dhcpdconf_pri = ""; - if ($skew > 10) { - $type = "secondary"; - $my_port = "520"; - $peer_port = "519"; - } else { + if ($failover_primary) { $my_port = "519"; $peer_port = "520"; $type = "primary"; $dhcpdconf_pri = "split 128;\n"; $dhcpdconf_pri .= " mclt 600;\n"; + } else { + $type = "secondary"; + $my_port = "520"; + $peer_port = "519"; } if (is_ipaddrv4($intip)) {