From 32c5c4cece5f58e51065363608d1b3f78a046d29 Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Tue, 9 Jun 2026 17:28:49 +0300 Subject: ethtool: T8964: Fix crash when NIC does not support ring-buffer configuration --- python/vyos/ethtool.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'python') diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py index 34c884e0b..85e228ede 100644 --- a/python/vyos/ethtool.py +++ b/python/vyos/ethtool.py @@ -181,15 +181,17 @@ class Ethtool: # Configuration of RX/TX ring-buffers is not supported on every device, # thus when it's impossible return None if rx_tx not in ['rx', 'tx']: - ValueError('Ring-buffer type must be either "rx" or "tx"') - return str(self._ring_buffer.get(f'{rx_tx}-max', None)) + raise ValueError('Ring-buffer type must be either "rx" or "tx"') + value = self._ring_buffer.get(f'{rx_tx}-max') if self._ring_buffer else None + return str(value) if value is not None else None def get_ring_buffer(self, rx_tx): # Configuration of RX/TX ring-buffers is not supported on every device, # thus when it's impossible return None if rx_tx not in ['rx', 'tx']: - ValueError('Ring-buffer type must be either "rx" or "tx"') - return str(self._ring_buffer.get(rx_tx, None)) + raise ValueError('Ring-buffer type must be either "rx" or "tx"') + value = self._ring_buffer.get(rx_tx) if self._ring_buffer else None + return str(value) if value is not None else None def check_speed_duplex(self, speed, duplex): """ Check if the passed speed and duplex combination is supported by -- cgit v1.2.3