mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
interfaces: refactor previous slightly
This commit is contained in:
parent
f8d0ca5e1c
commit
f4e13c2a6a
@ -82,6 +82,7 @@ function vxlan_configure_do($verbose = false, $device = null)
|
||||
// (re)configure vxlan devices
|
||||
foreach ($vxlans as $vxlan) {
|
||||
$device_name = "vxlan{$vxlan->deviceId}";
|
||||
$isChanged = false;
|
||||
|
||||
if ($device !== null && $device != $device_name) {
|
||||
$configured_devices[] = $device_name;
|
||||
@ -101,7 +102,6 @@ function vxlan_configure_do($verbose = false, $device = null)
|
||||
mwexecf('/sbin/ifconfig vxlan create name %s', array($device_name));
|
||||
$isChanged = true;
|
||||
} else {
|
||||
$isChanged = false;
|
||||
$current_settings['vxlanid'] = $interfaces_details[$device_name]['vxlan']['vni'];
|
||||
foreach (['local', 'remote', 'group'] as $target) {
|
||||
if (!empty($interfaces_details[$device_name]['vxlan'][$target])) {
|
||||
@ -111,6 +111,7 @@ function vxlan_configure_do($verbose = false, $device = null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// gather settings, detect changes
|
||||
$ifcnfcmd = '/sbin/ifconfig %s';
|
||||
$ifcnfcmdp = array($device_name);
|
||||
@ -135,13 +136,13 @@ function vxlan_configure_do($verbose = false, $device = null)
|
||||
$ifcnfcmdp[] = $value;
|
||||
}
|
||||
if (isset($current_settings[$param]) && $current_settings[$param] != $value) {
|
||||
// need to bring existing down to apply changes
|
||||
mwexecf('/sbin/ifconfig %s down', [$device_name]);
|
||||
$isChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// The device will be busy, first bring it down, apply changes, then bring it back up
|
||||
if ($isChanged) {
|
||||
mwexecf('/sbin/ifconfig %s down', [$device_name]);
|
||||
mwexecf($ifcnfcmd . ' up', $ifcnfcmdp);
|
||||
$changed_devices[] = $device_name;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user