diff options
author | Christian Breunig <christian@breunig.cc> | 2024-06-26 15:35:10 +0200 |
---|---|---|
committer | Christian Breunig <christian@breunig.cc> | 2024-06-26 15:39:10 +0200 |
commit | e47d4fd385631236da6882233b09f6364cbb077b (patch) | |
tree | 5a6656a74e720502d97daf91d5055a386a53f71e /src/migration-scripts | |
parent | e458035e1ab56c7c21e53f26d8a39f00a62e5c9c (diff) | |
download | vyos-1x-e47d4fd385631236da6882233b09f6364cbb077b.tar.gz vyos-1x-e47d4fd385631236da6882233b09f6364cbb077b.zip |
interfaces: T6519: harden config migration if ethernet interface is missing
During a corner case where the configuration is migrated to a different system
with fewer ethernet interfaces, migration will fail during an image upgrade.
vyos.ethtool.Ethtool() is instantiated with an invalid interface leading to an
exception that kills the migrator
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-x | src/migration-scripts/interfaces/20-to-21 | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/migration-scripts/interfaces/20-to-21 b/src/migration-scripts/interfaces/20-to-21 index 14ad0fe4d..05a0c7237 100755 --- a/src/migration-scripts/interfaces/20-to-21 +++ b/src/migration-scripts/interfaces/20-to-21 @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2021 VyOS maintainers and contributors +# Copyright (C) 2021-2024 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 @@ -22,6 +22,7 @@ from sys import argv from vyos.ethtool import Ethtool from vyos.configtree import ConfigTree +from vyos.utils.network import interface_exists if len(argv) < 2: print("Must specify file name!") @@ -38,6 +39,10 @@ if not config.exists(base): exit(0) for ifname in config.list_nodes(base): + # Bail out early if interface vanished from system + if not interface_exists(ifname): + continue + eth = Ethtool(ifname) # If GRO is enabled by the Kernel - we reflect this on the CLI. If GRO is |