fix: an ARP entry's expiry is no age
driver / standard (pull_request) Successful in 18s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m6s
driver / test (3.12) (pull_request) Successful in 1m27s
driver / lowest (pull_request) Successful in 37s
driver / test (3.13) (pull_request) Successful in 1m27s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m12s
CI / driver (pull_request) Successful in 3m12s
driver / publish (pull_request) Skipped

get_arp_table and get_ipv6_neighbors_table reported expires, the seconds
left until the entry expires: an entry refreshed a second ago looked 20
minutes old. Both now report ARP_AGE_UNKNOWN (-1.0).

NetOrk/netork#1327
This commit is contained in:
Christian Manivong committed 2026-10-30 08:37:08 +01:00
1 parent 0176656743
commit bb0810d693
3 files changed
+19 -4

No files matched your search

+4
View File
@@ -13,6 +13,10 @@ All notable changes to this driver. The format follows
3.12 venv no longer has.
### Fixed
- `get_arp_table()` and `get_ipv6_neighbors_table()` report an unknown age as `-1.0`
(napalm-device-types' `ARP_AGE_UNKNOWN`). They reported `expires`, the seconds
left until the entry expires, which is no age: an entry refreshed a second ago
looked 20 minutes old (NetOrk/netork#1327).
- `get_vpn_tunnels()` keys a WireGuard peer by its interface and the start of its
public key (`wireguard-wg0-aBcD1234`, URL-safe) instead of its position, so a peer
added ahead of another no longer renumbers it (#32). Every WireGuard key changes
+4 -4
View File
@@ -498,7 +498,7 @@ class OPNsenseDriver(
Calls ``GET /api/diagnostics/interface/get_arp``.
Each entry contains: ``interface``, ``mac``, ``ip``, ``age``.
Each entry contains: ``interface``, ``mac``, ``ip``, ``age`` (-1.0, unknown).
"""
data = self._get("/api/diagnostics/interface/get_arp")
arp_table: list[dict[str, Any]] = []
@@ -509,7 +509,7 @@ class OPNsenseDriver(
"interface": entry.get("intf") or entry.get("interface", ""),
"mac": (entry.get("mac") or "").lower(),
"ip": entry.get("ip") or entry.get("address", ""),
"age": float(entry.get("expires", 0)),
"age": -1.0, # `expires` counts down to expiry; it is no age
}
)
@@ -682,7 +682,7 @@ class OPNsenseDriver(
Calls ``GET /api/diagnostics/interface/get_ndp``.
Each entry contains: ``interface``, ``mac``, ``ip``, ``age``,
Each entry contains: ``interface``, ``mac``, ``ip``, ``age`` (-1.0, unknown),
``state`` (best-effort from NDP flags).
"""
data = self._get("/api/diagnostics/interface/get_ndp")
@@ -695,7 +695,7 @@ class OPNsenseDriver(
"interface": entry.get("intf") or entry.get("interface", ""),
"mac": (entry.get("mac") or "").lower(),
"ip": entry.get("ip") or entry.get("address", ""),
"age": float(entry.get("expires", 0)),
"age": -1.0, # `expires` counts down to expiry; it is no age
"state": entry.get("state", ""),
}
)
+11
View File
@@ -343,6 +343,13 @@ class TestGetInterfacesIp:
class TestGetArpTable:
def test_expires_is_not_an_age(self, driver):
"""``expires`` counts down to the entry's expiry; it says nothing about
when the neighbour was last confirmed. Reported as the age, an entry
refreshed a second ago looked 20 minutes old (NetOrk/netork#1327)."""
driver._get = lambda path: ARP_RESPONSE
assert {e["age"] for e in driver.get_arp_table()} == {-1.0}
def test_entry_count(self, driver):
driver._get = lambda path: ARP_RESPONSE
table = driver.get_arp_table()
@@ -681,6 +688,10 @@ class TestGetIpv6NeighborsTable:
driver._get = lambda path: {"rows": []}
assert driver.get_ipv6_neighbors_table() == []
def test_expires_is_not_an_age(self, driver):
driver._get = lambda path: NDP_RESPONSE
assert {e["age"] for e in driver.get_ipv6_neighbors_table()} == {-1.0}
# ---------------------------------------------------------------------------
# get_lldp_neighbors() / get_lldp_neighbors_detail()