Package ethtool allows control of the Linux ethtool generic netlink interface.

Owner
Matt Layher
Software Engineer. Go, Linux, and open source software enthusiast. On and ever upward.
Matt Layher
Comments
  • TestIntegrationClientLinkInfos and TestIntegrationClientNetlinkStrict fail

    TestIntegrationClientLinkInfos and TestIntegrationClientNetlinkStrict fail

    On the Ubuntu builders, the Linux integration tests fail:

    === RUN   TestIntegrationClientLinkInfos
        client_linux_integration_test.go:21: failed to open client: netlink receive: no such file or directory
    --- FAIL: TestIntegrationClientLinkInfos (0.00s)
    === RUN   TestIntegrationClientNetlinkStrict
        client_linux_integration_test.go:42: failed to open client: netlink receive: no such file or directory
    --- FAIL: TestIntegrationClientNetlinkStrict (0.00s)
    

    Full log: https://launchpadlibrarian.net/638901184/buildlog_ubuntu-lunar-amd64.golang-github-mdlayher-ethtool_0.0~git20221205.a2a5239-1_BUILDING.txt.gz

  • TestIntegrationClientLinkInfos fails with

    TestIntegrationClientLinkInfos fails with "operation not supported"

    Test fails as follows on Ubuntu 22.10 (kernel 5.19) and Debian bookworm (kernel 6.0, as of writing):

    === RUN   TestIntegrationClientLinkInfos
        client_linux_integration_test.go:23: failed to fetch link infos: netlink receive: operation not supported
    --- FAIL: TestIntegrationClientLinkInfos (0.00s)
    

    A git bisect reveals that the test started failing from commit 07f2ecdc165a478e1c8d93e0d17201498ab3acf5 onwards.

    This failing test is preventing the packaging of this project in Debian, and subsequently the updating of the prometheus-node-exporter package, whose version 1.5.0 depends on this module.

  • TestFEC fails on s390x

    TestFEC fails on s390x

    Another test that fails on Debian CI infrastructure (s390x):

    === RUN   TestFEC
        client_linux_test.go:893: unexpected request header bytes (-want +got):
              []uint8{
            - 	0x10, 0x00, 0x01, 0x80, 0x0b, 0x00, 0x02, 0x00,                                                 // -|........|
            + 	0x00, 0x10, 0x80, 0x01, 0x00, 0x0b, 0x00, 0x02,                                                 // +|........|
              	0x65, 0x6e, 0x70, 0x37, 0x73, 0x30, 0x00, 0x00,                                                 //  |enp7s0..|
            - 	0x18, 0x00, 0x02, 0x80, 0x04, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x80, 0x0c, 0x00, 0x01, 0x80, // -|................|
            - 	0x07, 0x00, 0x02, 0x00, 0x52, 0x53,                                                             // -|....RS|
            + 	0x00, 0x18, 0x80, 0x02, 0x00, 0x04, 0x00, 0x01, 0x00, 0x10, 0x80, 0x03, 0x00, 0x0c, 0x80, 0x01, // +|................|
            + 	0x00, 0x07, 0x00, 0x02, 0x52, 0x53, 0x00,                                                       // +|....RS.|
              	0x00, 0x00, 0x05, 0x00, 0x03,                                                                   //  |.....|
            - 	0x00,                                                                                           // -|.|
              	0x00, 0x00, 0x00, 0x00,                                                                         //  |....|
              }
    --- FAIL: TestFEC (0.00s)
    

    s390x is big-endian, and the byte ordering in the "got" response looks almost certainly like this is a wrong endianness decode issue.

  • Add FEC() and SetFEC() methods to configure forward error correction

    Add FEC() and SetFEC() methods to configure forward error correction

    Some network card and SFP module combinations (e.g. Mellanox ConnectX-4 with a Flexoptix P.B1625G.10.AD) need to explicitly be configured to use RS forward error correction, otherwise they won’t link.

    I changed the get() function to only set the COMPACT_BITSETS flag for query commands so that the resulting request byte sequence matches the ethtool(8) byte sequence 1:1 (see TestFEC). Functionally, there is no change in behavior, as can be verified by looking at the corresponding Linux kernel code :)

  • TestLinuxClientLinkModes fails on s390x

    TestLinuxClientLinkModes fails on s390x

    Another test that fails on Debian CI infrastructure (s390x):

    === RUN   TestLinuxClientLinkModes
    === RUN   TestLinuxClientLinkModes/OK
        client_linux_test.go:292: unexpected link mode (-want +got):
              []*ethtool.LinkMode{
              	&{
              		Interface:     {Index: 1, Name: "eth0"},
              		SpeedMegabits: 1000,
              		Ours: []ethtool.AdvertisedLinkMode{
            - 			{Index: 4, Name: "1000baseT/Half"},
            + 			{Index: 28, Name: "56000baseCR4/Full"},
            - 			{Index: 5, Name: "1000baseT/Full"},
            + 			{Index: 29, Name: "56000baseSR4/Full"},
              		},
              		Peer:   nil,
              		Duplex: s"Half",
              	},
              	&{
              		Interface:     {Index: 2, Name: "eth1"},
              		SpeedMegabits: 10000,
              		Ours: []ethtool.AdvertisedLinkMode{
            - 			{Index: 10, Name: "FIBRE"},
            + 			{Index: 18, Name: "10000baseKX4/Full"},
            - 			{Index: 12, Name: "10000baseT/Full"},
            + 			{Index: 20, Name: "10000baseR/FEC"},
              		},
              		Peer:   nil,
              		Duplex: s"Full",
              	},
              }
    --- FAIL: TestLinuxClientLinkModes (0.00s)
        --- FAIL: TestLinuxClientLinkModes/OK (0.00s)
    

    s390x is big-endian, so possibly this is an endian decode issue.

  • Support for `ETHTOOL_MSG_TSINFO_GET` and `ETHTOOL_MSG_TSINFO_GET_REPLY`

    Support for `ETHTOOL_MSG_TSINFO_GET` and `ETHTOOL_MSG_TSINFO_GET_REPLY`

    It looks like ethtool can support querying a link to find out what kind of time-stamping capabilities it has with the -T option.

    > ethtool -T enp1s0
    Time stamping parameters for enp1s0:
    Capabilities:
            hardware-transmit     (SOF_TIMESTAMPING_TX_HARDWARE)
            software-transmit     (SOF_TIMESTAMPING_TX_SOFTWARE)
            hardware-receive      (SOF_TIMESTAMPING_RX_HARDWARE)
            software-receive      (SOF_TIMESTAMPING_RX_SOFTWARE)
            software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
            hardware-raw-clock    (SOF_TIMESTAMPING_RAW_HARDWARE)
    PTP Hardware Clock: 0
    Hardware Transmit Timestamp Modes:
            off                   (HWTSTAMP_TX_OFF)
            on                    (HWTSTAMP_TX_ON)
    Hardware Receive Filter Modes:
            none                  (HWTSTAMP_FILTER_NONE)
            all                   (HWTSTAMP_FILTER_ALL)
    

    The results of this query could then be used in setsockopt to enable these capabilities when using sendmsg and recvmsg and then parsing the control message that gets returned to get timestamps of userspace, kernel, and hardware. Enabling these options would work with https://pkg.go.dev/github.com/mdlayher/socket as long as Recvmsg and Sendmsg are used and there is a utility function for assisting in parsing the control message, but this is outside the scope of this issue.

    Would you be open to adding support for this query? I propose something along the lines of:

    // TimestampInfo holds the decoded response from `ethtool -T`
    // NOTE: I am not suggesting that this is the struct we should use, but
    // it is similar to how I have a working version already.
    type TimestampInfo struct {
      HardwareRx bool
      HardwareTx bool
    
      SoftwareRx bool
      SoftwareTx bool
    
      SoftwareSystem bool
      HardwareRaw bool
    
      PTPClockIndex int
    }
    
    // TimestampingInfo essentiall does `ethtool -T DEV` and decodes the response into *TimestampInfo
    func (c *Client) TimestampingInfo(ifi Interface) (*TimestampInfo, error) {
      // TBD
    }
    

    Additional References:

    • https://kernel.googlesource.com/pub/scm/network/ethtool/ethtool/+/refs/tags/v5.14/ethtool.c#1653
    • https://www.kernel.org/doc/html/latest/networking/timestamping.html
  • ethtool: add LinkModeUpdate and Client.UpdateLinkMode

    ethtool: add LinkModeUpdate and Client.UpdateLinkMode

    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.

  • ethtool: add Client.Watch(ctx) to watch for multicast group changes

    ethtool: add Client.Watch(ctx) to watch for multicast group changes

    The folks at Talos Systems (CC @smira) are setting up a manual ethtool genetlink watcher, but it'd be very reasonable for us to provide a nicer interface in this package for handling that functionality.

    See https://github.com/talos-systems/talos/blob/5811f4dda1b62848eefae9be56e8b91d443f4d34/internal/app/machined/pkg/controllers/network/watch/ethtool.go.

