Documentation ¶
Overview ¶
This package provides a sideband control interface to an XETH driver. Usage,
task, err := xeth.Start(dev) if err { panic(err) } task.DumpIfInfo() for t = true; t; { select { case <-goes.Stop: return case buf := <-task.RxCh: if t = xeth.Class(buf) != xeth.ClassBreak; t { msg := xeth.Parse(buf) ... xeth.Pool(msg) } } } ... task.DumpFib() for t := true; t; { select { case <-goes.Stop: return case buf := <-task.RxCh: if t = xeth.Class(buf) != xeth.ClassBreak; t { msg := xeth.Parse(buf) ... xeth.Pool(msg) } } } ... goes.WG.Add(1) go func() { defer goes.WG.Done() for { select { case <-goes.Stop: return case buf := <-task.RxCh: msg := xeth.Parse(buf) ... xeth.Pool(msg) } } }() ...
Index ¶
- Constants
- Variables
- func Class(buf Buffer) int
- func LinkRange(f func(xid Xid, l *Link) bool)
- func NetNsRange(f func(ns NetNs) bool)
- func Parse(buf Buffer) interface{}
- func Pool(msg interface{})
- func Provision(dev, val string) error
- func RxIfInfo(msg *internal.MsgIfInfo) (note interface{})
- func Valid(xid Xid) bool
- type AutoNeg
- type Break
- type Buffer
- type Counter
- type DevAddIPNet
- type DevDel
- type DevDelIPNet
- type DevDown
- type DevDump
- type DevEthtoolFlags
- type DevEthtoolSettings
- type DevJoin
- type DevKind
- type DevLinkModesAdvertising
- type DevLinkModesLPAdvertising
- type DevLinkModesSupported
- type DevNew
- type DevPort
- type DevQuit
- type DevReg
- type DevUnreg
- type DevUp
- type Duplex
- type EthtoolFlagBits
- type EthtoolLinkModeBits
- type FibEntry
- type FibEntryEvent
- type Link
- func (l *Link) EthtoolAutoNeg(set ...AutoNeg) (an AutoNeg)
- func (l *Link) EthtoolDevPort(set ...DevPort) (devport DevPort)
- func (l *Link) EthtoolDuplex(set ...Duplex) (duplex Duplex)
- func (l *Link) EthtoolFlags(set ...EthtoolFlagBits) (bits EthtoolFlagBits)
- func (l *Link) EthtoolSpeed(set ...uint32) (mbps uint32)
- func (l *Link) IPNets(set ...[]*net.IPNet) (nets []*net.IPNet)
- func (l *Link) IfInfoDevKind(set ...DevKind) (devkind DevKind)
- func (l *Link) IfInfoFlags(set ...net.Flags) (flags net.Flags)
- func (l *Link) IfInfoHardwareAddr(set ...net.HardwareAddr) (ha net.HardwareAddr)
- func (l *Link) IfInfoIfIndex(set ...int32) (ifindex int32)
- func (l *Link) IfInfoName(set ...string) (name string)
- func (l *Link) IfInfoNetNs(set ...NetNs) (netns NetNs)
- func (l *Link) IsAdminUp() bool
- func (l *Link) IsAutoNeg() bool
- func (l *Link) IsBridge() bool
- func (l *Link) IsLag() bool
- func (l *Link) IsPort() bool
- func (l *Link) IsVlan() bool
- func (l *Link) LinkModesAdvertising(set ...EthtoolLinkModeBits) EthtoolLinkModeBits
- func (l *Link) LinkModesLPAdvertising(set ...EthtoolLinkModeBits) EthtoolLinkModeBits
- func (l *Link) LinkModesSupported(set ...EthtoolLinkModeBits) EthtoolLinkModeBits
- func (l *Link) LinkUp(set ...bool) (up bool)
- func (l *Link) Lowers(set ...[]Xid) (xids []Xid)
- func (l *Link) StatNames(set ...[]string) (names []string)
- func (l *Link) Stats(set ...[]uint64) (stats []uint64)
- func (l *Link) String() string
- func (l *Link) Uppers(set ...[]Xid) (xids []Xid)
- func (l *Link) Xid() Xid
- type LinkAttr
- type LinkStat
- type Linker
- type Maper
- type NH
- type Neighbor
- type NetNs
- func (ns NetNs) Base() string
- func (ns NetNs) FibEntries(rt RtTable, f func(fe *FibEntry) bool)
- func (ns NetNs) FibEntry(rt RtTable, ipnet string) (fe *FibEntry)
- func (ns NetNs) Inode() uint64
- func (ns NetNs) Neighbor(ip string) (neigh *Neighbor)
- func (ns NetNs) Neighbors(f func(neigh *Neighbor) bool)
- func (ns NetNs) Path() string
- func (ns NetNs) RtTables() []RtTable
- func (ns NetNs) String() string
- func (ns NetNs) Xid(ifindex int32, set ...Xid) (xid Xid)
- func (ns NetNs) Xids(f func(xid Xid) bool)
- type NetNsAdd
- type NetNsDel
- type NetNses
- type Ref
- type RtScope
- type RtTable
- type Rtn
- type RtnhFlags
- type Task
- func (task *Task) DumpFib()
- func (task *Task) DumpIfInfo()
- func (task *Task) ExceptionFrame(b []byte)
- func (task *Task) SetCarrier(xid Xid, on bool)
- func (task *Task) SetEthtoolStat(xid Xid, stat uint32, n uint64)
- func (task *Task) SetLinkStat(xid Xid, stat uint32, n uint64)
- func (task *Task) SetSpeed(xid Xid, mbps uint32)
- type Xid
- func (xid Xid) Delist(xids []Xid) []Xid
- func (xid Xid) Format(f fmt.State, c rune)
- func (xid Xid) List(xids []Xid) []Xid
- func (xid Xid) RxAdvertising(modes uint64) DevLinkModesAdvertising
- func (xid Xid) RxDown() DevDown
- func (xid Xid) RxEthtoolFlags(flags uint32) *DevEthtoolFlags
- func (xid Xid) RxEthtoolSettings(msg *internal.MsgEthtoolSettings) DevEthtoolSettings
- func (xid Xid) RxIP4Add(addr, mask uint32) *DevAddIPNet
- func (xid Xid) RxIP4Del(addr, mask uint32) *DevDelIPNet
- func (xid Xid) RxIP6Add(addr []byte, len int) *DevAddIPNet
- func (xid Xid) RxIP6Del(addr []byte) *DevDelIPNet
- func (xid Xid) RxLPAdvertising(modes uint64) DevLinkModesLPAdvertising
- func (xid Xid) RxReg(netns NetNs, ifindex int32) DevReg
- func (xid Xid) RxSupported(modes uint64) DevLinkModesSupported
- func (xid Xid) RxUnreg(newIfindex int32) (unreg DevUnreg)
- func (xid Xid) RxUp() DevUp
- type Xids
Constants ¶
View Source
const ( CompatRtTable = RtTable(RT_TABLE_COMPAT) DefaultRtTable = RtTable(RT_TABLE_DEFAULT) MainRtTable = RtTable(RT_TABLE_MAIN) LocalRtTable = RtTable(RT_TABLE_LOCAL) )
View Source
const ( VlanVidMask = 0xfff VlanNVid = 0x1000 )
View Source
const ( DevKindUnspec = 0x0 DevKindPort = 0x1 DevKindVlan = 0x2 DevKindBridge = 0x3 DevKindLag = 0x4 )
View Source
const ( SHUT_RD = iota SHUT_WR SHUT_RDWR )
View Source
const ( FIB_EVENT_ENTRY_REPLACE = iota FIB_EVENT_ENTRY_APPEND FIB_EVENT_ENTRY_ADD FIB_EVENT_ENTRY_DEL FIB_EVENT_RULE_ADD FIB_EVENT_RULE_DEL FIB_EVENT_NH_ADD FIB_EVENT_NH_DEL )
View Source
const ( RTN_UNSPEC = iota RTN_UNICAST RTN_LOCAL RTN_BROADCAST RTN_ANYCAST RTN_MULTICAST RTN_BLACKHOLE RTN_UNREACHABLE RTN_PROHIBIT RTN_THROW RTN_NAT RTN_XRESOLVE )
View Source
const ( RTNH_F_DEAD = 1 RTNH_F_PERVASIVE = 2 RTNH_F_ONLINK = 4 RTNH_F_OFFLOAD = 8 RTNH_F_LINKDOWN = 16 RTNH_F_UNRESOLVED = 32 )
View Source
const ( RT_SCOPE_UNIVERSE = 0 RT_SCOPE_SITE = 200 RT_SCOPE_LINK = 253 RT_SCOPE_HOST = 254 RT_SCOPE_NOWHERE = 255 )
View Source
const ( RT_TABLE_UNSPEC = 0 RT_TABLE_COMPAT = 252 RT_TABLE_DEFAULT = 253 RT_TABLE_MAIN = 254 RT_TABLE_LOCAL = 255 RT_TABLE_MAX = 0xFFFFFFFF )
View Source
const ( LinkStatRxPackets = iota LinkStatTxPackets LinkStatRxBytes LinkStatTxBytes LinkStatRxErrors LinkStatTxErrors LinkStatRxDropped LinkStatTxDropped LinkStatMulticast LinkStatCollisions LinkStatRxLengthErrors LinkStatRxOverErrors LinkStatRxCrcErrors LinkStatRxFrameErrors LinkStatRxFifoErrors LinkStatRxMissedErrors LinkStatTxAbortedErrors LinkStatTxCarrierErrors LinkStatTxFifoErrors LinkStatTxHeartbeatErrors LinkStatTxWindowErrors LinkStatRxCompressed LinkStatTxCompressed LinkStatRxNohandler )
View Source
const ( AUTONEG_DISABLE = 0 AUTONEG_ENABLE = 1 AUTONEG_UNKNOWN = 0xff )
View Source
const ( DUPLEX_HALF = 0 DUPLEX_FULL = 1 DUPLEX_UNKNOWN = 0xff )
View Source
const ( PORT_TP = 0 PORT_AUI = 1 PORT_MII = 2 PORT_FIBRE = 3 PORT_BNC = 4 PORT_DA = 5 PORT_NONE = 0xef PORT_OTHER = 0xff )
View Source
const ( ETH_TP_MDI_INVALID = 0 ETH_TP_MDI = 1 ETH_TP_MDI_X = 2 ETH_TP_MDI_AUTO = 3 )
View Source
const ( ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0 ETHTOOL_LINK_MODE_10baseT_Full_BIT = 1 ETHTOOL_LINK_MODE_100baseT_Half_BIT = 2 ETHTOOL_LINK_MODE_100baseT_Full_BIT = 3 ETHTOOL_LINK_MODE_1000baseT_Half_BIT = 4 ETHTOOL_LINK_MODE_1000baseT_Full_BIT = 5 ETHTOOL_LINK_MODE_Autoneg_BIT = 6 ETHTOOL_LINK_MODE_TP_BIT = 7 ETHTOOL_LINK_MODE_AUI_BIT = 8 ETHTOOL_LINK_MODE_MII_BIT = 9 ETHTOOL_LINK_MODE_FIBRE_BIT = 10 ETHTOOL_LINK_MODE_BNC_BIT = 11 ETHTOOL_LINK_MODE_10000baseT_Full_BIT = 12 ETHTOOL_LINK_MODE_Pause_BIT = 13 ETHTOOL_LINK_MODE_Asym_Pause_BIT = 14 ETHTOOL_LINK_MODE_2500baseX_Full_BIT = 15 ETHTOOL_LINK_MODE_Backplane_BIT = 16 ETHTOOL_LINK_MODE_1000baseKX_Full_BIT = 17 ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT = 18 ETHTOOL_LINK_MODE_10000baseKR_Full_BIT = 19 ETHTOOL_LINK_MODE_10000baseR_FEC_BIT = 20 ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 21 ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT = 22 ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT = 23 ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT = 24 ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT = 25 ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT = 26 ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT = 27 ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT = 28 ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT = 29 ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT = 30 ETHTOOL_LINK_MODE_25000baseCR_Full_BIT = 31 ETHTOOL_LINK_MODE_25000baseKR_Full_BIT = 32 ETHTOOL_LINK_MODE_25000baseSR_Full_BIT = 33 ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT = 34 ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT = 35 ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT = 36 ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT = 37 ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT = 38 ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT = 39 ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT = 40 ETHTOOL_LINK_MODE_1000baseX_Full_BIT = 41 ETHTOOL_LINK_MODE_10000baseCR_Full_BIT = 42 ETHTOOL_LINK_MODE_10000baseSR_Full_BIT = 43 ETHTOOL_LINK_MODE_10000baseLR_Full_BIT = 44 ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT = 45 ETHTOOL_LINK_MODE_10000baseER_Full_BIT = 46 ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 47 ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 48 ETHTOOL_LINK_MODE_FEC_NONE_BIT = 49 ETHTOOL_LINK_MODE_FEC_RS_BIT = 50 ETHTOOL_LINK_MODE_FEC_BASER_BIT = 51 )
View Source
const ( ClassUnknown = iota ClassBreak ClassInterface ClassAddress ClassFib ClassNeighbor ClassNetNs )
View Source
const ( VLAN_PRIO_MASK = 0xe000 VLAN_PRIO_SHIFT = 13 VLAN_CFI_MASK = 0x1000 VLAN_TAG_PRESENT = VLAN_CFI_MASK )
View Source
const Dbg = dbg.Func
View Source
const License = `` /* 15866-byte string literal not displayed */
View Source
const NoDbg = dbg.NoOp
View Source
const RTN_MAX = __RTN_MAX - 1
View Source
const WithDbg = Dbg != NoDbg
Variables ¶
View Source
var IndexofLinkStat = map[string]int{ "rx-packets": LinkStatRxPackets, "tx-packets": LinkStatTxPackets, "rx-bytes": LinkStatRxBytes, "tx-bytes": LinkStatTxBytes, "rx-errors": LinkStatRxErrors, "tx-errors": LinkStatTxErrors, "rx-dropped": LinkStatRxDropped, "tx-dropped": LinkStatTxDropped, "multicast": LinkStatMulticast, "collisions": LinkStatCollisions, "rx-length-errors": LinkStatRxLengthErrors, "rx-over-errors": LinkStatRxOverErrors, "rx-crc-errors": LinkStatRxCrcErrors, "rx-frame-errors": LinkStatRxFrameErrors, "rx-fifo-errors": LinkStatRxFifoErrors, "rx-missed-errors": LinkStatRxMissedErrors, "tx-aborted-errors": LinkStatTxAbortedErrors, "tx-carrier-errors": LinkStatTxCarrierErrors, "tx-fifo-errors": LinkStatTxFifoErrors, "tx-heartbeat-errors": LinkStatTxHeartbeatErrors, "tx-window-errors": LinkStatTxWindowErrors, "rx-compressed": LinkStatRxCompressed, "tx-compressed": LinkStatTxCompressed, "rx-nohandler": LinkStatRxNohandler, }
View Source
var Links sync.Map
View Source
var PageSize = syscall.Getpagesize()
Functions ¶
func NetNsRange ¶
Types ¶
type DevAddIPNet ¶
type DevDelIPNet ¶
type DevEthtoolFlags ¶
type DevEthtoolFlags struct { Xid EthtoolFlagBits }
type DevEthtoolSettings ¶
type DevEthtoolSettings Xid
type DevLinkModesAdvertising ¶
type DevLinkModesAdvertising Xid
type DevLinkModesLPAdvertising ¶
type DevLinkModesLPAdvertising Xid
type DevLinkModesSupported ¶
type DevLinkModesSupported Xid
type EthtoolFlagBits ¶
type EthtoolFlagBits uint32
func (EthtoolFlagBits) Test ¶
func (bits EthtoolFlagBits) Test(bit uint) bool
type EthtoolLinkModeBits ¶
type EthtoolLinkModeBits uint64
func (EthtoolLinkModeBits) Test ¶
func (bits EthtoolLinkModeBits) Test(bit uint) bool
type FibEntry ¶
type FibEntryEvent ¶
type FibEntryEvent uint8
func (FibEntryEvent) String ¶
func (event FibEntryEvent) String() string
type Link ¶
func (*Link) EthtoolAutoNeg ¶
func (*Link) EthtoolDevPort ¶
func (*Link) EthtoolDuplex ¶
func (*Link) EthtoolFlags ¶
func (l *Link) EthtoolFlags(set ...EthtoolFlagBits) (bits EthtoolFlagBits)
func (*Link) EthtoolSpeed ¶
func (*Link) IfInfoDevKind ¶
func (*Link) IfInfoHardwareAddr ¶
func (l *Link) IfInfoHardwareAddr(set ...net.HardwareAddr) (ha net.HardwareAddr)
func (*Link) IfInfoIfIndex ¶
func (*Link) IfInfoName ¶
func (*Link) IfInfoNetNs ¶
func (*Link) LinkModesAdvertising ¶
func (l *Link) LinkModesAdvertising(set ...EthtoolLinkModeBits) EthtoolLinkModeBits
func (*Link) LinkModesLPAdvertising ¶
func (l *Link) LinkModesLPAdvertising(set ...EthtoolLinkModeBits) EthtoolLinkModeBits
func (*Link) LinkModesSupported ¶
func (l *Link) LinkModesSupported(set ...EthtoolLinkModeBits) EthtoolLinkModeBits
type LinkAttr ¶
type LinkAttr uint8
const ( LinkAttrEthtoolAutoNeg LinkAttr = iota LinkAttrEthtoolDevPort LinkAttrEthtoolDuplex LinkAttrEthtoolFlags LinkAttrEthtoolSpeed LinkAttrIPNets LinkAttrIfInfoName LinkAttrIfInfoIfIndex LinkAttrIfInfoNetNs LinkAttrIfInfoFlags LinkAttrIfInfoDevKind LinkAttrIfInfoHardwareAddr LinkAttrLinkModesAdvertising LinkAttrLinkModesLPAdvertising LinkAttrLinkModesSupported LinkAttrLinkUp LinkAttrLowers LinkAttrStatNames LinkAttrStats LinkAttrUppers )
type Linker ¶
type Linker interface { Maper EthtoolAutoNeg(set ...AutoNeg) AutoNeg EthtoolDuplex(set ...Duplex) Duplex EthtoolDevPort(set ...DevPort) DevPort EthtoolFlags(set ...EthtoolFlagBits) EthtoolFlagBits EthtoolSpeed(set ...uint32) uint32 IfInfoName(set ...string) string IfInfoIfIndex(set ...int32) int32 IfInfoNetNs(set ...NetNs) NetNs IfInfoFlags(set ...net.Flags) net.Flags IfInfoDevKind(set ...DevKind) DevKind IfInfoHardwareAddr(set ...net.HardwareAddr) net.HardwareAddr IPNets(set ...[]*net.IPNet) []*net.IPNet IsAdminUp() bool IsAutoNeg() bool IsBridge() bool IsLag() bool IsPort() bool IsVlan() bool LinkModesSupported(set ...EthtoolLinkModeBits) EthtoolLinkModeBits LinkModesAdvertising(set ...EthtoolLinkModeBits) EthtoolLinkModeBits LinkModesLPAdvertising(set ...EthtoolLinkModeBits) EthtoolLinkModeBits LinkUp(set ...bool) bool Lowers(set ...[]Xid) []Xid Uppers(set ...[]Xid) []Xid Stats(set ...[]uint64) []uint64 StatNames(set ...[]string) []string String() string Xid() Xid }
type Maper ¶
type Maper interface { Delete(key interface{}) Load(key interface{}) (value interface{}, ok bool) Store(key, value interface{}) }
type Neighbor ¶
type NetNs ¶
type NetNs uint64
const DefaultNetNs NetNs = 1
type NetNses ¶
type NetNses []NetNs
func NewNetNses ¶
func NewNetNses() (l NetNses)
func (NetNses) InodeFilter ¶
type Task ¶
type Task struct { RxCh <-chan Buffer // cloned msgs received from driver RxErr error // error that stopped the rx service TxErr error // error that stopped the tx service // contains filtered or unexported fields }
func (*Task) ExceptionFrame ¶
Send an exception frame to driver through raw socket.
func (*Task) SetCarrier ¶
Send carrier change to driver through hi-priority channel.
func (*Task) SetEthtoolStat ¶
Send ethtool stat change to driver through leaky-bucket channel.
func (*Task) SetLinkStat ¶
Send link stat change to driver through leaky-bucket channel.
type Xid ¶
type Xid uint32
func (Xid) RxAdvertising ¶
func (xid Xid) RxAdvertising(modes uint64) DevLinkModesAdvertising
func (Xid) RxEthtoolFlags ¶
func (xid Xid) RxEthtoolFlags(flags uint32) *DevEthtoolFlags
func (Xid) RxEthtoolSettings ¶
func (xid Xid) RxEthtoolSettings(msg *internal.MsgEthtoolSettings) DevEthtoolSettings
func (Xid) RxIP4Add ¶
func (xid Xid) RxIP4Add(addr, mask uint32) *DevAddIPNet
func (Xid) RxIP4Del ¶
func (xid Xid) RxIP4Del(addr, mask uint32) *DevDelIPNet
func (Xid) RxIP6Del ¶
func (xid Xid) RxIP6Del(addr []byte) *DevDelIPNet
func (Xid) RxLPAdvertising ¶
func (xid Xid) RxLPAdvertising(modes uint64) DevLinkModesLPAdvertising
func (Xid) RxSupported ¶
func (xid Xid) RxSupported(modes uint64) DevLinkModesSupported
Source Files ¶
Click to show internal directories.
Click to hide internal directories.