From aa86b9d43d55c3f03d52d8901b741bfb6d91da1a Mon Sep 17 00:00:00 2001 From: Adam Dawidowski Date: Sun, 10 Jul 2022 11:49:53 +0200 Subject: [PATCH] interfaces: fix "Allow service binding" for multiple aliases per interface When using multiple aliases per interface, disabling binding on one could potentially disable binding for other aliases on the same interface, depending on the order of the VIPs in the config. The 'alias' setting was evaluated regardless of whether the subnet matched, so if a previous VIP for a matching interface had matched on subnet, the current VIP's 'bind' setting would be applied to the interface address even though the current VIP's subnet didn't match. --- src/etc/inc/interfaces.inc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 917561278..03283a276 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -4322,18 +4322,26 @@ function interfaces_addresses($interfaces, $as_subnet = false, $ifconfig_details continue; } + $match = false; + if ($info['family'] == 'inet' && strpos($vip['subnet'], ':') === false) { - $info['alias'] = $info['alias'] || $vip['subnet'] == $info['address']; + $match = $vip['subnet'] == $info['address']; } elseif ($info['family'] == 'inet6' && strpos($vip['subnet'], ':') !== false) { /* * Since we do not know what subnet value was given by user * uncompress/compress to match correctly compressed system * value. */ - $info['alias'] = $info['alias'] || Net_IPv6::compress(Net_IPv6::uncompress($vip['subnet'])) == $info['address']; + $match = Net_IPv6::compress(Net_IPv6::uncompress($vip['subnet'])) == $info['address']; } - if ($info['alias'] && !empty($vip['nobind'])) { + if (!$match) { + continue; + } + + $info['alias'] = true; + + if (!empty($vip['nobind'])) { $info['bind'] = false; } }