Repository navigation
fix(scanners): guard SNMP walk lookups that can disagree (#474) - #475
Merged
Merged
Conversation
Scanners walk each SNMP table column separately and then join the results by index. An FDB entry learned or aged out between walks is present in one column and missing from another, which raised "Undefined array key" warnings on every collection. * Extreme: skip FDB entries without a port, fall back to the VLAN ifIndex at the end of the EXOS index when the VLAN walk misses the entry, and skip partial ARP / IP FDB rows in both ExtremeWare and EXOS modes. * Shared helpers: guard the standard ARP table join and the dot1d wireless / dot1q port counts. * 3Com, Aruba CX, Cabletron, Cisco, Dell, D-Link, Enterasys, Enterasys N7, Foundry, H3C, HP, HP NGI, Juniper, Linux, Nortel, Nortel NG, TP-Link and Trendnet: guard interface, VLAN and MAC lookups keyed by a different walk. * Foundry and Enterasys: initialise the interface table before it is built rather than after; the reset added in #377 emptied it, so trunk counts were always zero and no user ports were found. * Foundry: key the active port count by ifIndex; the old counter only advanced on matching ports and checked the wrong interface. * Nortel NG: read ifAlias from the interface row, not a non-existent 'ifAlias' row. Fixes #474 Signed-off-by: TheWitness <thewitness@cacti.net> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The Foundry MAC loop double-counts interfaces already included in ports_active, inflating active-port totals and requiring a counter reset plus a regression assertion.
1 open issue
What changed in this PR
This PR addresses #474 by making Device Tracking’s SNMP collectors tolerate mismatched table walks. It also restores Foundry and Enterasys interface tables cleared by the earlier PHPStan cleanup in #377.
Changes:
- Guard cross-walk lookups and handle incomplete MAC, ARP, interface, and VLAN data.
- Restore interface-table use and correct Foundry indexing and Nortel NG alias lookup.
- Add regression tests for partial Extreme results and Foundry/Enterasys trunk counts.
| File | Description |
|---|---|
tests/Unit/InterfaceTableTrunkCountTest.php |
Add Foundry and Enterasys trunk-count regressions. |
tests/Unit/ExtremeIgnorePortsTest.php |
Cover incomplete Extreme FDB and ARP results. |
lib/mactrack_trendnet.php |
Guard interface-type and alias lookups. |
lib/mactrack_tplink.php |
Guard interface-type and VLAN-name lookups. |
lib/mactrack_norbay.php |
Guard interface metadata lookups. |
lib/mactrack_norbay_ng.php |
Correct alias indexing and guard interface lookups. |
lib/mactrack_linux.php |
Guard interface types during active-port counting. |
lib/mactrack_juniper.php |
Guard missing VLAN metadata. |
lib/mactrack_hp.php |
Guard interface type and name lookups. |
lib/mactrack_hp_ngi.php |
Guard interface type and name lookups. |
lib/mactrack_h3c_3com.php |
Guard interface and ARP joins. |
lib/mactrack_functions.php |
Guard shared port counts and Netscreen ARP joins. |
lib/mactrack_foundry.php |
Preserve interface data and iterate active ports by index. |
lib/mactrack_extreme.php |
Skip incomplete rows and add VLAN/port fallbacks. |
lib/mactrack_enterasys.php |
Preserve interface data and guard metadata lookups. |
lib/mactrack_enterasys_N7.php |
Guard interface types and reuse resolved port names. |
lib/mactrack_dlink.php |
Guard interface-type and VLAN-name lookups. |
lib/mactrack_dell.php |
Guard interface-type and alias lookups. |
lib/mactrack_cisco.php |
Guard VLAN-name lookups. |
lib/mactrack_cabletron.php |
Guard interface types and skip missing MAC addresses. |
lib/mactrack_aruba_oscx.php |
Guard interface-type lookups. |
lib/mactrack_3com.php |
Guard interface and bridge-port lookups. |
CHANGELOG.md |
Document #474 and interface-table restoration. |
Review effort: Balanced
#474) * Measure the Enterasys, Foundry, HP, HP NGI, Nortel and Nortel NG scanners in Clover so their changes are held to the coverage gate. * Drive each bridge-port scanner with a bridge port that is not an ifIndex, the SecureFast and standard ARP joins with partial walks, and the ExtremeWare ARP scan with a partial row. * Guard the Aruba CX and H3C VLAN name lookups, and the Nortel VLAN, ifOperStatus and ifDescr reads, which the new tests showed warn. * Drop the H3C, Enterasys N7 and TP-Link edits that were already protected by an enclosing check. Signed-off-by: TheWitness <thewitness@cacti.net> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
get_base_dot1dTpFdbEntry_ports() sets ports_active before the Foundry scanner recounts the up Ethernet ports, so with the interface table restored every active port was counted twice. Reset the counter before the Foundry recount, and assert the count in the Foundry test. Signed-off-by: TheWitness <thewitness@cacti.net> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
xmacan
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #474
Problem
MacTrack walks each SNMP table column separately, then joins the results by index. If an FDB entry is learned or ages out between walks, it can appear in one column but not another. On the reporter's Extreme X460, each collection logged
Undefined array keywarnings frommactrack_extreme.phplines 194, 195, 206 and 207. Those lines read$mac_port_list[$mac_key]and$mac_vlan_list[$mac_key], then used the missing results as keys into$ifInterfaces[...]and$vlan_ids[...].A survey of the other collectors found the same unguarded cross-walk lookups in most vendor scanners, in the shared ARP helper, and in two of the shared dot1d/dot1q helpers. It also found a related regression in Foundry and Enterasys.
Changes
Extreme (the reported bug)
N/A.Shared helpers (
mactrack_functions.php)get_standard_arp_table: guard the MAC/IP join, matching the guarded sibling function.get_base_wireless_dot1dTpFdbEntry_portsandget_base_dot1qTpFdbEntry_ports: guard theifOperStatus→ifInterfacesport count.Other collectors
Regression from #377 (Foundry and Enterasys)
$ifInterfaces = [];after the interface table was built. That emptied the table, so trunk counts were always 0. The empty table was also passed toget_base_dot1dTpFdbEntry_ports, so no user ports or MACs were found. The initialisation now comes before the build.$indexes[$i]counter on matching ports, so it checked the wrong interface. It now iterates by ifIndex.$ifInterfaces['ifAlias'][$ifIndex]never existed. It now reads$ifInterfaces[$ifIndex]['ifAlias'].Tests
ExtremeIgnorePortsTest: EXOS FDB entries missing from the VLAN walk or the port walk, and partial EXOS IP FDB rows. Both tests fail ondevelop: the VLAN is stored asN/Aand the warnings appear.InterfaceTableTrunkCountTest: Foundry and Enterasys trunk counts. Both fail ondevelop(count is 0).MACTRACK_TEST_DSN).php -lpasses on all lib files. PHPStan level 6 reports no new findings compared withdevelop. php-cs-fixer reports no issues on the changed lines.