packaging: restart imsd and imsd-ofonod on upgrade

An upgrade left the old imsd and imsd-ofonod running until they were
next restarted, while a changed bus policy is live the moment apk writes
it: dbus-broker-launch reloads on its own. A policy that relies on a
check inside the daemons would face the old daemons in between.

Mark imsd.service and imsd-ofonod.service needs-restart in post-upgrade
scripts; the systemd trigger restarts them once the transaction is done
(enqueue-marked). A call in progress ends. The same scripts run as
post-install: `apk del` removes a package's files and leaves its daemon
running, so a later `apk add` of the package is this upgrade for that
daemon — and apk runs the post-install script, not post-upgrade, for a
package it adds. GNOME Calls 50.0 dials nothing after imsd-ofonod
restarts under it until it restarts too, so imsd-ofonod's ExecStartPost
restarts the Calls daemon of each user running one — not at the unit's
first start since boot, when a Calls that runs already is left alone.

A daemon older than 0.3.10 kept its bring-up throttle wait in memory
only, so a restart lost it. imsd's post-upgrade records that daemon's
invocation, and imsd-handover.sh, an ExecStartPre after ims-pdn-up.sh,
reads the invocation's journal and, while the fresh-SA throttle's wait
it finds there still runs (`spi-s=0`; the old daemon's other deferrals
are not handed over), writes what is left of it to the holds file when
this start's LOCAL is the address the wait was earned on, or when that
address cannot be read; when LOCAL is another address, only the verdict
that the old registration is gone.

Tested on the dev phone (KPN) in builds of this series; not every path
has run there.
This commit is contained in:
Jorijn van der Graaf 2026-10-04 00:09:37 +02:00
commit 2fe991a14e
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
17 changed files with 275 additions and 27 deletions

View file

@ -735,14 +735,14 @@ std::int64_t NowEpoch() {
// The recovery policy's holds, kept for the next process: the network's
// word (a Retry-After, the schedule after a refused or throttled fresh
// attempt, a terminated binding's wait) outlives a restart of imsd. They
// are filed under the PDN's address — another one, or a reboot, starts
// clean — so the file names that address and the boot, and
// lives in /run. Seconds left at `written_at`, which is on the boot
// clock: no clock step moves it, and it runs through a suspend as the
// network's timers do. Whether the old registration is gone travels with
// them: a restart inside a hold must not resume over SAs the network has
// written off.
// attempt, a terminated binding's wait) outlives a restart of imsd, and
// an upgrade restarts it. They are filed under the PDN's address —
// another one, or a reboot, starts clean — so the file names that
// address and the boot, and lives in /run. Seconds left at
// `written_at`, which is on the boot clock: no clock step moves it, and
// it runs through a suspend as the network's timers do. Whether the old
// registration is gone travels with them: a restart inside a hold must
// not resume over SAs the network has written off.
std::int64_t BootSeconds() {
timespec ts{};
clock_gettime(CLOCK_BOOTTIME, &ts);
@ -1232,13 +1232,14 @@ private:
auto sa = imsd::ipsec::ParseExistingSa(state.out, policy.out, pcscf_, local_);
// The registration may sit on another address of the link: before
// 0.3.10 imsd registered on the kernel's temporary one (ims ledger
// F18). Resume there while it is still up — a restart keeps the
// registration for the price of a re-REGISTER, where a fresh one is
// an AKA run, a new SA pair and, when KPN refuses it, the old
// registration and a 21-minute wait (KPN refuses a fresh pair on an
// address whose registration is live and has accepted one on another
// address of the link meanwhile; other carriers' rules are unknown) —
// and move at the next fresh registration.
// F18). Resume there while it is still up — a restart, an upgrade
// among them, keeps the registration for the price of a re-REGISTER,
// where a fresh one is an AKA run, a new SA pair and, when KPN
// refuses it, the old registration and a 21-minute wait (KPN
// refuses a fresh pair on an address whose registration is live and
// has accepted one on another address of the link meanwhile; other
// carriers' rules are unknown) — and move at the next fresh
// registration.
if (!sa) {
for (const std::string& other : imsd::ipsec::SaLocals(state.out, pcscf_)) {
if (other == local_ || !OnLink(dev_, other)) continue;