From bde52467de6f0e777a207d68a5a4f4eb20824d05 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 16 May 2023 13:31:19 +0200 Subject: [PATCH] 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 --- src/etc/inc/interfaces.inc | 8 +++++--- src/etc/rc.newwanip | 2 +- src/etc/rc.newwanipv6 | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 1d14086ba..e0fdf10d6 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -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); } diff --git a/src/etc/rc.newwanip b/src/etc/rc.newwanip index 5483b533c..992e0da65 100755 --- a/src/etc/rc.newwanip +++ b/src/etc/rc.newwanip @@ -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)) { /* diff --git a/src/etc/rc.newwanipv6 b/src/etc/rc.newwanipv6 index 32fe6edec..7e48e534d 100755 --- a/src/etc/rc.newwanipv6 +++ b/src/etc/rc.newwanipv6 @@ -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 */