🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: muc.lists.freebsd.bugs
1 messages
1 total messages Started by bugzilla-noreply Fri, 06 Nov 2026 13:27
[Bug 300556] if_ipsec(4): output encapsulation follows stale tunnel binding after SADB endpoint change (MOBIKE / peer re-dial) -...
#388
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads