diff --git a/AGENTS.md b/AGENTS.md index 0b18a03..736a0b4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -991,6 +991,47 @@ Rules: a P-CSCF that had dropped a flow's state, and one that had received the first INVITE before the flow died; a reopen's connect that gets no answer at all; the emergency chain on a network. +- The firewall's rule for ESP (§7.3, §13; 1.2.4) is the bring-up script's, + which no suite reaches. The script's firewall block ran by itself on the + workstation against nftables (2026-11-24 and -25, the fp6 journal's + `2026-11-24-incoming-dropped-without-ping` capture, + `bench/bench-esp-rule.sh`: two network namespaces, an ESP transport-mode + SA pair between them, the dev phone's ruleset as read from it loaded in + the one that stands for the phone, the connection tracker's generic + timeout at 8 s, plain TCP both ways and no imsd). 1.2.3's block left the + ruleset as it was, and a connection the network's side opened to port + 45062 11 s after the phone's last packet got no answer: its three ESP + packets were new to the tracker and none passed the chain. This script's + block inserted the rule (`nftables: accepting ESP on qmapmux*`; a second + run inserted nothing), and the same connection, 11 s after the last + packet, was accepted. An ESP packet whose SPI no SA has passed the chain + and was dropped by the kernel (`XfrmInNoStates`); a connection through + the SA to another port got no answer, its SYNs dropped by the chain + after decapsulation. On that ruleset without imsd's rules the block + inserted all three above the chain's own; with no `inet filter` table it + did nothing. After the ruleset was loaded again from its file the + script's rule was gone and the connection unanswered again; a file that + carries the rule kept it. ESP on another interface was not accepted and + neither was an AH packet; ESP over IPv4 on `qmapmux0.0` was accepted, + and ESP on a second `qmapmux` interface. On that ruleset without imsd's + rules, as the block left it, connections to both ports were accepted. + Eleven faults put into the block one at a time, ten in its rule for ESP, + that rule's check and its journal lines and one in a port rule, were + each caught by a step (`bench/run-mutations-esp.sh`). + `bench/bench-esp-pinhole.sh` there has the gap without the script: the + network's connection accepted a second after the phone's own exchange + and under a packet of the phone's every 3 s, and unanswered 11 s after + the last packet. On the dev phone (KPN, the capture's `phone/`, + 2026-11-25) the script, run at imsd's start, inserted the rule above the + two port rules it found, and the daemon resumed its registration. Then a + text was sent to the phone's own number with the tracker's timeout at 0 + for the test, so that every ESP packet from the network came without an + entry: with the rule, six such packets came, and the answer to the + MESSAGE, the submit report and the text's delivery reached the daemon + within a second; with the rule taken out, 23 came in 20 s and none of + the three reached the daemon in those 20 s. Not met: a request the + network starts after the entry has lapsed of itself, 600 s after the + phone's last ESP packet (a call to the phone from another line). - `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, @@ -1424,7 +1465,12 @@ configures the muxed netdev. Idempotent; a non-zero exit fails the unit. - Opens imsd's protected ports 45061–45062 (TCP and UDP) on `qmapmux*` in nftables when a `inet filter` table exists (pmOS's default INPUT chain drops inbound on `qmapmux*`, which silently killed every network-initiated - request after ESP decapsulation). Best-effort. + request after ESP decapsulation), and accepts ESP itself on `qmapmux*` + (the packet passes the chain before it is decapsulated too; §13). Each + under its own comment in the chain, `imsd-protected-ports` and `imsd-esp`, + and only where the chain has no rule under that comment. Best-effort, + and in the running ruleset only: what the script inserted is gone when + the ruleset is next loaded from its files (§13). - Writes `/run/imsd.env`: `DEV=`, `LOCAL=`, `PCSCF_DISCOVERED=` (comma-separated in the modem's order; empty when nothing was discovered or `PCSCF` is set) and `PCSCF_DISCOVERY=found|none|failed|skipped` @@ -1979,7 +2025,9 @@ imsd to try again`, `wrote (not usable on the IPv6-only ims PDN)`, `P-CSCF discovery: nothing usable (…)`, `P-CSCF X configured: discovery skipped`, `host route to P-CSCF X dev Y` (the configured address or the first discovered), `wrote -/run/imsd.env: DEV=… LOCAL=… PCSCF_DISCOVERED=… PCSCF_DISCOVERY=…` —, +/run/imsd.env: DEV=… LOCAL=… PCSCF_DISCOVERED=… PCSCF_DISCOVERY=…`, +`nftables: opened protected ports 45061-45062 on qmapmux*` and `nftables: +accepting ESP on qmapmux*` where the script inserted the rule —, `imsd-handover: …`, `imsd-ofono-restart-calls: …`. ### 7.9 SMS over IP (TS 24.341) @@ -2734,7 +2782,10 @@ only the imsd side of its bus choice. (§7.2 step 3). Nothing else is routed over it. A change that routes anything else over it needs a reason and a bench. - The fixed protected ports (45061/45062) are opened in nftables for - `qmapmux*` only, by the bring-up script. + `qmapmux*` only, by the bring-up script, and ESP is accepted there: the + kernel drops an ESP packet no SA matches, and what an SA decapsulates + passes the chain again, under the same rules as a packet that came + without ESP. - Short messages (§7.9): `Send` is behind `net.catcrafts.IMS1.Messaging` (an ungated `Send` would let any local account text from the subscriber's number); the journal names a delivered message's sender, size and @@ -2852,8 +2903,28 @@ the related code. whether that shape is the phone's or the network's interworking, nothing on disk says. - **pmOS's default nftables** drops inbound on `qmapmux*`; without the - protected-port rule every network-initiated request (NOTIFY, MT INVITE) - dies after ESP decapsulation and MT calls fall back to CS. + protected-port rule every network-initiated request (NOTIFY, MT + INVITE) dies after ESP decapsulation and MT calls fall back to CS. The + ESP packet passes the same chain before it is decapsulated, and + without a rule for it the chain accepts it only as an answer to a + packet the phone sent (`ct state established`): the connection tracker + has no tracker for ESP, and its generic one keeps the entry for + `nf_conntrack_generic_timeout` seconds after the last packet either + way, 600 on the dev phone. A request the network starts later than + that after the phone's last ESP packet is then dropped, and its + retransmissions until the phone next sends to that P-CSCF. A CRLF + keepalive every 30 s keeps the entry (over TCP and outside a call + only: `SendKeepalive` sends none over UDP, and the shell's loop calls + it only while no call is up); the bring-up script's rule for ESP + (§7.3, 1.2.4) makes the entry needless. Shown on the workstation with + the dev phone's ruleset, and on the dev phone for a text with the + tracker's timeout at 0 (§5). A firewall without an `inet filter` table + with an `input` chain gets no rule from the script and needs its own. + And the script's rules are in the running ruleset only: a reload of + the ruleset from its files (the nftables unit's `flush ruleset`, and + the one in `/etc/nftables.nft`) removes them until imsd next starts, + so a ruleset whose files carry the port rules (fp6-img's + `01_imsd.nft`) has to carry the rule for ESP in them too. - **The kernel's temporary SLAAC address** on the ims netdev is listed first and retired after about two days; a registration bound to it dies with it. - **systemd reads `EnvironmentFile=` per spawned command** (systemd 262~rc3 diff --git a/packaging/ims-pdn-up.sh b/packaging/ims-pdn-up.sh index dafc4d9..0342941 100644 --- a/packaging/ims-pdn-up.sh +++ b/packaging/ims-pdn-up.sh @@ -501,6 +501,18 @@ log "wrote /run/imsd.env: DEV=$IFACE LOCAL=$ADDR PCSCF_DISCOVERED=$DISCOVERED PC # the P-CSCF's TCP SYNs to the protected server port never reached the # listener, so terminating delivery failed and MT calls fell back to CS. # 45061/45062 = imsd's protected client/server ports (kPortUc/kPortUs). +# +# The ESP packet itself passes the chain first, before the kernel +# decapsulates it. With no rule for it, the chain lets it in only as an +# answer to a packet of ours ("ct state established": the connection +# tracker's entry for a protocol it has no tracker of its own for, 600 s by +# default), and drops a request the network starts later than that after +# our last packet. ESP that no SA of ours matches is dropped by the kernel +# behind the rule, and what an SA decapsulates passes the chain again. +# +# Each of the two has its own check: a ruleset that carries the port rules +# under their comment (fp6-img's 01_imsd.nft) can lack the ESP rule. What +# is inserted here is gone when the ruleset is next loaded from its files. # Best-effort: never fail the unit over a missing/foreign firewall. if nft list table inet filter >/dev/null 2>&1; then if ! nft list chain inet filter input | grep -q imsd-protected-ports; then @@ -509,5 +521,10 @@ if nft list table inet filter >/dev/null 2>&1; then log "nftables: opened protected ports 45061-45062 on qmapmux*" || log "nftables: rule insert failed (continuing)" fi + if ! nft list chain inet filter input | grep -q imsd-esp; then + nft insert rule inet filter input iifname "qmapmux*" meta l4proto esp accept comment '"imsd-esp"' && + log "nftables: accepting ESP on qmapmux*" || + log "nftables: rule insert failed (continuing)" + fi fi exit 0