summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-30 21:25:38 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-30 21:27:53 +0200
commitce784a9fcb7199f87949f17777b7b736227c85b3 (patch)
tree8da4e6f22e5c0b342fe7765c2cdf465ec0e861f4 /python/vyos
parent50364a4b7a9de85fe59a6a4fb611bafb64c9f7f0 (diff)
downloadvyos-1x-ce784a9fcb7199f87949f17777b7b736227c85b3.tar.gz
vyos-1x-ce784a9fcb7199f87949f17777b7b736227c85b3.zip
vyos.ifconfig: T3619: only inform user about real offload change for invalid option
Commit 31169fa8 ("vyos.ifconfig: T3619: only set offloading options if supported by NIC") added a warning for the user if an offload option was about to change that was not possible at all (harware limit). Unfortunately the warning was even displayed if nothing was done at all. This got corrected.
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig/ethernet.py57
1 files changed, 25 insertions, 32 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index fbff789eb..696fec03b 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -236,12 +236,11 @@ class EthernetIf(Interface):
raise ValueError('Value out of range')
enabled, fixed = self.ethtool.get_generic_receive_offload()
- if not fixed:
- enabled = 'on' if enabled else 'off'
- if enabled != state:
+ if enabled != state:
+ if not fixed:
return self.set_interface('gro', 'on' if state else 'off')
-
- print('Adapter does not support changing generic-receive-offload settings!')
+ else:
+ print('Adapter does not support changing generic-receive-offload settings!')
return False
def set_gso(self, state):
@@ -256,12 +255,11 @@ class EthernetIf(Interface):
raise ValueError('Value out of range')
enabled, fixed = self.ethtool.get_generic_segmentation_offload()
- if not fixed:
- enabled = 'on' if enabled else 'off'
- if enabled != state:
- return self.set_interface('gro', 'on' if state else 'off')
-
- print('Adapter does not support changing generic-segmentation-offload settings!')
+ if enabled != state:
+ if not fixed:
+ return self.set_interface('gso', 'on' if state else 'off')
+ else:
+ print('Adapter does not support changing generic-segmentation-offload settings!')
return False
def set_lro(self, state):
@@ -276,12 +274,11 @@ class EthernetIf(Interface):
raise ValueError('Value out of range')
enabled, fixed = self.ethtool.get_large_receive_offload()
- if not fixed:
- enabled = 'on' if enabled else 'off'
- if enabled != state:
+ if enabled != state:
+ if not fixed:
return self.set_interface('gro', 'on' if state else 'off')
-
- print('Adapter does not support changing large-receive-offload settings!')
+ else:
+ print('Adapter does not support changing large-receive-offload settings!')
return False
def set_rps(self, state):
@@ -314,12 +311,11 @@ class EthernetIf(Interface):
raise ValueError('Value out of range')
enabled, fixed = self.ethtool.get_scatter_gather()
- if not fixed:
- enabled = 'on' if enabled else 'off'
- if enabled != state:
+ if enabled != state:
+ if not fixed:
return self.set_interface('gro', 'on' if state else 'off')
-
- print('Adapter does not support changing scatter-gather settings!')
+ else:
+ print('Adapter does not support changing scatter-gather settings!')
return False
def set_tso(self, state):
@@ -335,12 +331,11 @@ class EthernetIf(Interface):
raise ValueError('Value out of range')
enabled, fixed = self.ethtool.get_tcp_segmentation_offload()
- if not fixed:
- enabled = 'on' if enabled else 'off'
- if enabled != state:
+ if enabled != state:
+ if not fixed:
return self.set_interface('gro', 'on' if state else 'off')
-
- print('Adapter does not support changing tcp-segmentation-offload settings!')
+ else:
+ print('Adapter does not support changing tcp-segmentation-offload settings!')
return False
def set_ufo(self, state):
@@ -356,12 +351,11 @@ class EthernetIf(Interface):
raise ValueError('Value out of range')
enabled, fixed = self.ethtool.get_udp_fragmentation_offload()
- if not fixed:
- enabled = 'on' if enabled else 'off'
- if enabled != state:
+ if enabled != state:
+ if not fixed:
return self.set_interface('gro', 'on' if state else 'off')
-
- print('Adapter does not support changing udp-fragmentation-offload settings!')
+ else:
+ print('Adapter does not support changing udp-fragmentation-offload settings!')
return False
def set_ring_buffer(self, b_type, b_size):
@@ -381,7 +375,6 @@ class EthernetIf(Interface):
print(f'could not set "{b_type}" ring-buffer for {ifname}')
return output
-
def update(self, config):
""" General helper function which works on a dictionary retrived by
get_config_dict(). It's main intention is to consolidate the scattered