Perforator is a tool for recording performance metrics over subregions of a program using the Linux "perf" interface.

Perforator Perforator is a tool for recording performance metrics over subregions of a program (e.g., functions) using the Linux "perf" interface.

Dec 15, 2022
Di - A (very) WIP Go 1.18+ generic dependency injection package based on type reflection

di A (very) WIP Go 1.18+ generic dependency injection package based on type refl

Apr 26, 2022
Go library to interface with NEAR nodes' JSON-RPC interface

StreamingFast Solana library for Go Go library to interface with NEAR nodes' JSON-RPC interface Contributing Issues and PR in this repo related strict

Nov 9, 2021
📋 cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)

clipboard Cross platform (macOS/Linux/Windows/Android/iOS) clipboard package in Go import "golang.design/x/clipboard" Features Cross platform supports

Dec 24, 2022
This Go package allows you to set handler functions that run when named events occur

This Go package allows you to set handler functions that run when named events occur

Feb 10, 2022
A better Generic Pool (sync.Pool)
A better Generic Pool (sync.Pool)

This package is a thin wrapper over the Pool provided by the sync package. The Pool is an essential package to obtain maximum performance by reducing the number of memory allocations.

Dec 1, 2022
Go library for decoding generic map values into native Go structures and vice versa.

mapstructure mapstructure is a Go library for decoding generic map values to structures and vice versa, while providing helpful error handling. This l

