diff --git a/AGENTS.md b/AGENTS.md index 5a83fcb..5e288b2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -101,7 +101,9 @@ meanwhile and the routing of our reg-event SUBSCRIBE's final read there, the 12 s wait restarted on a provisional); the reregistration's headers and its answer to a challenge (`Reregister`: the stored challenge answer, or the empty digest for a pre-0.3.11 state file, the new SPIs, `PortUcNext`; a 401 thrown -as a refusal carrying its status); the state-file round trip +as a refusal carrying its status; and, since 1.2.5, the number it takes, +used and written to the state file once the REGISTER is sent, §7.2 +step 5 and §5); the state-file round trip (`PersistState`/`LoadState`: the `security_server` key, written empty for a value with a quote, a backslash or a newline — the choice between that list and the entry rebuilt from the SA is `Imsd:Ipsec`'s, with a test); the @@ -527,16 +529,9 @@ Rules: pre-fix build that renewed that closure; the retry on this code, the renewal firing, Timer F, the doubling, a SUBSCRIBE `Retry-After`, the renew arm and the back-off's survival across a refresh have run nowhere — - §3, §7.4); a `Retry-After` on a REGISTER has run in the field (one - report, a screenshot of 2026-10-08, O2, 0.3.10: a refresh's Retry-After - set the next step's time — `in 7 min`, then `in 13 min` — and the - refusals counted; the wait's length went unmeasured, the journal lines - on the screenshot carry no timestamps; KPN's refusals, all 403, carry - none) and a `Dial` bringing a recovery step + §3, §7.4); a `Dial` bringing a recovery step forward (imsd-ofonod refuses the `Dial` itself and imsd-dialerd forwards - it) is pinned in `tests/Engine` only; a 401 to a reregistration (the - refreshes KPN accepted were never challenged — consecutive CSeqs on every - bench — and O2 has not run this shape) and + it) is pinned in `tests/Engine` only; the escalation by one refused refresh that carries a `Retry-After` — the escalation to a fresh registration is pinned in `tests/Engine` only; a resume echoing a multi-mechanism Security-Server list on the wire (the @@ -600,30 +595,20 @@ Rules: a quote, a backslash or a newline — neither KPN's nor O2's list has one; the resume of such a file ran with a hand-edited empty key, 2026-10-11); a state write of a standing registration after a fresh - attempt that aborted before its SA setup (`RegState::securityServer`, - not the attempt's `ss_` — on KPN the old SA's retry after a throttled - attempt is refused 403, the throttled-attempt chain below, so no such - write follows here); the window that leaves a state file naming another + attempt that had its 401 and aborted before its SA setup + (`RegState::securityServer`, + not the attempt's `ss_`: since 1.2.5 the write is made when a + re-REGISTER is sent, so on KPN it follows the old SA's first retry + after a throttled attempt, which KPN has answered 403, 2026-10-03, and + 480, 2026-11-25; no daemon that writes at the send has had a throttled + attempt); the window that leaves a state file naming another SA pair than the kernel's (a stop or a crash between a fresh attempt's SA setup and its 200's state write — the check is pinned in `tests/Ipsec` and ran on a hand-edited list, 2026-10-11; the window itself is not - staged); a - refused initial or fresh - REGISTER (403, 5xx) at bring-up or in recovery (KPN has only throttled or - stayed silent — pinned in `tests/Engine` only); the write-off of the old + staged); the write-off of the old registration by a recovery's fresh attempt that fails past the SA setup (such attempts are on record only as a bring-up's fatal exit, which does - not pass that arm — pinned in `tests/Engine` only); the escalation by - two refused refreshes that carry no `Retry-After` (KPN refuses a refresh - only with the 403 that says the registration is gone — pinned in - `tests/Engine` only); of the throttled-attempt chain in recovery (a - throttled fresh attempt, the old SA retried once meanwhile with the stored - binding's Contact and refused 403, the deferred attempt accepted at the - hold's end — run 2026-10-03 on the series as it then stood) the deferred - attempt made by the - same process, since a restart inside the hold made it from the holds file - instead (the same process made it on 2026-09-24, on the build before the - policy's rework); the address moves + not pass that arm — pinned in `tests/Engine` only); the address moves writing `old_gone` to the holds file (the move benches predate that field); a SUBSCRIBE final read inside a REGISTER wait (KPN answers within the second); the shell's handling of a NOTIFY that terminates our own @@ -645,7 +630,9 @@ Rules: session, or GNOME Calls' `Answer` through imsd-ofonod's gate (imsd's own `Accept` gate has run: refused for an account without a seat session and for nobody, accepted for root, 2026-10-04); a refused - final carrying reason headers (KPN's 403s carry none — the rendering is pinned + final carrying a `Warning`, a `Reason` or a `Server` header (KPN's 403s + and 482s carried none, its 480s of 2026-11-25 a `Retry-After` and no + other — the rendering of the three is pinned in `tests/Sip` only); an `AUDIO_USER` pin in imsd's own environment that names no account (the logind fallback) or an account without a PipeWire socket (a silent call) — a pin naming an account with one ran, 2026-10-04. @@ -1099,6 +1086,35 @@ Rules: since. The flow was found dead 0.3 s after the repeat went out, the recovery reconnected and re-registered 0.2 s after that, and the text ended `failed`, its repeat lost with the flow. +- The CSeq of a re-REGISTER (§7.2 step 5) is the shell's, and no suite + reaches it. On the workstation the daemon ran against a stand-in network + that keeps the highest CSeq of the protected REGISTERs it has taken + per Call-ID, answers a protected REGISTER + that is not higher `482 Loop Detected`, and can take one refresh + without answering it or refuse one (the fp6 journal's + `2026-11-25-refresh-answer-lost` + capture, `bench/bench-cseq.sh`): after a refresh whose answer is lost + the reconnect's re-REGISTER carries the next number and is answered + 200, where 1.2.4's carried the lost one's, was refused twice and + registered fresh; a daemon killed under the wait resumes with the next + number, the state file having it, where 1.2.4's resume was refused and + registered fresh; after a refresh the stand-in refused (503) the + reconnect's re-REGISTER carries the next number, where 1.2.4's carried + the refused one's again (the stand-in keeps no number for a REGISTER + it refuses, and answered both 200). On the dev phone (KPN, + 2026-11-25, this commit's + daemon; the fp6 journal's `2026-11-25-through-sleep` capture, + `phone/cseqtest-2-a`), with the firewall's rule for ESP taken out and + the connection tracker's generic timeout at 0 around a refresh, so that + its answer was dropped: `keepalive re-REGISTER failed: no reply to + re-REGISTER`, and `reconnected + re-registered` 10 s later. Not run: the + number after a re-REGISTER whose send failed; a re-REGISTER's answer + lost over UDP; a restart after a daemon was told to stop (SIGTERM) + under the wait, where the bench kills it; a resume whose REGISTER gets + no answer; a state file torn by a kill during its write; and what a + network makes of a number that skips one, as a REGISTER that was sent + and never arrived leaves it (the stand-in took one; no phone run tells + whether its network saw one). - `imsd-pcscf` ran on the dev phone (KPN) on 2026-10-11 against the live ims bearer: the `--mux 1 --profile 2 -v` sequence, a plain run, and `OutOfCall` on an unbound mux (the fp6 journal's `2026-10-11-pcscf-pco-probe` capture, @@ -1385,7 +1401,11 @@ The daemon's own bring-up (`BringUp()` in `main.cpp`): `tcp_retries2` of 15); until 1.2.3 a ping's were among those bytes every 30 s outside a call. The refresh of a registration this process made fresh is a reregistration as TS 24.229 - 5.1.1.4.2 has it: the same Call-ID and Contact, CSeq+1, the + 5.1.1.4.2 has it: the same Call-ID and Contact, the CSeq one above the + last REGISTER sent on that Call-ID, answered or not (RFC 3261 10.2; + the number is used, and in the state file, once the REGISTER is sent: + §13 has KPN's 482 to re-REGISTERs that, by 1.2.4's code, carried an + unanswered one's number), the Authorization of the last successful authentication verbatim (the 401's nonce, our cnonce and response, kept in the state file), a Security-Client with new SPIs and a new client port (`PortUcNext`, @@ -2959,6 +2979,24 @@ the related code. 21 min is the wait that has never been refused, not a measured minimum; imsd resumes rather than registers fresh wherever it can, since on a live registration's address the attempt is refused and costs the registration. +- **KPN refused the two re-REGISTERs that followed an unanswered refresh + `482 Loop Detected`, before any fresh attempt, and answered 200 where + the next number was sent** (the dev phone, 2026-11-25; the fp6 + journal's `2026-11-25-refresh-answer-lost` capture). A refresh's answer + did not reach the phone, whose firewall dropped the network's packets + for 20 s in a test. The reconnect's re-REGISTER was refused 482 10 s + after the refresh had failed, and the next one that reached the + network 66 s after that. That both carried the unanswered one's number + is read from the code, not seen: it was a test build with 1.2.4's code + at that place, and the journal prints no number for a REGISTER that + fails. The fresh registration that followed met the throttle above + (`spi-s=0`), re-REGISTERs after it were answered `480 Temporarily + Unavailable` with `Retry-After: 180` (by the same reading of the code + they carried the unanswered one's number too: the 482 came only + before the throttled attempt), and the phone registered again + 25 min 55 s after the refresh had failed. With the next number, the + reconnect's re-REGISTER after a refresh whose answer was dropped the + same way was answered 200. - **O2 UK, 2026-09-24:** a refresh refused 21 × 503 over 70 min, then 33 unanswered reconnect cycles; a fresh registration was accepted in one second. The origin of `RegRecovery`. On 2026-10-08, under 0.3.10 (the diff --git a/implementations/main.cpp b/implementations/main.cpp index e079f19..e120fad 100644 --- a/implementations/main.cpp +++ b/implementations/main.cpp @@ -2544,6 +2544,15 @@ private: do spiUs = rng_.UInt(0x10000, 0xFFFFFFF); while (spiUs == reg_.spiUc || spiUs == reg_.spiUs || spiUs == spiUc); std::string reg = imsd::msg::BuildRegisterProtected(ctx_, callid, ftag, rng_.Token(16), cseq, spiUc, spiUs, auth, PortUcNext); if (!sip_.Send(reg)) throw std::runtime_error("send re-REGISTER failed"); + // Sent, the number is used, whatever comes back: the next REGISTER + // on this Call-ID carries a higher one (RFC 3261 10.2), where a + // registrar that took this one and whose answer did not arrive + // refuses the same number (10.3 step 7; KPN answered 482 Loop + // Detected where, by 1.2.4's code, two re-REGISTERs carried an + // unanswered refresh's: the dev phone, 2026-11-25). After a restart + // too: the state file has the number before the answer is waited for. + reg_.cseq = cseq; + PersistState(reg_, route_, ppi_, ctx_.aor, ctx_.transport, pcscf_); std::string m = AwaitFinal(callid, cseq, "re-REGISTER"); auto st = imsd::sip::Status(m); if (st == 200) return {m, cseq};