ethtool

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2023 License: MIT Imports: 9 Imported by: 7

README

ethtool Test Status Go Reference Go Report Card

Package ethtool allows control of the Linux ethtool generic netlink interface. For more information, see: https://www.kernel.org/doc/html/latest/networking/ethtool-netlink.html.

Documentation

Overview

Package ethtool allows control of the Linux ethtool generic netlink interface. For more information, see: https://www.kernel.org/doc/html/latest/networking/ethtool-netlink.html.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvertisedLinkMode

type AdvertisedLinkMode struct {
	Index int
	Name  string
}

An AdvertisedLinkMode is a link mode that an interface advertises it is capable of using.

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client can manipulate the ethtool netlink interface.

func New

func New() (*Client, error)

New creates a Client which can issue ethtool commands.

func (*Client) Close

func (c *Client) Close() error

Close cleans up the Client's resources.

func (*Client) FEC

func (c *Client) FEC(ifi Interface) (*FEC, error)

FEC fetches the forward error correction (FEC) setting for the specified Interface.

func (*Client) LinkInfo

func (c *Client) LinkInfo(ifi Interface) (*LinkInfo, error)

LinkInfo fetches LinkInfo for the specified Interface.

If the requested device does not exist or is not supported by the ethtool interface, an error compatible with errors.Is(err, os.ErrNotExist) will be returned.

func (*Client) LinkInfos

func (c *Client) LinkInfos() ([]*LinkInfo, error)

LinkInfos fetches LinkInfo structures for each ethtool-supported interface on this system.

func (*Client) LinkMode

func (c *Client) LinkMode(ifi Interface) (*LinkMode, error)

LinkMode fetches LinkMode data for the specified Interface.

If the requested device does not exist or is not supported by the ethtool interface, an error compatible with errors.Is(err, os.ErrNotExist) will be returned.

func (*Client) LinkModes

func (c *Client) LinkModes() ([]*LinkMode, error)

LinkModes fetches LinkMode structures for each ethtool-supported interface on this system.

func (*Client) LinkState

func (c *Client) LinkState(ifi Interface) (*LinkState, error)

LinkState fetches LinkState data for the specified Interface.

If the requested device does not exist or is not supported by the ethtool interface, an error compatible with errors.Is(err, os.ErrNotExist) will be returned.

func (*Client) LinkStates

func (c *Client) LinkStates() ([]*LinkState, error)

LinkStates fetches LinkState structures for each ethtool-supported interface on this system.

func (*Client) SetFEC

func (c *Client) SetFEC(fec FEC) error

SetFEC sets the forward error correction (FEC) parameters for the Interface in fec.

Setting FEC parameters requires elevated privileges and if the caller does not have permission, an error compatible with errors.Is(err, os.ErrPermission) will be returned.

If the requested device does not exist or is not supported by the ethtool interface, an error compatible with errors.Is(err, os.ErrNotExist) will be returned.

func (*Client) SetWakeOnLAN

func (c *Client) SetWakeOnLAN(wol WakeOnLAN) error

SetWakeOnLAN sets the WakeOnLAN parameters for the Interface in wol.

Setting Wake-on-LAN parameters requires elevated privileges and if the caller does not have permission, an error compatible with errors.Is(err, os.ErrPermission) will be returned.

If the requested device does not exist or is not supported by the ethtool interface, an error compatible with errors.Is(err, os.ErrNotExist) will be returned.

func (*Client) WakeOnLAN

func (c *Client) WakeOnLAN(ifi Interface) (*WakeOnLAN, error)

WakeOnLAN fetches WakeOnLAN parameters for the specified Interface.

Fetching Wake-on-LAN information requires elevated privileges and if the caller does not have permission, an error compatible with errors.Is(err, os.ErrPermission) will be returned.

If the requested device does not exist or is not supported by the ethtool interface, an error compatible with errors.Is(err, os.ErrNotExist) will be returned.

func (*Client) WakeOnLANs

func (c *Client) WakeOnLANs() ([]*WakeOnLAN, error)

