Skip to content

MacTrack: scan, poller, view, OUI and MacWatch defects found in an algorithm review #432

Closed

Description

@somethingwithproof

A review of the collection, scheduling and reporting code found the defects below. Each line says what a user sees.

Scanning and vendors

  • Cisco: a switch that returns no VLAN names or trunk status keeps the previous scan's MAC count and "completed ok" message, so site totals count MACs that were not scanned. VLAN totals can go negative on devices without the reserved VLANs.
  • SNMP: OIDs are keyed with a leading dot on the snmpwalk path and without it on the PHP SNMP path, so Juniper, Aruba, TP-Link, D-Link and Enterasys misread MACs or VLANs on one of the two paths.
  • Generic dot1q: the MAC is read from dot1qTpFdbAddress, which Q-BRIDGE-MIB defines as not accessible, so compliant agents return nothing and every port is skipped.
  • Dell and TRENDnet: the VLAN becomes part of the MAC and zero octets come out as one digit.
  • TP-Link: bridge ports are renumbered 1..n in walk order, so switches whose bridge ports do not start at 1 put MACs on the wrong interface or none.
  • Aruba AOS-CX: MACs are stored colon-separated, so the vendor lookup and ARP-to-port match fail; IPv6 neighbours are misread as IPv4 addresses.
  • Seven scanners check a "portLink" key that nothing sets, so MACs learned on ports that carry an IP address are stored as user ports. Four scanners skip the bridge root port only when a port range is set.
  • Scanning is slow: every stored MAC runs its own MacAuth query and REPLACE (about 20,000 round trips for a 10,000-MAC switch), the standard ARP scan writes one row at a time, and Cisco scans re-walk ifOperStatus and dot1dBasePortIfIndex for every VLAN.
  • ArpWatch: lines without a host name read past the end of the line, and a trailing host name keeps its newline.
  • Aggregated table: rows migrated from before 4.9 keep an eight-character vendor_mac that no OUI matches, and the poller never refreshes it, so they never get a vendor.

Poller

  • Site scan: marks every site's VLANs absent and deletes those it did not see, and clears active_last on every aggregated row. Clearing active_last also moves date_last, so an inactive MAC looks seen.
  • Run limit: at a 5-minute frequency on a 5-minute poller the limit is zero, so each run times out after its first batch and truncates the temp table while scanners still write.
  • Scanner counting: scanners register only once PHP starts, so the wait loop can finish early, and the launch loop counts the parent and resolver rows as scanners.
  • Wait loop: the resolver check runs back to back with no pause for as long as the resolver runs.
  • Resolver: it quits after about 18 seconds, so most addresses are never resolved; the write-back replaces the whole snapshot row, clearing the vendor and re-creating rows already moved.
  • Schedule: a run slot only counts when strictly in the past, and the last run time is stored at start, so the schedule drifts with poller jitter. The first run of a day adds 86400 seconds, which is an hour off across a DST change.
  • IP ranges: a range absent from a scan keeps its old address count, the scan date comes from an arbitrary row, and each range costs a SELECT and a write.
  • Hung-process cleanup: the poller and resolver rows are never cleared, a stored PID that was reused can be killed, an unreadable maintenance time runs maintenance every cycle, and site scans log no statistics.

Views

  • Sites view: the device type and site conditions replace the WHERE clause built so far, dropping the text filter or leaving a bare AND. The summary applies the site filter to a table it does not join, which is an SQL error.
  • ARP view: the Interface column is empty for scanners that store the port as an interface name, because the join compares a name as a number.

OUI

MacWatch and MacAuth

  • MacWatch: schedule options are minutes but are compared as seconds, the 12-hour and daily choices are stored as 255 in a tinyint, and the last mail time is never recorded, so every periodic watch mails on every scan.
  • MacAuth and MacWatch: MACs are saved as typed (00:11:22:33:44:55) while scanners store twelve hex digits, so poller lookups never match. A MacAuth prefix marks history authorized at save, but the scan-time check matches only whole addresses, so the next scan reverses it.

Maintenance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions