🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.freebsd.bugs
Article #388

[Bug 300556] if_ipsec(4): output encapsulation follows stale tunnel binding after SADB endpoint change (MOBIKE / peer re-dial) -...

#388
From: bugzilla-noreply
Date: Fri, 06 Nov 2026 13:27
163 lines
8496 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300556

            Bug ID: 300556
           Summary: if_ipsec(4): output encapsulation follows stale tunnel
                    binding after SADB endpoint change (MOBIKE / peer
                    re-dial) - silent one-way tunnel
           Product: Base System
           Version: 15.1-RELEASE
          Hardware: amd64
               URL: https://lists.freebsd.org/archives/freebsd-net/2026-No
                    vember/009614.html
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: mykola@lainlounge.org

Environment
-----------

FreeBSD 15.1-RELEASE-p6 (amd64). Route-based IPsec concentration hub:
one if_ipsec(4) clone per peer leg (reqid-bound), inner addresses on
ipsecN, BIRD exchanging BGP/BFD over the inner links. strongSwan 6.1.0
(swanctl, kernel-pfkey), responder connections with remote %any,
mobike=yes, dpd_delay 30s, children start_action=none + updown hook.
Peers are dynamic-WAN sites (PPPoE/DHCP/CGNAT; Linux VTI/XFRM
initiators and RouterOS) - their outer addresses change on re-dial,
which is exactly why MOBIKE is enabled.

All addresses below are sanitized to RFC 5737 documentation ranges.

Problem
-------

if_ipsec(4) output encapsulation uses the interface's tunnel binding
(the addresses set with `ifconfig ipsecN tunnel <local> <remote>`),
not the current SADB entry for the interface's reqid. When a peer's
outer address changes and the SA endpoint is updated (MOBIKE update,
or peer re-dial), the interface binding keeps pointing at the old
address.

Inbound decapsulation still works (SA lookup by SPI), so the failure
mode is a silent one-way tunnel: IKE ESTABLISHED, CHILD INSTALLED,
inbound ESP with incrementing sequence numbers, zero outbound ESP
toward the new address. IKE-level DPD keeps working - replies are
sent to the current packet source - so the control plane reports
healthy while the data plane is black-holed. Nothing logs an error
at any layer.

Two production incidents of this class:

* 2026-10-24 (~6h45m dead leg): a dual-stack peer's SA outer was
  migrated to IPv6 via MOBIKE. if_ipsec carries a single v4 tunnel
  binding; outbound ESP froze (SA alive, out-SA 0 packets).

* 2026-10-31 (~5h33m dead leg): a single-stack peer re-dialed PPPoE
  and received a different IPv4 (192.0.2.10 -> 198.51.100.10).
  Observations during the wedge:

    - swanctl --list-sas: IKE ESTABLISHED, remote @ 198.51.100.10,
      CHILD INSTALLED (the peer had rekeyed the CHILD under the old
      IKE)
    - ifconfig ipsecN: tunnel peer still 192.0.2.10
    - tcpdump on the hub WAN: inbound ESP from 198.51.100.10 with
      incrementing seq; no outbound ESP toward 198.51.100.10
      (outbound was being encapsulated toward the dead 192.0.2.10)
    - BFD down, BGP Connect; the hub kernel even answered TCP RSTs
      through the working decap path, which made the leg look
      half-alive from the peer side

  Recovery required full IKE re-establishment (terminate + fresh
  IKE_AUTH), which re-runs our updown hook and re-pins the binding.
  CHILD rekeys do not move the binding.

Steps to reproduce
------------------

Deterministic lab recipe (two VMs, no NAT needed):

1. Hub (FreeBSD 15.1): create the interface and set the binding as
   an updown hook would at establishment:

        ifconfig ipsec0 create reqid 10
        ifconfig ipsec0 tunnel 192.0.2.1 198.51.100.10
        ifconfig ipsec0 10.0.0.0/31        # inner address

   strongSwan responder connection: remote %any, mobike=yes,
   dpd_delay 30s, CHILD start_action=none, kernel-pfkey.

2. Peer (any MOBIKE-capable initiator): establish IKEv2 + ESP;
   verify two-way inner traffic (ping both directions over ipsec0).

3. Change the peer's outer source address WITHOUT restarting IKE
   (re-IP its WAN interface, or force a NAT rebinding). MOBIKE UPDATE
   fires; the hub's SA remote becomes the new address.

4. Observe on the hub:

    - swanctl --list-sas          -> remote @ <new address>
    - ifconfig ipsec0             -> tunnel peer still <old address>
    - ping <peer inner address>   -> no reply (outbound ESP is being
                                     encapsulated toward <old>)
    - peer-side ping <hub inner>  -> still works (inbound decap intact)
    - tcpdump -ni <wan-iface> esp -> inbound ESP from <new>, seq
                                     incrementing; zero outbound ESP
                                     toward <new>

Expected result
---------------

Either:

  (a) if_ipsec output follows the current SADB endpoint selected by
      the interface's reqid - XFRM-interface-like semantics, where
      the interface carries no static endpoint at all and output SA
      selection is purely policy/reqid-driven; or

  (b) a documented, supported out-of-band mechanism to keep bindings
      in sync - ideally an RTM_* route-socket notification on SADB
      endpoint changes, so userland can re-pin bindings event-driven
      instead of polling.

Actual result
-------------

Output encapsulation silently follows a stale binding until a full
IKE re-establishment. No error, no log entry, DPD green, one-way
traffic.

Current workaround
------------------

An updown hook re-pins the binding at every fresh child-up:

    /sbin/ifconfig ipsec${reqid} tunnel "${me}" "${peer}"

(skipping v6 outers - SIOCSIFPHYADDR family clashes otherwise). This
covers fresh establishments only: rekeys and processed MOBIKE updates
do not re-run the hook, and strongSwan has no address-change hook we
could ride. We are adding a periodic reconciler that compares the
vici-reported IKE remote against the interface binding and re-pins on
drift, plus a watchdog that tears the IKE SA down when BFD stays down.

Questions
---------

1. Is out-of-band re-pinning the intended long-term pattern for
   if_ipsec(4) driven by PF_KEY daemons?
2. Would an SADB-change notification (RTM_* analog) be a welcome
   addition so bindings can be re-pinned event-driven?
3. Is XFRM-interface-like binding semantics work (SA-follow) on the
   roadmap for if_ipsec(4)?

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <bug-300556-227@https.bugs.freebsd.org/bugzilla/>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.szaf.org!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.szaf.org!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: bugzilla-noreply@freebsd.org
Newsgroups: muc.lists.freebsd.bugs
Subject: [Bug 300556] if_ipsec(4): output encapsulation follows stale tunnel
 binding after SADB endpoint change (MOBIKE / peer re-dial) - silent one-way
 tunnel
Date: Fri, 06 Nov 2026 13:27:33 +0000
Organization: Newsgate at muc.de e.V.
Sender: owner-freebsd-bugs@FreeBSD.org
Approved: news-admin@muc.de
Distribution: world
Message-ID: <bug-300556-227@https.bugs.freebsd.org/bugzilla/>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="78102"; mail-complaints-to="news-admin@muc.de"
X-Original-To: bugs@mlmmj.nyi.freebsd.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim;
	t=1793971653;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding;
	bh=q6MUV7Du9NqF8vfFwPpftIKiNmkaCfVMpS2TvH1rfPk=;
	b=o70d4WFYON/wPK668dpphAtxMC7X32MT21MS+y9DLsvtxpjfs2sWz/MoWVdiiSzVowVH9R
	U51+k5Ith1fE74ENTG5RRpB3RK5xYjO9HxFnNQoFzz0eNp6dgxX4HtKj0icecQ3R5+3SMZ
	dzf7jEQiAT4ERwpBVGhdGilMndVLGAluYmODncHt7hRSGpilThGlXcWPkPM1VzqvMeHxaF
	6Ht/p3yJ+H+bp0cva3sIdgeh0ZKVHiaXHzy9wNO/7EpBUZ6UbZAlCWCtTQtdNnTwMUHzSX
	RudIOLDErRcdN8xzQLweNSC9Jl2dNrjxB3EreP3n+o/r6WxPtZfxx8mJRsCdkA==
X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
Auto-Submitted: auto-generated
Precedence: list
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes