diff --git a/hbd/client/connectivity.py b/hbd/client/connectivity.py index 1250213..4af186b 100644 --- a/hbd/client/connectivity.py +++ b/hbd/client/connectivity.py @@ -165,7 +165,9 @@ class Connectivity: key = (addr, gw) st.addr, st.gateway = addr, gw self._last_key[fam] = key - if due and fam not in self._ping_disabled: + if fam in self._ping_disabled: + st.present = None # cannot probe: unknown, never absent, while a route exists + elif due: await self._tier2(fam, st, now) async def _tier2(self, fam: str, st: FamilyState, now: float) -> None: diff --git a/tests/test_connectivity.py b/tests/test_connectivity.py index 60d2237..9af80a8 100644 --- a/tests/test_connectivity.py +++ b/tests/test_connectivity.py @@ -156,3 +156,18 @@ def test_from_config(): assert c.probes["ipv4"] == "9.9.9.9" assert c.probes["ipv6"] == "2606:4700:4700::1111" assert c.probe_interval == 30.0 + + +def test_ping_less_family_stays_unknown_after_route_returns(): + net = Net() + net.rtt["ipv4"] = "unavailable" + c = make(net) + refresh(c) + assert "p4" not in c.flags() + net.addr["ipv4"] = None + refresh(c) + assert c.flags()["p4"] is False # no route is definitive + net.addr["ipv4"] = "192.0.2.5" + refresh(c) + assert "p4" not in c.flags() + assert net.pings.count("ipv4") == 1 # missing binary is not retried