]> git.99rst.org Git - openwrt-packages.git/commitdiff
strongswan: rename 'local_ip' to 'local_addrs'
authorFlorian Eckert <redacted>
Thu, 23 Jul 2026 14:18:18 +0000 (16:18 +0200)
committerFlorian Eckert <redacted>
Mon, 3 Aug 2026 09:07:41 +0000 (11:07 +0200)
Rename the 'local_ip' UCI option to 'local_addrs' to match the
'swanctl.conf' 'local_addrs' directive, which accepts one or more
local addresses rather than implying a single fixed IP. The
previous name suggested only one address could be configured.

Store the option as a UCI list to allow specifying multiple local
addresses, consistent with how 'remote_addrs' is already handled.
If left empty, no 'local_addrs' line is written to 'swanctl.conf',
so strongswan falls back to its own default of '%any'.

Add a uci-defaults migration script to convert existing 'local_ip'
entries (whether stored as a plain option or as a list) to a
'local_addrs' list on upgrade.

Signed-off-by: Florian Eckert <redacted>
net/strongswan/files/etc/uci-defaults/strongswan
net/strongswan/files/swanctl.init

index 625ca8fd99208854cb8a07bed59aa48ed10e3fe9..9e5628acb0ba7247e284cbd6d2011656025494cc 100644 (file)
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+. /lib/functions.sh
 migrate_ipsec() {
        # Skip migration if the 'globals' section already exists
        uci show ipsec.globals 1>/dev/null 2>/dev/null
@@ -96,12 +97,34 @@ migrate_remote_gateway() {
        config_foreach migrate_remote_gateway_remote remote
 }
 
+migrate_local_ip_local() {
+       local cfg="$1"
+
+       local local_ip value
+
+       config_get local_ip "$cfg" local_ip ""
+       [ -z "$local_ip" ] && return
+
+       for value in $local_ip; do
+               uci add_list "ipsec.${cfg}.local_addrs=${value}"
+       done
+
+       uci -q delete "ipsec.${cfg}.local_ip"
+       uci commit ipsec
+}
+
+migrate_local_ip() {
+       config_load ipsec
+       config_foreach migrate_local_ip_local remote
+}
+
 main() {
        migrate_ipsec
        migrate_ignore_routing_tables
        migrate_local_nat
        migrate_gateway
        migrate_remote_gateway
+       migrate_local_ip
 }
 
 main
index 4ffbea57539519e80cb05685bc0ca304db6bcffc..1673c5a1f2f8dde13cd36c346cc0e9f51794bdae 100644 (file)
@@ -440,7 +440,6 @@ config_remote() {
        local auth_method
        local local_identifier
        local remote_identifier
-       local local_ip
        local keyingtries
        local dpddelay
        local encap
@@ -456,6 +455,7 @@ config_remote() {
        local send_cert
        local send_certreq
        local eap_id
+       local local_addrs
        local remote_addrs
        local local_sourceip
        local remote_ca_certs
@@ -468,7 +468,6 @@ config_remote() {
        config_get auth_method "$conf" authentication_method
        config_get local_identifier "$conf" local_identifier ""
        config_get remote_identifier "$conf" remote_identifier ""
-       config_get local_ip "$conf" local_ip "%any"
        config_get keyingtries "$conf" keyingtries "3"
        config_get dpddelay "$conf" dpddelay "30s"
        config_get_bool encap "$conf" encap 0
@@ -485,6 +484,7 @@ config_remote() {
        config_get_bool send_certreq "$conf" send_certreq 1
        config_get eap_id "$conf" eap_id "%any"
 
+       config_list_foreach "$conf" local_addrs append_var local_addrs ","
        config_list_foreach "$conf" remote_addrs append_var remote_addrs ","
        config_list_foreach "$conf" local_sourceip append_var local_sourceip ","
        config_list_foreach "$conf" remote_ca_certs append_var remote_ca_certs ","
@@ -536,7 +536,7 @@ config_remote() {
        swanctl_xappend0 "# config for $conf"
        swanctl_xappend0 "connections {"
        swanctl_xappend1 "$conf {"
-       swanctl_xappend2 "local_addrs = $local_ip"
+       [ -n "$local_addrs" ] && swanctl_xappend2 "local_addrs = $local_addrs"
        [ -n "$remote_addrs" ] && swanctl_xappend2 "remote_addrs = $remote_addrs"
        [ -n "$local_sourceip" ] && swanctl_xappend2 "vips = $local_sourceip"
        [ -n "$fragmentation" ] && swanctl_xappend2 "fragmentation = $fragmentation"
git clone https://git.99rst.org/PROJECT