diff options
author | Christian Breunig <christian@breunig.cc> | 2023-10-22 19:03:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-22 19:03:21 +0200 |
commit | 282c32d51e2d013410fd39e33feba6e657894971 (patch) | |
tree | 10d24e60167dfb6b5720fa32d0a97dfd6ccb47cd /src | |
parent | 4595bca31a6f507ecb1567807f36b42bb6fe0e38 (diff) | |
parent | 3356e26a6a58f924209b9d79ec52cb09bb4fb3ea (diff) | |
download | vyos-1x-282c32d51e2d013410fd39e33feba6e657894971.tar.gz vyos-1x-282c32d51e2d013410fd39e33feba6e657894971.zip |
Merge pull request #2392 from vyos/mergify/bp/sagitta/pr-2386
vxlan: T5671: change port to IANA assigned default port (backport #2386)
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/interfaces-vxlan.py | 7 | ||||
-rwxr-xr-x | src/migration-scripts/interfaces/31-to-32 | 46 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/conf_mode/interfaces-vxlan.py b/src/conf_mode/interfaces-vxlan.py index 05f68112a..ff8144e74 100755 --- a/src/conf_mode/interfaces-vxlan.py +++ b/src/conf_mode/interfaces-vxlan.py @@ -168,6 +168,13 @@ def verify(vxlan): verify_address(vxlan) verify_bond_bridge_member(vxlan) verify_mirror_redirect(vxlan) + + # We use a defaultValue for port, thus it's always safe to use + if vxlan['port'] == '8472': + Warning('Starting from VyOS 1.4, the default port for VXLAN '\ + 'has been changed to 4789. This matches the IANA assigned '\ + 'standard port number!') + return None def generate(vxlan): diff --git a/src/migration-scripts/interfaces/31-to-32 b/src/migration-scripts/interfaces/31-to-32 new file mode 100755 index 000000000..35b397c39 --- /dev/null +++ b/src/migration-scripts/interfaces/31-to-32 @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2023 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# T5671: change port to IANA assigned default port + +from sys import argv +from sys import exit +from vyos.configtree import ConfigTree + +if len(argv) < 2: + print("Must specify file name!") + exit(1) + +file_name = argv[1] +with open(file_name, 'r') as f: + config_file = f.read() + base = ['interfaces', 'vxlan'] + +config = ConfigTree(config_file) +if not config.exists(base): + # Nothing to do + exit(0) + +for vxlan in config.list_nodes(base): + if not config.exists(base + ['port']): + config.set(base + [vxlan, 'port'], value='8472') + +try: + with open(file_name, 'w') as f: + f.write(config.to_string()) +except OSError as e: + print(f'Failed to save the modified config: {e}') + exit(1) |