From b43c7f2c72e04e54b8c081a756a19ba14488e28a Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 20 Sep 2016 16:22:11 +0100 Subject: [PATCH] fix: This removes stale entries in the mac_ipv4 table (#4444) --- includes/discovery/arp-table.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/discovery/arp-table.inc.php b/includes/discovery/arp-table.inc.php index 7bce3b623b..7240fd3a5c 100644 --- a/includes/discovery/arp-table.inc.php +++ b/includes/discovery/arp-table.inc.php @@ -41,7 +41,7 @@ foreach ($vrfs_lite_cisco as $vrf) { $clean_mac = $m_a.$m_b.$m_c.$m_d.$m_e.$m_f; $mac_table[$if][$mac]['cleanmac'] = $clean_mac; $port_id = $interface['port_id']; - $mac_table[$port_id][$clean_mac] = 1; + $mac_table[$port_id][$clean_mac][$ip] = 1; if (dbFetchCell('SELECT COUNT(*) from ipv4_mac WHERE port_id = ? AND ipv4_address = ?', array($interface['port_id'], $ip))) { // Commented below, no longer needed but leaving for reference. @@ -74,8 +74,9 @@ foreach ($vrfs_lite_cisco as $vrf) { foreach (dbFetchRows($sql) as $entry) { $entry_mac = $entry['mac_address']; $entry_if = $entry['port_id']; - if (!$mac_table[$entry_if][$entry_mac]) { - dbDelete('ipv4_mac', '`port_id` = ? AND `mac_address` = ?', array($entry_if, $entry_mac)); + $entry_ip = $entry['ipv4_address']; + if (!$mac_table[$entry_if][$entry_mac][$entry_ip]) { + dbDelete('ipv4_mac', '`port_id` = ? AND `mac_address` = ? AND `ipv4_address` = ? ', array($entry_if, $entry_mac, $entry_ip)); d_echo("Removing MAC $entry_mac from interface ".$interface['ifName']); echo '-';