mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 10:04:41 +00:00
interfaces: undo restricting lookups to configured interfaces only
In practice call stack above get_interface_ip*() is too messy and this will likely break a number of lookups.
This commit is contained in:
parent
38efe9d9d6
commit
0c0a2fec3b
@ -4581,19 +4581,15 @@ function interfaces_primary_address($interface, $ifconfig_details = null)
|
||||
{
|
||||
$ifcfgip = $network = $subnetbits = null;
|
||||
|
||||
$interfaces_a = config_read_array('interfaces');
|
||||
|
||||
if (!empty($interfaces_a[$interface])) {
|
||||
foreach (interfaces_addresses($interface, false, $ifconfig_details) as $addr) {
|
||||
if ($addr['family'] != 'inet' || $addr['alias']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$network = gen_subnet($addr['address'], $addr['bits']) . "/{$addr['bits']}";
|
||||
$subnetbits = $addr['bits'];
|
||||
$ifcfgip = $addr['address'];
|
||||
break; /* all done */
|
||||
foreach (interfaces_addresses($interface, false, $ifconfig_details) as $addr) {
|
||||
if ($addr['family'] != 'inet' || $addr['alias']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$network = gen_subnet($addr['address'], $addr['bits']) . "/{$addr['bits']}";
|
||||
$subnetbits = $addr['bits'];
|
||||
$ifcfgip = $addr['address'];
|
||||
break; /* all done */
|
||||
}
|
||||
|
||||
return [ $ifcfgip, $network, $subnetbits ];
|
||||
@ -4605,22 +4601,20 @@ function interfaces_primary_address6($interface, $ifconfig_details = null)
|
||||
|
||||
$interfaces_a = config_read_array('interfaces');
|
||||
|
||||
if (!empty($interfaces_a[$interface])) {
|
||||
if (isset($interfaces_a[$interface]['dhcp6prefixonly'])) {
|
||||
/* extend the search scope for a viable GUA to tracking interfaces */
|
||||
$interface = array_merge([$interface], array_keys(link_interface_to_track6($interface)));
|
||||
if (isset($interfaces_a[$interface]['dhcp6prefixonly'])) {
|
||||
/* extend the search scope for a viable GUA to tracking interfaces */
|
||||
$interface = array_merge([$interface], array_keys(link_interface_to_track6($interface)));
|
||||
}
|
||||
|
||||
foreach (interfaces_addresses($interface, false, $ifconfig_details) as $addr) {
|
||||
if ($addr['family'] != 'inet6' || $addr['deprecated'] || $addr['tentative'] || $addr['alias'] || $addr['scope']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (interfaces_addresses($interface, false, $ifconfig_details) as $addr) {
|
||||
if ($addr['family'] != 'inet6' || $addr['deprecated'] || $addr['tentative'] || $addr['alias'] || $addr['scope']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$networkv6 = gen_subnetv6($addr['address'], $addr['bits']) . "/{$addr['bits']}";
|
||||
$subnetbitsv6 = $addr['bits'];
|
||||
$ifcfgipv6 = $addr['address'];
|
||||
break; /* all done */
|
||||
}
|
||||
$networkv6 = gen_subnetv6($addr['address'], $addr['bits']) . "/{$addr['bits']}";
|
||||
$subnetbitsv6 = $addr['bits'];
|
||||
$ifcfgipv6 = $addr['address'];
|
||||
break; /* all done */
|
||||
}
|
||||
|
||||
return [ $ifcfgipv6, $networkv6, $subnetbitsv6 ];
|
||||
@ -4630,19 +4624,15 @@ function interfaces_scoped_address6($interface, $ifconfig_details = null)
|
||||
{
|
||||
$ifcfgipv6 = $networkv6 = $subnetbitsv6 = null;
|
||||
|
||||
$interfaces_a = config_read_array('interfaces');
|
||||
|
||||
if (!empty($interfaces_a[$interface])) {
|
||||
foreach (interfaces_addresses($interface, false, $ifconfig_details) as $addr) {
|
||||
if ($addr['family'] != 'inet6' || $addr['deprecated'] || $addr['tentative'] || $addr['alias'] || $addr['scope']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$networkv6 = gen_subnetv6($addr['address'], $addr['bits']) . "/{$addr['bits']}";
|
||||
$subnetbitsv6 = $addr['bits'];
|
||||
$ifcfgipv6 = "{$addr['address']}%{$addr['name']}";
|
||||
break; /* all done */
|
||||
foreach (interfaces_addresses($interface, false, $ifconfig_details) as $addr) {
|
||||
if ($addr['family'] != 'inet6' || $addr['deprecated'] || $addr['tentative'] || $addr['alias'] || $addr['scope']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$networkv6 = gen_subnetv6($addr['address'], $addr['bits']) . "/{$addr['bits']}";
|
||||
$subnetbitsv6 = $addr['bits'];
|
||||
$ifcfgipv6 = "{$addr['address']}%{$addr['name']}";
|
||||
break; /* all done */
|
||||
}
|
||||
|
||||
return [ $ifcfgipv6, $networkv6, $subnetbitsv6 ];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user