Skip to content

Commit

Permalink
interfaces: do not reach for tracked interfaces during rc.newwanipv6
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fichtner committed May 16, 2023
1 parent 766f1f0 commit bde5246
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
2 changes: 1 addition & 1 deletion src/etc/rc.newwanip
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
/*
Expand Down
2 changes: 1 addition & 1 deletion src/etc/rc.newwanipv6
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit bde5246

Please sign in to comment.