Dec 28, 2022
conditiond is a generic constraint and policy evaluator.

conditiond conditiond is a generic constraint and policy evaluator. This tool lets you define constraints in data and evaluate them at run time. It's

Dec 5, 2022
Some utility functions for generic types in Go.

GOUF - Utility Functions for generic types Go team released Go 1.18 beta recently with support for Generics(a.k.a type parameters). This package provi

Apr 13, 2022
Generic Free List implementation to reuse memory and avoid allocations

gofl GOFL provides a Generic Free List implementation for Go. Installation This

Oct 17, 2022
Slice - provides generic Map, Reduce and Filter functions for Go.

slice slice is a simple Go package to provide generic versions of Map, Reduce and Filter on slices. I mainly wrote it as an exercise to get more famil

Jan 1, 2023
🚀 GoDI: Generic based DI in Go

?? GoDI: Generic based DI in Go Installation DI: go get -u github.com/MaximZayats/godi/ import "github.com/MaximZayats/godi/di" CMD: go get -u github.

Aug 14, 2022
Generic-based collection tools

go-collection go collection is a tool implemented using generic, it can help you process slice/map data quickly and easily convert between them. Note:

Dec 29, 2022
sigbypass4xx is a utility to automate well-know techniques used to bypass access control restrictions.

sigbypass4xx sigbypass4xx is a utility to automate well-know techniques used to bypass access control restrictions. Resources Usage Installation From

Nov 9, 2022
Automatically set GOMAXPROCS to match Linux container CPU quota.

automaxprocs Automatically set GOMAXPROCS to match Linux container CPU quota. Installation go get -u go.uber.org/automaxprocs Quick Start import _ "go

Dec 29, 2022
A Go library for the Linux Landlock sandboxing feature

Go Landlock library The Go Landlock library restricts the current processes' ability to use files, using Linux 5.13's Landlock feature. (Package docum

Dec 27, 2022
A fully Go userland with Linux bootloaders! u-root can create a one-binary root file system (initramfs) containing a busybox-like set of tools written in Go.

u-root Description u-root embodies four different projects. Go versions of many standard Linux tools, such as ls, cp, or shutdown. See cmds/core for m

Dec 29, 2022
Execute a binary from memory, without touching the disk. Linux only.
Execute a binary from memory, without touching the disk. Linux only.

Memit Execute a binary from memory, without touching the disk. Linux only. Available as both a Go module and a binary. Using the Go module The Command

Jan 5, 2023
Procswap is a simple application that allows you to prioritize processes on a Windows machine.
Procswap is a simple application that allows you to prioritize processes on a Windows machine.

Procswap is a simple application that allows you to prioritize processes on a Windows machine.

Mar 8, 2022