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:38:44 +0200
commit717894ece10532007ca44118bf63abe200239685 (patch)
treeaa4f949bc8b882c33041908df525bdda8ebf6216 /python/vyos
parent6f31b78d867f21405cc214697cf569b2df41288d (diff)
downloadvyos-1x-717894ece10532007ca44118bf63abe200239685.tar.gz
vyos-1x-717894ece10532007ca44118bf63abe200239685.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. (cherry picked from commit ce784a9fcb7199f87949f17777b7b736227c85b3)
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 80044c13e..cb03a006c 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -237,12 +237,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):
@@ -257,12 +256,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):
@@ -277,12 +275,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):
@@ -315,12 +312,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):
@@ -336,12 +332,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):
@@ -357,12 +352,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):
@@ -382,7 +376,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