Commit a79eb6858c for strongswan.org

commit a79eb6858cce3a264af2ec9bc776e79a97a8f3c4
Author: Tobias Brunner <tobias@strongswan.org>
Date:   Thu Apr 16 08:59:02 2026 +0200

    testing: Add marks to ikev2/mobike-nat-mappings to test their migration

diff --git a/testing/tests/ikev2/mobike-nat-mappings/description.txt b/testing/tests/ikev2/mobike-nat-mappings/description.txt
index cbf1714a17..28bca106ce 100644
--- a/testing/tests/ikev2/mobike-nat-mappings/description.txt
+++ b/testing/tests/ikev2/mobike-nat-mappings/description.txt
@@ -4,3 +4,6 @@ in the subnet behind. When the NAT router <b>moon</b> is restarted, the NAT
 mappings change. <b>alice</b> notices this when sending a DPD and signals the
 change via a MOBIKE ADDRESS_UPDATE notification to peer <b>sun</b>. <b>alice</b> sets
 a virtual IP of 10.3.0.3, so that the IPsec policies don't have to be changed.
+
+To test updating/migrating marks, <b>sun</b> sets all possible marks on the
+SAs it installs, which requires extra firewall rules.
diff --git a/testing/tests/ikev2/mobike-nat-mappings/evaltest.dat b/testing/tests/ikev2/mobike-nat-mappings/evaltest.dat
index 49f8463357..68e631e919 100644
--- a/testing/tests/ikev2/mobike-nat-mappings/evaltest.dat
+++ b/testing/tests/ikev2/mobike-nat-mappings/evaltest.dat
@@ -19,6 +19,10 @@ alice::swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-ho
 sun::  swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_MOON remote-port=5... remote-id=alice@strongswan.org.*protocol=ESP encap=yes spi-in.*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
 alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
 bob::  ping -c 1 10.3.0.3::64 bytes from 10.3.0.3: icmp_.eq=1::YES
+sun::ip xfrm state::mark 0x2/0xfffffffa output-mark 0x6/0xfffffff6::1
+sun::ip xfrm state::mark 0x3/0xfffffffb output-mark 0x5/0xfffffffd::1
+sun::ip xfrm policy::mark 0x2/0xfffffffa::2
+sun::ip xfrm policy::mark 0x3/0xfffffffb::1
 moon::tcpdump::moon.strongswan.org.*sun.strongswan.org.*: UDP-encap: ESP.*::4
 moon::tcpdump::sun.strongswan.org.*moon.strongswan.org.*: UDP-encap: ESP.*::5
 bob::tcpdump::10.3.0.3.*bob.strongswan.org.*ICMP echo request::2
diff --git a/testing/tests/ikev2/mobike-nat-mappings/hosts/sun/etc/swanctl/swanctl.conf b/testing/tests/ikev2/mobike-nat-mappings/hosts/sun/etc/swanctl/swanctl.conf
index 3fe5d2df97..ed82a707b0 100644
--- a/testing/tests/ikev2/mobike-nat-mappings/hosts/sun/etc/swanctl/swanctl.conf
+++ b/testing/tests/ikev2/mobike-nat-mappings/hosts/sun/etc/swanctl/swanctl.conf
@@ -17,6 +17,13 @@ connections {
       children {
          mobike {
             local_ts = 10.2.0.0/16
+
+            mark_in = 2/0xfffffffa
+            mark_in_sa = yes
+            mark_out = 3/0xfffffffb
+            # this is chosen so mark_in matches after applying its mask
+            set_mark_in = 6/0xfffffff6
+            set_mark_out = 5/0xfffffffd
          }
       }
    }
diff --git a/testing/tests/ikev2/mobike-nat-mappings/pretest.dat b/testing/tests/ikev2/mobike-nat-mappings/pretest.dat
index 3f0368efc1..926516d06d 100644
--- a/testing/tests/ikev2/mobike-nat-mappings/pretest.dat
+++ b/testing/tests/ikev2/mobike-nat-mappings/pretest.dat
@@ -1,5 +1,8 @@
 alice::iptables-restore < /etc/iptables.rules
 sun::iptables-restore < /etc/iptables.rules
+# make sure packets match the marks set for testing
+sun::iptables -t mangle -A PREROUTING -s PH_IP_MOON -j MARK --set-mark 2
+sun::iptables -t mangle -A PREROUTING -d 10.3.0.3 -j MARK --set-mark 3
 moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p udp -j SNAT --to-source PH_IP_MOON:1024-1100
 moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-source PH_IP_MOON:2000-2100
 alice::systemctl start strongswan