fix: an ARP entry's expiry is no age #35
No files matched your search
@@ -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
|
||||
|
||||
@@ -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", ""),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user