mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
interfaces: refactor interface_parent_devices() to take device name instead
This simplifies the call a little and allows us to do better recursion away from config-based interfaces. We could just pass the device as the interface and it would work but then we pass it down twice and it's not very readable.
This commit is contained in:
parent
faffad558a
commit
fac8f85a51
@ -2341,7 +2341,7 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
|
||||
|
||||
/* XXX the parent lookup works for 'vlan' but misses final parent for 'qinq' */
|
||||
if (strstr($realhwif, 'vlan') || strstr($realhwif, 'qinq')) {
|
||||
$parent_realif = interface_parent_devices($interface)[0];
|
||||
$parent_realif = interface_parent_devices($realhwif)[0];
|
||||
$parent_details = $ifconfig_details[$parent_realif];
|
||||
$parent_mtu = $mtu;
|
||||
|
||||
@ -3435,27 +3435,21 @@ function get_ppp_parent($ifcfg_if)
|
||||
}
|
||||
|
||||
/* collect hardware device parents for VLAN, LAGG and bridges */
|
||||
function interface_parent_devices($interface)
|
||||
function interface_parent_devices($device)
|
||||
{
|
||||
$parents = [];
|
||||
|
||||
$realif = get_real_interface($interface);
|
||||
if (strstr($realif, 'pppoe')) {
|
||||
/* handle lookup mismatch */
|
||||
$realif = get_ppp_parent($realif);
|
||||
}
|
||||
|
||||
if (strstr($realif, 'vlan') || strstr($realif, 'qinq')) {
|
||||
if (strstr($device, 'vlan') || strstr($device, 'qinq')) {
|
||||
/* XXX maybe if we have a qinq type return both parents? */
|
||||
foreach (config_read_array('vlans', 'vlan') as $vlan) {
|
||||
if ($realif == $vlan['vlanif']) {
|
||||
if ($device == $vlan['vlanif']) {
|
||||
$parents[] = $vlan['if'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} elseif (strstr($realif, 'bridge')) {
|
||||
} elseif (strstr($device, 'bridge')) {
|
||||
foreach (config_read_array('bridges', 'bridged') as $bridge) {
|
||||
if ($realif == $bridge['bridgeif']) {
|
||||
if ($device == $bridge['bridgeif']) {
|
||||
foreach (explode(',', $bridge['members']) as $member) {
|
||||
/* bridge stores members as configured interfaces */
|
||||
$parents[] = get_real_interface($member);
|
||||
@ -3463,9 +3457,9 @@ function interface_parent_devices($interface)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} elseif (strstr($realif, 'lagg')) {
|
||||
} elseif (strstr($device, 'lagg')) {
|
||||
foreach (config_read_array('laggs', 'lagg') as $lagg) {
|
||||
if ($realif == $lagg['laggif']) {
|
||||
if ($device == $lagg['laggif']) {
|
||||
foreach (explode(',', $lagg['members']) as $member) {
|
||||
$parents[] = $member;
|
||||
}
|
||||
|
||||
@ -897,7 +897,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
|
||||
if (strstr($a_interfaces[$if]['if'], 'vlan') || strstr($a_interfaces[$if]['if'], 'qinq')) {
|
||||
list ($parentif) = interface_parent_devices($if);
|
||||
list ($parentif) = interface_parent_devices($a_interfaces[$if]['if']);
|
||||
$intf_details = legacy_interface_details($parentif);
|
||||
if ($intf_details['mtu'] < $pconfig['mtu']) {
|
||||
$input_errors[] = gettext("MTU of a VLAN should not be bigger than parent interface.");
|
||||
@ -908,7 +908,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
continue;
|
||||
}
|
||||
|
||||
list ($parentif) = interface_parent_devices($idx);
|
||||
list ($parentif) = interface_parent_devices($ifdata['if']);
|
||||
if ($parentif != $a_interfaces[$if]['if']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user