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.
This commit is contained in:
Adam Dawidowski 2022-07-10 11:49:53 +02:00 committed by Franco Fichtner
parent b8c6c18202
commit aa86b9d43d

View File

@ -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;
}
}