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

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

No files matched your search

+5
View File
@@ -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": the host
list says a host is active, not when the gateway last saw it (NetOrk/netork#1327).
## [0.3.0] - 2026-10-23
The first release on PyPI.
+6 -2
View File
@@ -321,7 +321,11 @@ class ZyxelVMGDriver(ResidentialGatewayDriver):
return result
def get_arp_table(self, vrf: str = "") -> list[dict[str, Any]]:
"""Return the ARP table derived from DHCP host entries."""
"""Return the ARP table derived from DHCP host entries.
The host list does not say when the gateway last saw a host, so ``age``
is ``-1.0`` (unknown, napalm-device-types' ``ARP_AGE_UNKNOWN``).
"""
arp: list[dict[str, Any]] = []
for host in self.get_hosts():
if not host["is_active"] or not host["mac"] or not host["ip"]:
@@ -331,7 +335,7 @@ class ZyxelVMGDriver(ResidentialGatewayDriver):
"interface": host["interface_type"],
"mac": host["mac"],
"ip": host["ip"],
"age": 0.0,
"age": -1.0,
}
)
return arp
+14
View File
@@ -278,6 +278,20 @@ class TestZyxelVMGDriver:
self._setup_mocked_http()
assert self.driver.get_arp_table() == []
def test_an_arp_entry_has_no_known_age(self):
"""The host list says a host is active, not when the gateway last saw it;
0.0 would read as "confirmed just now" (NetOrk/netork#1327)."""
self.driver.get_hosts = lambda: [
{
"mac": "aa:bb:cc:dd:ee:ff",
"ip": "192.168.1.33",
"hostname": "laptop",
"interface_type": "lan",
"is_active": True,
}
]
assert [e["age"] for e in self.driver.get_arp_table()] == [-1.0]
def test_reboot_host_is_the_contract_the_application_calls(self):
"""It was reboot(), which nothing looks for: the gateway could not be
restarted from the application (#5)."""