From de7e37aa171583116e26fce39eb76f65ef6c4606 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 25 May 2018 07:57:22 +0200 Subject: [PATCH] interfaces: trust the GUI to do its job There is still a weird interaction between this code and get_real_interface as they both react to dhcp6usev4iface, but now this is more obvious and could help with refactors later on. The upside is that we do not have to adjust this for another IPv6 type that will gain IPv4 latch capability in the future. --- src/etc/inc/interfaces.inc | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 93c9edfbc..4a72bdc1f 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -4046,26 +4046,21 @@ function get_interface_ipv6($interface = 'wan') } } - /* - * NOTE: On the case when only the prefix is requested, - * the communication on WAN will be done over link-local. - */ - if (isset($config['interfaces'][$interface])) { - switch ($config['interfaces'][$interface]['ipaddr']) { - case 'pppoe': - case 'l2tp': - case 'pptp': - case 'ppp': - if (in_array($config['interfaces'][$interface]['ipaddrv6'], array('dhcp6', 'slaac', 'staticv6'))) { - $realif = get_real_interface($interface, 'inet6'); - } - break; - } - if (isset($config['interfaces'][$interface]['dhcp6prefixonly'])) { - $curip = find_interface_ipv6_ll($realif); - if ($curip && is_ipaddrv6($curip) && ($curip != "::")) { - return $curip; - } + if (isset($config['interfaces'][$interface]['dhcp6usev4iface'])) { + $realif = get_real_interface($interface, 'inet6'); + } + + if (isset($config['interfaces'][$interface]['dhcp6prefixonly'])) { + $curip = find_interface_ipv6_ll($realif); + if ($curip && is_ipaddrv6($curip) && ($curip != "::")) { + return $curip; + } else { + /* + * XXX This may have been an intended opt-out case earlier, + * but it looks wrong to assume prefix-only and then fall + * through to see if a different address is there. + */ + return null; } }