WakeOnLANs fetches WakeOnLAN information for each ethtool-supported interface on this system.

type Duplex

type Duplex int

A Duplex is the link duplex type for a LinkMode structure.

const (
	Half    Duplex = 0x00
	Full    Duplex = 0x01
	Unknown Duplex = 0xff
)

Possible Duplex type values.

func (Duplex) String

func (i Duplex) String() string

type Error

type Error struct {
	Message string
	Err     error
}

An Error is an error value produced by the kernel due to a bad ethtool netlink request. Typically the Err will be of type *netlink.OpError.

func (*Error) Error

func (e *Error) Error() string

Error implements error.

func (*Error) Is

func (e *Error) Is(target error) bool

Is enables Error comparison with sentinel errors that are part of the Client's API contract such as os.ErrNotExist and os.ErrPermission.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap unwraps the internal Err field for use with errors.Unwrap.

type FEC

type FEC struct {
	Interface Interface
	Modes     FECModes
	Active    FECMode
	Auto      bool
}

A FEC contains the forward error correction (FEC) parameters for an interface.

func (*FEC) Supported

func (f *FEC) Supported() FECModes

Supported returns the supported/configured FEC modes. Some drivers report supported, others configured. See https://kernel.googlesource.com/pub/scm/network/ethtool/ethtool/+/2b3ddcb35357ae34ed0a6ae2bb006dcdaec353a9

type FECMode

type FECMode int

A FECMode is a FEC mode bit value (single element bitmask) specifying the active mode of an interface.

func (FECMode) String

func (f FECMode) String() string

String implements fmt.Stringer.

type FECModes

type FECModes FECMode

A FECModes is a FEC mode bitmask of mode(s) supported by an interface.

func (FECModes) String

func (f FECModes) String() string

String implements fmt.Stringer.

type Interface

type Interface struct {
	// Callers may choose to set either Index, Name, or both fields. Note that
	// if both are set, the kernel will verify that both Index and Name are
	// associated with the same interface. If they are not, an error will be
	// returned.
	Index int
	Name  string
}

An Interface is an ethtool netlink Ethernet interface. Interfaces are used to identify an Ethernet interface being queried by its index and/or name.

type LinkInfo

type LinkInfo struct {
	Interface Interface
	Port      Port
}

LinkInfo contains link settings for an Ethernet interface.

type LinkMode

type LinkMode struct {
	Interface     Interface
	SpeedMegabits int
	Ours, Peer    []AdvertisedLinkMode
	Duplex        Duplex
}

LinkMode contains link mode information for an Ethernet interface.

type LinkState

type LinkState struct {
	Interface Interface
	Link      bool
}

LinkState contains link state information for an Ethernet interface.

type Port

type Port int

A Port is the port type for a LinkInfo structure.

const (
	TwistedPair  Port = 0x00
	AUI          Port = 0x01
	MII          Port = 0x02
	Fibre        Port = 0x03
	BNC          Port = 0x04
	DirectAttach Port = 0x05
	None         Port = 0xef
	Other        Port = 0xff
)

Possible Port type values.

func (Port) String

func (i Port) String() string

type WOLMode

type WOLMode int

A WOLMode is a Wake-on-LAN mode bitmask of mode(s) supported by an interface.

const (
	PHY         WOLMode = 1 << 0
	Unicast     WOLMode = 1 << 1
	Multicast   WOLMode = 1 << 2
	Broadcast   WOLMode = 1 << 3
	ARP         WOLMode = 1 << 4
	Magic       WOLMode = 1 << 5
	MagicSecure WOLMode = 1 << 6
	Filter      WOLMode = 1 << 7
)

Possible Wake-on-LAN mode bit flags.

func (WOLMode) String

func (m WOLMode) String() string

String returns the string representation of a WOLMode bitmask.

type WakeOnLAN

type WakeOnLAN struct {
	Interface Interface
	Modes     WOLMode
}

A WakeOnLAN contains the Wake-on-LAN parameters for an interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL