Skip to content

Commit

Permalink
Merge pull request #3725 from vyos/mergify/bp/sagitta/pr-3724
Browse files Browse the repository at this point in the history
interfaces: T6519: harden config migration if ethernet interface is missing (backport #3724)
  • Loading branch information
c-po authored Jun 26, 2024
2 parents 621dd08 + b9fb916 commit 679c474
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions python/vyos/ethtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import re

from json import loads
from vyos.utils.network import interface_exists
from vyos.utils.process import popen

# These drivers do not support using ethtool to change the speed, duplex, or
Expand Down Expand Up @@ -64,6 +65,9 @@ class Ethtool:

def __init__(self, ifname):
# Get driver used for interface
if not interface_exists(ifname):
raise ValueError(f'Interface "{ifname}" does not exist!')

out, _ = popen(f'ethtool --driver {ifname}')
driver = re.search(r'driver:\s(\w+)', out)
if driver:
Expand Down
7 changes: 6 additions & 1 deletion src/migration-scripts/interfaces/20-to-21
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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!")
Expand All @@ -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
Expand Down

0 comments on commit 679c474

Please sign in to comment.