Skip to content

Commit

Permalink
interfaces: ignore ULAs for primary IPv6 detection #6939
Browse files Browse the repository at this point in the history
(cherry picked from commit 89ee410)
  • Loading branch information
fichtner committed Oct 29, 2023
1 parent 53178c1 commit a40dd50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4414,7 +4414,7 @@ function _interfaces_primary_address6($interface, $ifconfig_details = null, $all

if ($link_local && !$addr['scope']) {
continue;
} elseif (!$link_local && $addr['scope']) {
} elseif (!$link_local && ($addr['scope'] || is_uniquelocal($addr['address']))) {
continue;
}

Expand Down
6 changes: 6 additions & 0 deletions src/etc/inc/util.inc
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,12 @@ function is_linklocal($ipaddr)
return !!preg_match('/^fe[89ab][0-9a-f]:/i', $ipaddr ?? '');
}

/* returns true if $ipaddr is a valid uniquelocal address (inside fd00::/8) */
function is_uniquelocal($ipaddr)
{
return !!preg_match('/^fd[0-9a-f][0-9a-f]:/i', $ipaddr ?? '');
}

/* returns true if $ipaddr is a valid literal IPv6 address */
function is_literalipaddrv6($ipaddr)
{
Expand Down

0 comments on commit a40dd50

Please sign in to comment.