From 61487b13da8dc270907633a3140bd0cc2aa0926a Mon Sep 17 00:00:00 2001 From: Oleksandr Kuchmystyi Date: Wed, 31 Dec 2025 10:50:21 +0300 Subject: openvpn: T7633: Add support for 'data-ciphers-fallback' in site-to-site tunnels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Introduced new CLI option 'data-ciphers-fallback' for OpenVPN interfaces (used as fallback cipher in site-to-site mode) - Adjust migration 1‑to‑2 to skip migrating 'cipher' for site‑to‑site interfaces --- src/migration-scripts/openvpn/1-to-2 | 6 ++++++ src/migration-scripts/openvpn/4-to-5 | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/migration-scripts/openvpn/4-to-5 (limited to 'src/migration-scripts') diff --git a/src/migration-scripts/openvpn/1-to-2 b/src/migration-scripts/openvpn/1-to-2 index 83d6219d6..75360446c 100644 --- a/src/migration-scripts/openvpn/1-to-2 +++ b/src/migration-scripts/openvpn/1-to-2 @@ -25,11 +25,17 @@ def migrate(config: ConfigTree) -> None: # Remove 'encryption cipher' and add this value to 'encryption ncp-ciphers' # for server and client mode. # Site-to-site mode still can use --cipher option + mode_path = ['interfaces', 'openvpn', i, 'mode'] cipher_path = ['interfaces', 'openvpn', i, 'encryption', 'cipher'] ncp_cipher_path = ['interfaces', 'openvpn', i, 'encryption', 'ncp-ciphers'] + if config.exists(cipher_path): if config.exists(['interfaces', 'openvpn', i, 'shared-secret-key']): continue + # Only migrate if mode is not 'site-to-site' + if config.value_exists(mode_path, 'site-to-site'): + continue + cipher = config.return_value(cipher_path) config.delete(cipher_path) if cipher == 'none': diff --git a/src/migration-scripts/openvpn/4-to-5 b/src/migration-scripts/openvpn/4-to-5 new file mode 100644 index 000000000..5c7ee833c --- /dev/null +++ b/src/migration-scripts/openvpn/4-to-5 @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# Copyright VyOS maintainers and contributors +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see . +# +# T7633: This migration converts legacy 'encryption cipher' directives into +# 'encryption data-ciphers-fallback' for site-to-site mode tunnels. +# +# In modern OpenVPN (v2.6+), 'cipher' and 'data-ciphers' are not valid +# in site-to-site mode. +# The appropriate directive is now '--data-ciphers-fallback alg'. + +from vyos.configtree import ConfigTree + +def migrate(config: ConfigTree) -> None: + ovpn_intfs = config.list_nodes(['interfaces', 'openvpn'], path_must_exist=False) + for i in ovpn_intfs: + base_path = ['interfaces', 'openvpn', i] + mode_path = base_path + ['mode'] + cipher_path = base_path + ['encryption', 'cipher'] + + # Only migrate if mode is explicitly 'site-to-site' + if config.value_exists(mode_path, 'site-to-site'): + + # Rename 'encryption cipher' with 'encryption data-ciphers-fallback' + if config.exists(cipher_path): + config.rename(cipher_path, 'data-ciphers-fallback') -- cgit v1.2.3