Skip to content

Commit

Permalink
ethernet: T3891: add conditional code-path when doing speed/duplex ch…
Browse files Browse the repository at this point in the history
…anges

There is no need for the backend code to call ethtool and try to change speed or
duplex settings every time there is a change in the interface configuration,
but no change for the speed/duplex subnodes. This also makes the commit itself
faster when working with ethernet interfaces.

Bonus: no repeating CLI messages that the driver does not support speed/duplex
changes, as we do not change anything here.

Extension to commit f2ecc97 ("ethernet: T3891: honor auto-negotiation support
per NIC")
  • Loading branch information
c-po committed May 12, 2023
1 parent ace81a4 commit aea8922
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions python/vyos/ifconfig/ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,11 @@ def update(self, config):
self.set_tso(dict_search('offload.tso', config) != None)

# Set physical interface speed and duplex
if {'speed', 'duplex'} <= set(config):
speed = config.get('speed')
duplex = config.get('duplex')
self.set_speed_duplex(speed, duplex)
if 'speed_duplex_changed' in config:
if {'speed', 'duplex'} <= set(config):
speed = config.get('speed')
duplex = config.get('duplex')
self.set_speed_duplex(speed, duplex)

# Set interface ring buffer
if 'ring_buffer' in config:
Expand Down
9 changes: 8 additions & 1 deletion src/conf_mode/interfaces-ethernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from vyos.base import Warning
from vyos.config import Config
from vyos.configdict import get_interface_dict
from vyos.configdict import is_node_changed
from vyos.configverify import verify_address
from vyos.configverify import verify_dhcpv6
from vyos.configverify import verify_eapol
Expand Down Expand Up @@ -66,11 +67,17 @@ def get_config(config=None):
get_first_key=True, no_tag_node_value_mangle=True)

base = ['interfaces', 'ethernet']
_, ethernet = get_interface_dict(conf, base)
ifname, ethernet = get_interface_dict(conf, base)

if 'deleted' not in ethernet:
if pki: ethernet['pki'] = pki

tmp = is_node_changed(conf, base + [ifname, 'speed'])
if tmp: ethernet.update({'speed_duplex_changed': {}})

tmp = is_node_changed(conf, base + [ifname, 'duplex'])
if tmp: ethernet.update({'speed_duplex_changed': {}})

return ethernet

def verify(ethernet):
Expand Down

0 comments on commit aea8922

Please sign in to comment.