From 090dd89aa1e9dc9c9c969d4efd97307f49c5fe5f Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 2 Feb 2021 14:39:14 +0100 Subject: [PATCH] interfaces: finally fix IPv6 misalignment in get_interfaces_info() Related to: https://github.com/opnsense/core/issues/4651 --- src/etc/inc/interfaces.inc | 22 ++++++++++++++-------- src/www/status_interfaces.php | 6 +++--- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 95e5be5f2..71f38711d 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -4149,10 +4149,21 @@ function get_interfaces_info() $ifinfo = array_merge($ifinfo, $all_intf_details[$ifinfo['if']]); } - /* XXX apparently we ignore a different IPv6 realif completely... */ + if (!empty($ifinfo['ipv4'])) { + $ifinfo['ipaddr'] = $ifinfo['ipv4'][0]['ipaddr']; + $ifinfo['subnet'] = $ifinfo['ipv4'][0]['subnetbits']; + } + + if (!empty($all_intf_details[$ifinfo['ifv6']]['ipv6'])) { + /* rewrite always as it can be a different interface */ + $ifinfo['ipv6'] = $all_intf_details[$ifinfo['ifv6']]['ipv6']; + } elseif ($ifinfo['if'] != !$ifinfo['ifv6']) { + /* clear on a mismatch to avoid wrong data here */ + $ifinfo['ipv6'] = []; + } + if (!empty($ifinfo['ipv6'])) { - /* XXX ... so avoid intermediate breakage by using IPv4 realif here */ - list ($primary6, $unused, $subnet6) = interfaces_primary_address6($ifdescr, $ifinfo['if'], $all_intf_details); + list ($primary6, $unused, $subnet6) = interfaces_primary_address6($ifdescr, $ifinfo['ifv6'], $all_intf_details); if (!empty($primary6)) { $ifinfo['ipaddrv6'] = $primary6; $ifinfo['subnetv6'] = $subnet6; @@ -4167,11 +4178,6 @@ function get_interfaces_info() } } - if (!empty($ifinfo['ipv4'])) { - $ifinfo['ipaddr'] = $ifinfo['ipv4'][0]['ipaddr']; - $ifinfo['subnet'] = $ifinfo['ipv4'][0]['subnetbits']; - } - /* XXX there are more magic files */ $aux = @file_get_contents("/tmp/{$ifinfo['ifv6']}_pdinfo"); if (!empty($aux)) { diff --git a/src/www/status_interfaces.php b/src/www/status_interfaces.php index c906409c8..2926ac5fd 100644 --- a/src/www/status_interfaces.php +++ b/src/www/status_interfaces.php @@ -309,14 +309,14 @@ include("head.inc"); endif; if (!empty($ifinfo['gateway'])): ?> - + - + /64 - +