ims-pdn-up: the firewall accepts the ims PDN's ESP itself, not only as an answer to a packet of the phone's
A request the network starts (a call to the phone, a text, a NOTIFY)
reaches the phone as an ESP packet on the ims netdev. That packet passes
the firewall's input chain before the kernel decapsulates it, and what
it carried passes the chain again afterwards. The script opened the
chain for the second, imsd's two protected ports. For the first there
was no rule, and pmOS's chain then lets an ESP packet in only as an
answer to one 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 dropped, and its retransmissions until
the phone next sends to that P-CSCF; imsd sees nothing of it.
What keeps the entry is the CRLF keepalive every 30 s, which goes out
over TCP and outside a call only.
The script now inserts a rule that accepts ESP on qmapmux*, under the
comment imsd-esp and with a check of its own, so that a ruleset which
carries the port rules already (fp6-img's 01_imsd.nft) gets it too. The
kernel drops an ESP packet no SA matches, and what an SA decapsulates
passes the chain again, under the rules a packet on qmapmux* meets
without ESP. Like the port rules the script inserts, the rule is in the
running ruleset only: a reload of the ruleset from its files removes it
until imsd next starts, so a ruleset whose files carry the port rules
has to carry this rule in them as well.
Tested: the script's firewall block by itself on the workstation against
nftables, in two network namespaces with an ESP SA pair between them and
the dev phone's ruleset as read from it (the fp6 journal's
2026-11-24-incoming-dropped-without-ping capture, bench-esp-rule.sh),
the tracker's timeout at 8 s: with 1.2.3's block a connection opened to
port 45062 from the network's side 11 s after the phone's last packet
got no answer, its ESP packets new to the tracker and none through the
chain; with this block the rule was inserted once and the same
connection accepted; an ESP packet with an SPI no SA has dropped by the
kernel behind the chain; a connection through the SA to another port
dropped by the chain; ESP on another interface and an AH packet not
accepted, ESP over IPv4 and ESP on a second qmapmux interface accepted;
the rule gone and the connection unanswered again after the ruleset was
loaded again from its file, and kept where the file carries the rule;
all three rules inserted on a ruleset without imsd's, and connections to
both ports accepted through them; nothing done where there is no inet
filter table. 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. On the dev phone on KPN the script
inserted the rule at imsd's start, above the port rules it found, and
the daemon resumed its registration; and with the tracker's timeout at 0
for the test, so that every ESP packet from the network came without an
entry, a text sent to the phone's own number was answered, reported and
delivered within a second with the rule (six such packets), and none of
the three reached the daemon in 20 s with the rule taken out (23 such
packets). 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).
This commit is contained in:
parent
0aea0dac7f
commit
bc0e70a17f
2 changed files with 93 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue