mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Prevent spurious MAC changes on multi-interface devices (#14671)
This commit is contained in:
@@ -36,9 +36,6 @@ foreach (DeviceCache::getPrimary()->getVrfContexts() as $context_name) {
|
||||
$sql = 'SELECT * from `ipv4_mac` WHERE `device_id`=? AND `context_name`=?';
|
||||
$existing_data = dbFetchRows($sql, [$device['device_id'], $context_name]);
|
||||
|
||||
$ipv4_addresses = array_map(function ($data) {
|
||||
return $data['ipv4_address'];
|
||||
}, $existing_data);
|
||||
$arp_table = [];
|
||||
$insert_data = [];
|
||||
foreach ($arp_data as $ifIndex => $data) {
|
||||
@@ -59,7 +56,14 @@ foreach (DeviceCache::getPrimary()->getVrfContexts() as $context_name) {
|
||||
$mac = implode(array_map('zeropad', explode(':', $raw_mac)));
|
||||
$arp_table[$port_id][$ip] = $mac;
|
||||
|
||||
$index = array_search($ip, $ipv4_addresses);
|
||||
$index = false;
|
||||
foreach ($existing_data as $existing_key => $existing_value) {
|
||||
if ($existing_value['ipv4_address'] == $ip && $existing_value['port_id'] == $port_id) {
|
||||
$index = $existing_key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($index !== false) {
|
||||
$old_mac = $existing_data[$index]['mac_address'];
|
||||
if ($mac != $old_mac && $mac != '') {
|
||||
|
Reference in New Issue
Block a user