diff options
author | Christian Breunig <christian@breunig.cc> | 2023-09-19 18:48:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-19 18:48:09 +0200 |
commit | e570044ff8a81cbcfc340df5c8a33763a6962af3 (patch) | |
tree | 1ba3123b08fdb08dfc45295091a461cc39046dc0 /python/vyos/ifconfig/ethernet.py | |
parent | 38cab26959ded78a737db2272fe25106a2de47b0 (diff) | |
parent | 0984a36f6d6427bb6cb665002be3e67c4a72ff9d (diff) | |
download | vyos-1x-e570044ff8a81cbcfc340df5c8a33763a6962af3.tar.gz vyos-1x-e570044ff8a81cbcfc340df5c8a33763a6962af3.zip |
Merge pull request #2288 from sarthurdev/flowtable
firewall: T4502: Update to flowtable CLI
Diffstat (limited to 'python/vyos/ifconfig/ethernet.py')
-rw-r--r-- | python/vyos/ifconfig/ethernet.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py index 24ce3a803..285542057 100644 --- a/python/vyos/ifconfig/ethernet.py +++ b/python/vyos/ifconfig/ethernet.py @@ -57,6 +57,10 @@ class EthernetIf(Interface): 'validate': lambda v: assert_list(v, ['on', 'off']), 'possible': lambda i, v: EthernetIf.feature(i, 'gso', v), }, + 'hw-tc-offload': { + 'validate': lambda v: assert_list(v, ['on', 'off']), + 'possible': lambda i, v: EthernetIf.feature(i, 'hw-tc-offload', v), + }, 'lro': { 'validate': lambda v: assert_list(v, ['on', 'off']), 'possible': lambda i, v: EthernetIf.feature(i, 'lro', v), @@ -222,6 +226,25 @@ class EthernetIf(Interface): print('Adapter does not support changing generic-segmentation-offload settings!') return False + def set_hw_tc_offload(self, state): + """ + Enable hardware TC flow offload. State can be either True or False. + Example: + >>> from vyos.ifconfig import EthernetIf + >>> i = EthernetIf('eth0') + >>> i.set_hw_tc_offload(True) + """ + if not isinstance(state, bool): + raise ValueError('Value out of range') + + enabled, fixed = self.ethtool.get_hw_tc_offload() + if enabled != state: + if not fixed: + return self.set_interface('hw-tc-offload', 'on' if state else 'off') + else: + print('Adapter does not support changing hw-tc-offload settings!') + return False + def set_lro(self, state): """ Enable Large Receive offload. State can be either True or False. @@ -358,6 +381,9 @@ class EthernetIf(Interface): # GSO (generic segmentation offload) self.set_gso(dict_search('offload.gso', config) != None) + # GSO (generic segmentation offload) + self.set_hw_tc_offload(dict_search('offload.hw-tc-offload', config) != None) + # LRO (large receive offload) self.set_lro(dict_search('offload.lro', config) != None) |