interfaces: finally fix IPv6 misalignment in get_interfaces_info()

Related to: https://github.com/opnsense/core/issues/4651
This commit is contained in:
Franco Fichtner 2021-02-02 14:39:14 +01:00
parent 87c00de215
commit 090dd89aa1
2 changed files with 17 additions and 11 deletions

View File

@ -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)) {

View File

@ -309,14 +309,14 @@ include("head.inc");
endif;
if (!empty($ifinfo['gateway'])): ?>
<tr>
<td><?= gettext("Gateway IPv4") ?></td>
<td><?= gettext('IPv4 gateway') ?></td>
<td><?= htmlspecialchars($config['interfaces'][$ifdescr]['gateway']) ?> <?= $ifinfo['gateway'] ?></td>
</tr>
<?php
endif;
if (!empty($ifinfo['linklocal'])): ?>
<tr>
<td><?= gettext("IPv6 Link Local") ?></td>
<td><?= gettext("IPv6 link-local") ?></td>
<td><?= $ifinfo['linklocal'] ?>/64
</tr>
<?php
@ -344,7 +344,7 @@ include("head.inc");
<?php endif ?>
<?php if (!empty($ifinfo['gatewayv6'])): ?>
<tr>
<td><?= gettext("Gateway IPv6") ?></td>
<td><?= gettext('IPv6 gateway') ?></td>
<td><?= htmlspecialchars($config['interfaces'][$ifdescr]['gatewayv6']) ?> <?= $ifinfo['gatewayv6'] ?></td>
</tr>
<?php