imsd: a server port's answer finds its connection or socket when it is sent

A request that came in on a server port (the protected ports' TCP
listeners and UDP sockets) was answered through a closure that kept a
descriptor's number: its connection's over TCP, a socket's over UDP.
The daemon closes a connection's descriptor when the peer has ended
the connection, and the kernel gives a closed descriptor's number out
again. A call's later answers go through the closure of the call's
latest request when the user answers or refuses or the ringing ends
(the 200 of an Accept, a 486, a 480): they were written to that
number, whatever had it by then, the connection of whoever had
connected since among them.

A closure now keeps the port its request came in on and the peer it
came from, or which of the two UDP ports its answer leaves by. Over
TCP an answer is written to the newest connection the daemon holds
from that peer to that port, and is not sent where it holds none: the
journal says so once in a run. Over UDP it leaves from the socket its
port has at that moment, if it has one.

Tested: the daemon of this commit on the workstation against a
stand-in network that closes the connection its INVITE came on while
the call rings and then connects from another host, from another
port, from the same port to the daemon's other port or from the same
port to the same one, and one that resets the connection right behind
its INVITE and makes it again (the fp6 journal's
2026-12-04-pani-in-dialog capture, bench/); and on the dev phone on
KPN, where it answered a call that came in and the two requests that a
text to the phone's own number brings (the journal's
2026-12-04-imsd-1.2.7-range-on-dev-phone capture).
This commit is contained in:
Jorijn van der Graaf 2026-12-04 23:20:38 +01:00
commit 6d05aaed0d
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
2 changed files with 132 additions and 12 deletions

View file

@ -180,7 +180,11 @@ sleep (1.2.5, §7.10) is the shell's but for when the phone has to be
awake (`WakeAt`) and the policy's wake after a local wait
(`RegRecovery::WakeTime`), which are `Imsd:Engine`'s, with tests; §7.10
has what the shell does for it, and §5 what of that ran against
stand-ins on the workstation and what on the dev phone. SMS over IP
stand-ins on the workstation and what on the dev phone. Where an answer
goes that the server ports send (§12: the connection found by its port
and its peer, an answer that is not sent, the socket a datagram leaves
from) is the shell's (`ServerPorts`); §5 has what of it ran against a
stand-in network on the workstation and what on the dev phone. SMS over IP
(1.2.0, §7.9) keeps in the
shell, among others, the service centre's source (`SMSC=` over EF_SMSP, `LoadSmsParameters`),
the three counters (TP-MR, RP-MR, the concatenation reference), their
@ -1309,6 +1313,46 @@ Rules:
through a step's wait while a text is in flight, which is read from
the code;
the reg-event subscription's renewal on a network.
- Where an answer goes that the server ports send (§12) is the shell's
(`ServerPorts`), and no suite reaches it. On the workstation the daemon
ran against a stand-in network that sends it requests over TCP and UDP
and can close or reset a connection behind one (the fp6 journal's
`2026-12-04-pani-in-dialog` capture, `bench/bench-pani.sh`: the daemon
in dev mode, its card and modem reads answered by stand-ins, an
incoming call accepted on its bus). Where the network closed the
connection its INVITE had come on while the call rang, the 200 of the
Accept arrived on the connection the same peer had made again to the
same port, also where the network had reset the first right behind its
INVITE (that call's 100 and 180 did not arrive: the connection they
were written to had been reset); it was not sent, with the journal's
line, where the only new connection was another host's, another port's
of the same host, or the same peer's to the daemon's other port (the
release before, 1.2.6, wrote it on the other host's connection and on
the one to the other port; with another port of the same host it was
not run); and it arrived on the INVITE's own connection where the peer
made a second one to the other port while the call rang. Two requests
whose connections the network closed right behind them were not
answered, with one line. Over UDP five OPTIONS requests were answered
from the ports the release before answered them from; two of the five
had no `rport` in their Via and were answered at the port that Via
names. On the dev phone on KPN (2026-12-04; the fp6 journal's
`2026-12-04-imsd-1.2.7-range-on-dev-phone` capture: the daemon in the
packaged one's place, resuming its registration, and the SA pair's
packets read on the phone) the two requests that a text to the phone's
own number brings came in over UDP, and each 200 left from 45061 for
the P-CSCF's protected server port, which their Via names; the text
was delivered, and the network sent neither request again. A call
came in there over TCP, on a connection the P-CSCF had made to 45062
and had sent two NOTIFYs on: the 200s to those, the call's 100, its
180 and the 200 of the Accept left on that connection, and the 200 to
its BYE, which came over UDP, from 45061. Of what ran against the
stand-in network nothing else has been seen on a real one (a
connection closed or reset behind a request and an answer that is not
sent among it).
Not run: an answer given after the daemon has moved to another
address; a peer on a link-local or an IPv4 address; a connection that
ends in an error and is made again within one turn of the daemon's
loop.
- `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,
@ -2295,6 +2339,9 @@ Lines the operator (and the scripts) look for, all prefixed `imsd: `:
`INVITE final 422, Min-SE N` or `INVITE final 422, no Min-SE read`: the call's `ended:` line, or an
emergency attempt's `— retrying as plain INVITE of the digits`. In each of the three a `Reason` header of
the 422 follows the `Min-SE` part (`…, Reason: …`).
- `an answer from port N to [address]:port is not sent: no connection from that peer to that port is held
(said once)` the first time in a run that an answer is given to the channel of a request that came in over
TCP and `ServerPorts` holds no connection from that request's peer to that port (§12).
- `sleep is held off while the call lasts (logind's inhibitor)` when the
calls table's first call has its lock and `sleep is no longer held off
(no call)` when that lock is released, the table's last call gone
@ -3346,6 +3393,18 @@ only the imsd side of its bus choice.
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.
- `ServerPorts` (the protected ports' TCP listeners and UDP sockets)
takes a request from whatever reaches it on the ims PDN (the entry on
short messages below). The channel of a request that came in there
over TCP is the newest connection `ServerPorts` holds from that
request's peer to the port it came in on; where it holds none, an
answer given to the channel is not sent (§7.8). A connection that has
ended in an error is held until `Poll` has read its end, and what is
written to it meanwhile is lost. Over UDP the channel is the socket
that the port the answer leaves by has when the answer is sent, if it
has one. A channel keeps no descriptor: the kernel gives a closed
descriptor's number out again, to a pipe, a file or the connection of
whoever connects next.
- 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