mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 01:24:38 +00:00
interfaces: improve banner address return
primary will move to tracking interfaces or pick up any SLAAC related address even though that is not being actively configured. Similar to the dashboard only print the scoped address without the need to do the logic in the caller. Maybe we could even return the assigned prefix here for clarity, but then the prefix isn't a reachable address.
This commit is contained in:
parent
6fb821666b
commit
85b223d00c
@ -4337,6 +4337,16 @@ function interfaces_addresses($interfaces, $as_subnet = false, $ifconfig_details
|
||||
return $result;
|
||||
}
|
||||
|
||||
function interfaces_has_prefix_only($interface)
|
||||
{
|
||||
$interfaces_a = config_read_array('interfaces');
|
||||
|
||||
return empty($interfaces_a[$interface]['adv_dhcp6_config_file_override']) &&
|
||||
((!empty($interfaces_a[$interface]['adv_dhcp6_config_advanced']) &&
|
||||
empty($interfaces_a[$interface]['adv_dhcp6_id_assoc_statement_address_enable'])) ||
|
||||
isset($interfaces_a[$interface]['dhcp6prefixonly']));
|
||||
}
|
||||
|
||||
function interfaces_primary_address($interface, $ifconfig_details = null)
|
||||
{
|
||||
$ifcfgip = $network = $subnetbits = null;
|
||||
@ -4366,14 +4376,7 @@ function interfaces_primary_address6($interface, $ifconfig_details = null)
|
||||
{
|
||||
$ifcfgipv6 = $networkv6 = $subnetbitsv6 = null;
|
||||
|
||||
$interfaces_a = config_read_array('interfaces');
|
||||
|
||||
if (
|
||||
empty($interfaces_a[$interface]['adv_dhcp6_config_file_override']) &&
|
||||
((!empty($interfaces_a[$interface]['adv_dhcp6_config_advanced']) &&
|
||||
empty($interfaces_a[$interface]['adv_dhcp6_id_assoc_statement_address_enable'])) ||
|
||||
isset($interfaces_a[$interface]['dhcp6prefixonly']))
|
||||
) {
|
||||
if (interfaces_has_prefix_only($interface)) {
|
||||
/* extend the search scope for a non-NA mode to tracking interfaces */
|
||||
$interface = array_merge([$interface], array_keys(link_interface_to_track6($interface)));
|
||||
}
|
||||
@ -4409,3 +4412,14 @@ function interfaces_scoped_address6($interface, $ifconfig_details = null)
|
||||
|
||||
return [ $ifcfgipv6, $networkv6, $subnetbitsv6 ];
|
||||
}
|
||||
|
||||
function interfaces_prefix_address6($interface, $ifconfig_details = null)
|
||||
{
|
||||
$ifcfgipv6 = $networkv6 = $subnetbitsv6 = null;
|
||||
|
||||
if (interfaces_has_prefix_only($interface)) {
|
||||
return interfaces_scoped_address6($interface, $ifconfig_details);
|
||||
}
|
||||
|
||||
return interfaces_primary_address6($interface, $ifconfig_details);
|
||||
}
|
||||
|
||||
@ -84,14 +84,12 @@ foreach ($iflist as $ifname => $ifcfg) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$realif = get_real_interface($ifname);
|
||||
$network = null;
|
||||
if (!empty($ifdetails[$realif]['ipv4'][0])) {
|
||||
$network = $ifdetails[$realif]['ipv4'][0]['ipaddr'] . "/" . $ifdetails[$realif]['ipv4'][0]['subnetbits'];
|
||||
}
|
||||
|
||||
list ($primary6,, $bits6) = interfaces_primary_address6($ifname, $ifdetails);
|
||||
list ($primary,, $bits) = interfaces_primary_address($ifname, $ifdetails);
|
||||
$network = "{$primary}/{$bits}";
|
||||
|
||||
list ($primary6,, $bits6) = interfaces_prefix_address6($ifname, $ifdetails);
|
||||
$network6 = "{$primary6}/{$bits6}";
|
||||
|
||||
$tobanner = "{$ifcfg['descr']} ({$realif})";
|
||||
@ -100,7 +98,7 @@ foreach ($iflist as $ifname => $ifcfg) {
|
||||
|
||||
$v6first = false;
|
||||
|
||||
if (!empty($network)) {
|
||||
if ($network != '/') {
|
||||
printf("v4%s: %s", $class, $network);
|
||||
} else {
|
||||
$v6first = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user