uci -q commit ipsec
}
+migrate_ignore_routing_tables() {
+ local tables table count
+
+ # Check whether we still have the old config option ( not a 'list')
+ count="$(grep -c -E "^[[:space:]]*option ignore_routing_tables" /etc/config/ipsec)"
+ [ "$count" = "0" ] && return
+
+ tables="$(uci -q get "ipsec.globals.ignore_routing_tables")"
+ uci -q delete "ipsec.globals.ignore_routing_tables"
+ for table in $tables; do
+ uci add_list "ipsec.globals.ignore_routing_tables=${table}"
+ done
+
+ uci commit ipsec
+}
+
main() {
migrate_ipsec
+ migrate_ignore_routing_tables
}
main
swanctl_xappend0 ""
}
+config_charon_ignore_routing_tables() {
+ local conf="$1"
+
+ local routing_table_list routing_table ignore_routing_tables
+
+ config_list_foreach "$conf" ignore_routing_tables append_var routing_table_list
+ for routing_table in $routing_table_list; do
+ local routing_table_id
+ if [ "$routing_table" -ge 0 ] 2>/dev/null; then
+ routing_table_id=$routing_table
+ else
+ routing_table_id=$(sed -n '/[ \t]*[0-9]\+[ \t]\+'$routing_table'[ \t]*$/s/[ \t]*\([0-9]\+\).*/\1/p' /etc/iproute2/rt_tables)
+ fi
+
+ [ -n "$routing_table_id" ] && append ignore_routing_tables "$routing_table_id"
+ done
+
+ [ -n "$ignore_routing_tables" ] && swan_xappend1 "ignore_routing_tables = $ignore_routing_tables"
+}
+
config_charon_install_routes() {
local conf="$1"
config_strongswan_generate() {
local conf="$1"
- local debug routing_tables_ignored device_list
+ local debug device_list
- local routing_table
- local routing_table_id
local interface
local interface_list
config_get debug "$conf" debug 0
- # prepare extra charon config option ignore_routing_tables
- for routing_table in $(config_get "$conf" "ignore_routing_tables"); do
- if [ "$routing_table" -ge 0 ] 2>/dev/null; then
- routing_table_id=$routing_table
- else
- routing_table_id=$(sed -n '/[ \t]*[0-9]\+[ \t]\+'$routing_table'[ \t]*$/s/[ \t]*\([0-9]\+\).*/\1/p' /etc/iproute2/rt_tables)
- fi
-
- [ -n "$routing_table_id" ] && append routing_tables_ignored "$routing_table_id"
- done
-
config_list_foreach "$conf" interface append_var interface_list
if [ -z "$interface_list" ]; then
swan_xappend0 "charon {"
config_charon_install_routes "$conf"
- [ -n "$routing_tables_ignored" ] && swan_xappend1 "ignore_routing_tables = $routing_tables_ignored"
+ config_charon_ignore_routing_tables "$conf"
[ -n "$device_list" ] && swan_xappend1 "interfaces_use = $device_list"
swan_xappend1 "start-scripts {"
swan_xappend2 "load-all = /usr/sbin/swanctl --load-all --noprompt"