Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ethtool: add LinkModeUpdate and Client.UpdateLinkMode #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dshynkev
Copy link

This proposes an interface for partial updates of link mode information. Tests coming up: wanted to make sure the overall design was acceptable first. The motivation behind disjoining LinkMode and LinkModeUpdate is that:

  1. The sets of readable and writable fields are not the same, e.g. ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE is only readable and ETHTOOL_A_LINKMODES_LANES is only writable per docs.
  2. This allows for a natural (for golang) partial update interface via nullable fields.

One point on which I waver is whether slices should have encoding/json-type semantics (nil <> empty slice) as proposed here, or perhaps be pointers like everything else. Let me know what you think.

Copy link
Owner

@mdlayher mdlayher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice and tidy too. The genltest library is a bit awkward at times but I believe the existing tests should serve as a pretty good reference. Something I'd like to rework for netlink/genetlink v2, but such is life.

Thank you for contributing!

@@ -99,6 +99,14 @@ type LinkMode struct {
Duplex Duplex
}

// LinkModeUpdate contains an update to the link mode information
// for an Ethernet interface.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note something like "Zero-value fields are not sent to the kernel as part of the update.", and that covers the nil and empty slice cases. I'm good with empty slices here; *[]AdvertisedLinkMode would be pretty awkward. I can't think of any valid reason you would try to clear all the advertised link modes via an empty slice anyway.

@SuperQ
Copy link
Collaborator

SuperQ commented Jun 14, 2023

Ping, this needs a rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants