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 ¶
- type AdvertisedLinkMode
- type Client
- func (c *Client) AllPrivateFlags() ([]*PrivateFlags, error)
- func (c *Client) Close() error
- func (c *Client) FEC(ifi Interface) (*FEC, error)
- func (c *Client) LinkInfo(ifi Interface) (*LinkInfo, error)
- func (c *Client) LinkInfos() ([]*LinkInfo, error)
- func (c *Client) LinkMode(ifi Interface) (*LinkMode, error)
- func (c *Client) LinkModes() ([]*LinkMode, error)
- func (c *Client) LinkState(ifi Interface) (*LinkState, error)
- func (c *Client) LinkStates() ([]*LinkState, error)
- func (c *Client) PrivateFlags(ifi Interface) (*PrivateFlags, error)
- func (c *Client) SetFEC(fec FEC) error
- func (c *Client) SetPrivateFlags(p PrivateFlags) error
- func (c *Client) SetWakeOnLAN(wol WakeOnLAN) error
- func (c *Client) WakeOnLAN(ifi Interface) (*WakeOnLAN, error)
- func (c *Client) WakeOnLANs() ([]*WakeOnLAN, error)
- type Duplex
- type Error
- type FEC
- type FECMode
- type FECModes
- type Interface
- type LinkInfo
- type LinkMode
- type LinkState
- type Port
- type PrivateFlags
- type WOLMode
- type WakeOnLAN
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdvertisedLinkMode ¶
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 (*Client) AllPrivateFlags ¶ added in v0.2.0
func (c *Client) AllPrivateFlags() ([]*PrivateFlags, error)
AllPrivateFlags returns Private Flags for each ethtool-supported interface on this system.
func (*Client) FEC ¶
FEC fetches the forward error correction (FEC) setting for the specified Interface.
func (*Client) LinkInfo ¶
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 ¶
LinkInfos fetches LinkInfo structures for each ethtool-supported interface on this system.
func (*Client) LinkMode ¶
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 ¶
LinkModes fetches LinkMode structures for each ethtool-supported interface on this system.
func (*Client) LinkState ¶
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 ¶
LinkStates fetches LinkState structures for each ethtool-supported interface on this system.
func (*Client) PrivateFlags ¶ added in v0.2.0
func (c *Client) PrivateFlags(ifi Interface) (*PrivateFlags, error)
PrivateFlags returns Private Flags for a single interface. See the type for a more in-depth explanation.
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) SetFEC ¶
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) SetPrivateFlags ¶ added in v0.2.0
func (c *Client) SetPrivateFlags(p PrivateFlags) error
SetPrivateFlags attempts to set the given private flags on the given interface. Flags does not need to contain the all flags, those not in it are left as-is.
Setting Private Flags requires elevated privileges and if the caller does not have permission, an error compatible with errors.Is(err, os.ErrPermission) will be returned.
Note that not all flags can be changed in all interface states, some might only be settable if the interface is down or are only settable once.
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 ¶
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 ¶
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 ¶
WakeOnLANs fetches WakeOnLAN information for each ethtool-supported interface on this system.
type 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.
type FEC ¶
A FEC contains the forward error correction (FEC) parameters for an interface.
func (*FEC) Supported ¶
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.
type FECModes ¶
type FECModes FECMode
A FECModes is a FEC mode bitmask of mode(s) supported by an interface.
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 LinkMode ¶
type LinkMode struct { Interface Interface SpeedMegabits int Ours, Peer []AdvertisedLinkMode Duplex Duplex }
LinkMode contains link mode information for an Ethernet interface.
type Port ¶
type Port int
A Port is the port type for a LinkInfo structure.
type PrivateFlags ¶ added in v0.2.0
type PrivateFlags struct { Interface Interface // Flags is a map of flag names to their active state, i.e. if the flag // is on or off. Flags map[string]bool }
PrivateFlags is a list of driver-specific flags which are either on or off. These are used to control behavior specific to a specific driver or device for which no generic API exists.
The flags which go in here are mostly undocumented other than in kernel source code, you can get the list of supported flags by calling PrivateFlags() and then searching for the returned names in Linux kernel sources.
This is technically a bitset but as the bit positions are not stable across kernel versions there is no reason to use that functionality, thus it is not exposed.
Note that these flags are in practice not fully covered by Linux's userspace ABI guarantees, it should be expected that a flag can go away.
type WOLMode ¶
type WOLMode int
A WOLMode is a Wake-on-LAN mode bitmask of mode(s) supported by an interface.