From 48fdda1904597c7aec9a4e644221dfeebbb2491b 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 The host list says a host is active, not when the gateway last saw it, so get_arp_table reports ARP_AGE_UNKNOWN instead of 0.0 ("confirmed just now"). NetOrk/netork#1327 --- CHANGELOG.md | 5 +++++ napalm_zyxel/zyxel_driver.py | 8 ++++++-- tests/test_zyxel.py | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1517f5e..7e5098c 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": 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. diff --git a/napalm_zyxel/zyxel_driver.py b/napalm_zyxel/zyxel_driver.py index 96d6ff3..cab9c88 100644 --- a/napalm_zyxel/zyxel_driver.py +++ b/napalm_zyxel/zyxel_driver.py @@ -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 diff --git a/tests/test_zyxel.py b/tests/test_zyxel.py index 965a3cf..ed80de2 100644 --- a/tests/test_zyxel.py +++ b/tests/test_zyxel.py @@ -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).""" -- 2.54.1