interfaces: do not reach for tracked interfaces during rc.newwanipv6

Shift away from get_interface_ip() as we don't need to handle VIPs or
plain addresses here and make sure that we do not reach for tracked
interface addresses.  This will make link-local end up as the current
IP being cached, but that's fine since previously we fixed the shifting
prefix detection during RENEW/REBIND and that looks to be working.

Eventually we need to rename "prefix" variant to "primary" as that is
what it is doing and the current "primary" one is more of a listen
IP helper in case the WAN does not have a routable address.  But deal
with that later to avoid overcomplicating the current patch.

PR: https://forum.opnsense.org/index.php?topic=26832.0
This commit is contained in:
Franco Fichtner 2023-05-16 13:31:19 +02:00
parent 766f1f0c5a
commit bde52467de
3 changed files with 7 additions and 5 deletions

View File

@ -4362,11 +4362,12 @@ function interfaces_primary_address($interface, $ifconfig_details = null)
return [ $ifcfgip, $network, $subnetbits ];
}
function interfaces_primary_address6($interface, $ifconfig_details = null)
/* XXX rename "primary" to "routed" as that is what it is */
function interfaces_primary_address6($interface, $ifconfig_details = null, $allow_track = true)
{
$ifcfgipv6 = $networkv6 = $subnetbitsv6 = null;
if (interfaces_has_prefix_only($interface)) {
if (interfaces_has_prefix_only($interface) && $allow_track) {
/* extend the search scope for a non-NA mode to tracking interfaces */
$interface = array_merge([$interface], array_keys(link_interface_to_track6($interface)));
}
@ -4403,6 +4404,7 @@ function interfaces_scoped_address6($interface, $ifconfig_details = null)
return [ $ifcfgipv6, $networkv6, $subnetbitsv6 ];
}
/* XXX rename "prefix" to "primary" as that is what it is */
function interfaces_prefix_address6($interface, $ifconfig_details = null)
{
$ifcfgipv6 = $networkv6 = $subnetbitsv6 = null;
@ -4411,5 +4413,5 @@ function interfaces_prefix_address6($interface, $ifconfig_details = null)
return interfaces_scoped_address6($interface, $ifconfig_details);
}
return interfaces_primary_address6($interface, $ifconfig_details);
return interfaces_primary_address6($interface, $ifconfig_details, false);
}

View File

@ -62,7 +62,7 @@ if (!isset($config['interfaces'][$interface]['enable'])) {
system_resolver_configure();
$interface_descr = convert_friendly_interface_to_friendly_descr($interface);
$ip = get_interface_ip($interface);
list ($ip) = interfaces_primary_address($interface);
if (!is_ipaddr($ip)) {
/*

View File

@ -62,7 +62,7 @@ if (!isset($config['interfaces'][$interface]['enable'])) {
system_resolver_configure();
$interface_descr = convert_friendly_interface_to_friendly_descr($interface);
$ip = get_interface_ipv6($interface);
list ($ip) = interfaces_prefix_address6($interface);
if (!is_ipaddr($ip)) {
/* interface is not ready */