summaryrefslogtreecommitdiff
path: root/src/migration-scripts/interfaces
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-10-20 21:55:01 +0200
committerChristian Breunig <christian@breunig.cc>2023-10-20 21:59:23 +0200
commit6db8d3ded19f652b99231be0d705d76b598ac72a (patch)
tree1f28defdb3634162c15102c403c51aaceeda1288 /src/migration-scripts/interfaces
parent6116840936d3d47aa55cc127c52eedeacfa4198b (diff)
downloadvyos-1x-6db8d3ded19f652b99231be0d705d76b598ac72a.tar.gz
vyos-1x-6db8d3ded19f652b99231be0d705d76b598ac72a.zip
vxlan: T5671: change port to IANA assigned default port
Currently VyOS VXLAN implementation uses the Linux assigned port 8472 that predates the IANA assignment. As Most other vendors use the IANA assigned port, follow this guideline and use the new default port 4789. Existing configuration not defining an explicit port number will be migrated to the old default port number of 8472, keeping existing configurations work!
Diffstat (limited to 'src/migration-scripts/interfaces')
-rwxr-xr-xsrc/migration-scripts/interfaces/31-to-3246
1 files changed, 46 insertions, 0 deletions
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)