fix: an unknown ARP age is -1.0, not 0.0 #17

Merged
christianmanivong merged 1 commits from fix/arp-unknown-age into main 2026-10-30 09:11:54 +00:00
3 changed files with 16 additions and 3 deletions

No files matched your search

+6
View File
@@ -12,6 +12,12 @@ All notable changes to this driver. The format follows
- The floor on napalm is 5.1: older releases import `pkg_resources`, which a Python
3.12 venv no longer has.
### Fixed
- `get_arp_table()` on Smart switches reports the age as `-1.0` (unknown,
napalm-device-types' `ARP_AGE_UNKNOWN`) instead of `0.0`, which means "confirmed
just now". The "Age (min)" column of `show arp` is not parsed until real switch
output confirms its format (NetOrk/netork#1327).
## [0.6.0] - 2026-10-23
The first release on PyPI, under the new name `napalm-netgear-switches`.
+3 -3
View File
@@ -894,9 +894,9 @@ class NetgearSmartDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
return configs
def get_arp_table(self, vrf: str = "") -> list[dict]:
"""Return the ARP table.
"""Return the ARP table. ``age`` is -1.0 (napalm-device-types' ``ARP_AGE_UNKNOWN``).
Example ``show arp`` output::
Example ``show arp`` output (not from a real switch: "Age (min)" waits for one)::
IP Address MAC Address Interface Age (min) Type
--------- ---------------- --------- --------- -------
@@ -940,7 +940,7 @@ class NetgearSmartDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
"interface": interface,
"mac": mac_addr,
"ip": ip_addr,
"age": 0.0,
"age": -1.0, # unknown, never 0.0 ("just now")
}
)
+7
View File
@@ -322,6 +322,13 @@ class TestGetArpTable:
# napalm_helpers.mac normalises to "AA:BB:CC:DD:EE:FF" format
assert any(":" in mac for mac in macs)
def test_age_is_unknown(self, driver):
"""The "Age (min)" column is not parsed yet (the fixture is not real switch
output), so the age is unknown: -1.0, never 0.0, which reads as "just now"
to a caller that ranks sightings by freshness (NetOrk/netork#1327)."""
driver._send_command = lambda cmd: SHOW_ARP
assert [e["age"] for e in driver.get_arp_table()] == [-1.0, -1.0]
# ---------------------------------------------------------------------------
# Tests: get_mac_address_table