From dacefaa6067ec88d353a6dae6caadc677edc3be9 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 30 Oct 2026 08:37:08 +0100 Subject: [PATCH] fix: an unknown ARP age is -1.0, not 0.0 Get-NetNeighbor reports a state but no age, so get_arp_table reports ARP_AGE_UNKNOWN instead of 0.0 ("confirmed just now"). NetOrk/netork#1327 --- CHANGELOG.md | 5 +++++ napalm_windows/windows.py | 4 +++- tests/test_windows.py | 11 +++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 295dca5..c90bfc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ 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()` reports an unknown age as `-1.0` (napalm-device-types' + `ARP_AGE_UNKNOWN`) instead of `0.0`, which means "confirmed just now": + `Get-NetNeighbor` has a state but no age (NetOrk/netork#1327). + ## [0.2.0] - 2026-10-23 The first release on PyPI. diff --git a/napalm_windows/windows.py b/napalm_windows/windows.py index 1872d34..eefae4f 100644 --- a/napalm_windows/windows.py +++ b/napalm_windows/windows.py @@ -436,6 +436,8 @@ class WindowsDriver(OSDriver): return result def get_arp_table(self, vrf: str = "") -> list[dict[str, Any]]: + """Get-NetNeighbor's IPv4 neighbours. It reports a state but no age, so + ``age`` is ``-1.0`` (unknown, napalm-device-types' ``ARP_AGE_UNKNOWN``).""" entries = [] for n in _as_list(self._run_ps(_PS_ARP)): if (n.get("state") or "").lower() in _DEAD_NEIGHBOUR_STATES: @@ -443,7 +445,7 @@ class WindowsDriver(OSDriver): mac = _mac(n.get("mac")) if not _is_real_neighbour_mac(mac): continue - entries.append({"interface": n["interface"], "mac": mac, "ip": n["ip"], "age": 0.0}) + entries.append({"interface": n["interface"], "mac": mac, "ip": n["ip"], "age": -1.0}) return entries def get_route_to( diff --git a/tests/test_windows.py b/tests/test_windows.py index 516e2e5..bbdb611 100644 --- a/tests/test_windows.py +++ b/tests/test_windows.py @@ -297,10 +297,17 @@ class TestGetArpTable: arp = _driver(_PS_ARP=_fixture("arp.json")).get_arp_table() assert arp == [ - {"interface": "Ethernet", "mac": "00:0D:B9:11:22:33", "ip": "10.0.0.1", "age": 0.0}, - {"interface": "Ethernet", "mac": "00:15:5D:AA:BB:CC", "ip": "10.0.0.20", "age": 0.0}, + {"interface": "Ethernet", "mac": "00:0D:B9:11:22:33", "ip": "10.0.0.1", "age": -1.0}, + {"interface": "Ethernet", "mac": "00:15:5D:AA:BB:CC", "ip": "10.0.0.20", "age": -1.0}, ] + def test_age_is_unknown(self): + """Get-NetNeighbor has a state but no age; 0.0 would read as "confirmed + just now" to a caller ranking sightings by freshness (NetOrk/netork#1327).""" + arp = _driver(_PS_ARP=_fixture("arp.json")).get_arp_table() + + assert {entry["age"] for entry in arp} == {-1.0} + class TestGetRouteTo: def test_maps_protocols_and_drops_noise(self):