Documentation ¶
Index ¶
- Constants
- Variables
- func AddAddr(ctx *Context, addr *Address) error
- func AddAddrs(ctx *Context, addrs []*Address) error
- func IfInfomsgBytes(msg unix.IfInfomsg) []byte
- func IsNotFound(err error) bool
- type AddrInfo
- type Address
- type Attributes
- type Bridge
- type Context
- type Fib
- type Link
- func (l *Link) Absent(ctx *Context) error
- func (l *Link) Add(ctx *Context) error
- func (l *Link) AddAddr(ctx *Context, addr *Address) error
- func (l *Link) AddAltNames(ctx *Context, altNames []string) error
- func (l *Link) Addrs(ctx *Context) ([]*Address, error)
- func (l *Link) ApplyType(typ string) Attributes
- func (l *Link) Attributes() []Attributes
- func (l *Link) ChangeContext(ctx *Context, new *Context) error
- func (l *Link) Del(ctx *Context) error
- func (l *Link) DelAltNames(ctx *Context, altNames []string) error
- func (l *Link) Down(ctx *Context) error
- func (l *Link) IsUp() bool
- func (l Link) Marshal(ctx *Context) ([]byte, error)
- func (l *Link) Modify(ctx *Context, op uint16) error
- func (l *Link) Present(ctx *Context) error
- func (l *Link) Promisc(ctx *Context, v bool) error
- func (l *Link) Read(ctx *Context) error
- func (l *Link) Satisfies(spec *Link) bool
- func (l *Link) Set(ctx *Context) error
- func (l *Link) SetMaster(ctx *Context, index int) error
- func (l *Link) SetMtu(ctx *Context, mtu int) error
- func (l *Link) SetNoMaster(ctx *Context) error
- func (l *Link) SetTagged(ctx *Context, vid uint16, unset bool, pvid bool, self bool) error
- func (l *Link) SetUntagged(ctx *Context, vid uint16, unset bool, pvid bool, self bool) error
- func (l *Link) SetVf(ctx *Context, vfn uint32, vfi *VfInfo) error
- func (l *Link) SetVlan(ctx *Context, vid uint16, unset, untagged, pvid, self bool) error
- func (l *Link) Unmarshal(ctx *Context, bs []byte) error
- func (l *Link) Up(ctx *Context) error
- type LinkInfo
- type LinkType
- type Loopback
- type Macvlan
- type MacvlanMode
- type NbrMsg
- type NdMsg
- type Neighbor
- type Route
- func (r *Route) Absent(ctx *Context) error
- func (r *Route) Add(ctx *Context) error
- func (r *Route) Del(ctx *Context) error
- func (r *Route) Marshal() ([]byte, error)
- func (r *Route) Modify(ctx *Context, op uint16) error
- func (r *Route) Present(ctx *Context) error
- func (r *Route) Unmarshal(bs []byte) error
- type Rule
- func (r *Rule) Absent(ctx *Context) error
- func (r *Rule) Add(ctx *Context) error
- func (r *Rule) Del(ctx *Context) error
- func (r *Rule) Marshal(ctx *Context) ([]byte, error)
- func (r *Rule) Modify(ctx *Context, op uint16) error
- func (r *Rule) Present(ctx *Context) error
- func (r *Rule) Resolve(ctx *Context) error
- func (r *Rule) Unmarshal(ctx *Context, buf []byte) error
- type Tap
- type Tun
- type Veth
- type VfInfo
- type VfInfos
- type Vlan
- type Vrf
- type Vxlan
- type Wireguard
Constants ¶
const ( IFLA_BR_UNSPEC = iota IFLA_BR_FORWARD_DELAY IFLA_BR_HELLO_TIME IFLA_BR_MAX_AGE IFLA_BR_AGEING_TIME IFLA_BR_STP_STATE IFLA_BR_PRIORITY IFLA_BR_VLAN_FILTERING IFLA_BR_VLAN_PROTOCOL IFLA_BR_GROUP_FWD_MASK IFLA_BR_ROOT_ID IFLA_BR_BRIDGE_ID IFLA_BR_ROOT_PORT IFLA_BR_ROOT_PATH_COST IFLA_BR_TOPOLOGY_CHANGE IFLA_BR_TOPOLOGY_CHANGE_DETECTED IFLA_BR_HELLO_TIMER IFLA_BR_TCN_TIMER IFLA_BR_TOPOLOGY_CHANGE_TIMER IFLA_BR_GC_TIMER IFLA_BR_GROUP_ADDR IFLA_BR_FDB_FLUSH IFLA_BR_MCAST_ROUTER IFLA_BR_MCAST_SNOOPING IFLA_BR_MCAST_QUERY_USE_IFADDR IFLA_BR_MCAST_QUERIER IFLA_BR_MCAST_HASH_ELASTICITY IFLA_BR_MCAST_HASH_MAX IFLA_BR_MCAST_LAST_MEMBER_CNT IFLA_BR_MCAST_STARTUP_QUERY_CNT IFLA_BR_MCAST_LAST_MEMBER_INTVL IFLA_BR_MCAST_MEMBERSHIP_INTVL IFLA_BR_MCAST_QUERIER_INTVL IFLA_BR_MCAST_QUERY_INTVL IFLA_BR_MCAST_QUERY_RESPONSE_INTVL IFLA_BR_MCAST_STARTUP_QUERY_INTVL IFLA_BR_NF_CALL_IPTABLES IFLA_BR_NF_CALL_IP6TABLES IFLA_BR_NF_CALL_ARPTABLES IFLA_BR_VLAN_DEFAULT_PVID )
const ( IFLA_BRIDGE_FLAGS = iota IFLA_BRIDGE_MODE IFLA_BRIDGE_VLAN_INFO IFLA_BRIDGE_VLAN_TUNNEL_INFO )
const ( BRIDGE_VLAN_INFO_MASTER = 1 << iota BRIDGE_VLAN_INFO_PVID BRIDGE_VLAN_INFO_UNTAGGED BRIDGE_VLAN_INFO_RANGE_BEGIN BRIDGE_VLAN_INFO_RANGE_END BRIDGE_VLAN_INFO_BRENTRY )
const ( BRIDGE_FLAGS_MASTER = 1 BRIDGE_FLAGS_SELF = 2 )
const ( IFLA_INFO_UNSPEC uint16 = iota IFLA_INFO_KIND IFLA_INFO_DATA )
interface link address attribute types
const ( RTEXT_FILTER_VF uint32 = 1 RTEXT_FILTER_BRVLAN = 2 RTEXT_FILTER_SKIP_STATS = 8 )
filters for IFLA_EXT_MASK
const ( IFLA_MACVLAN_UNSPEC uint16 = iota IFLA_MACVLAN_MODE IFLA_MACVLAN_FLAGS IFLA_MACVLAN_MACADDR_MODE IFLA_MACVLAN_MACADDR IFLA_MACVLAN_MACADDR_DATA IFLA_MACVLAN_MACADDR_COUNT )
const ( MACVLAN_MACADDR_ADD uint32 = iota MACVLAN_MACADDR_DEL MACVLAN_MACADDR_FLUSH MACVLAN_MACADDR_SET )
const ( NDA_UNSPEC uint16 = iota NDA_DST NDA_LLADDR NDA_CACHEINFO NDA_PROBES NDA_VLAN NDA_PORT NDA_VNI NDA_IFINDEX NDA_MASTER NDA_LINK_NETNSID NDA_SRC_VNI )
attribute types
const ( NTF_USE = 0x01 NTF_SELF = 0x02 NTF_MASTER = 0x04 NTF_PROXY = 0x08 NTF_EXT_LEARNED = 0x10 NTF_OFFLOADED = 0x20 NTF_ROUTER = 0x80 )
neighbor cache entry flags
const ( NUD_INCOMPLETE = 0x01 NUD_REACHABLE = 0x02 NUD_STALE = 0x04 NUD_DELAY = 0x08 NUD_PROBE = 0x10 NUD_FAILED = 0x20 NUD_NOARP = 0x40 NUD_PERMANENT = 0x80 NUD_NONE = 0x00 )
neighbor cache entry states
const ( FRA_UNSPEC uint16 = iota FRA_DST FRA_SRC FRA_IIFNAME FRA_GOTO FRA_UNUSED2 FRA_PRIORITY FRA_UNUSED3 FRA_UNUSED4 FRA_UNUSED5 FRA_FWMARK FRA_FLOW FRA_TUN_ID FRA_SUPPRESS_IFGROUP FRA_SUPPRESS_PREFIXLEN FRA_TABLE FRA_FWMASK FRA_OIFNAME FRA_PAD FRA_L3MDEV FRA_UID_RANGE FRA_PROTOCOL FRA_IP_PROTO FRA_SPORT_RANGE FRA_DPORT_RANGE )
const ( FR_ACT_UNSPEC uint8 = iota FR_ACT_TO_TBL FR_ACT_GOTO FR_ACT_NOP FR_ACT_RES3 FR_ACT_RES4 FR_ACT_BLACKHOLE FR_ACT_UNREACHABLE FR_ACT_PROHIBIT )
const ( VETH_INFO_UNSPEC uint16 = iota VETH_INFO_PEER )
veth attribute types
const ( IFLA_VLAN_UNSPEC uint16 = iota IFLA_VLAN_ID IFLA_VLAN_FLAGS IFLA_VLAN_EGRESS_QOS IFLA_VLAN_INGRESS_QOS IFLA_VLAN_PROTOCOL )
const ( IFLA_VRF_UNSPEC uint16 = iota IFLA_VRF_TABLE )
const ( IFLA_VRF_PORT_UNSPEC uint16 = iota IFLA_VRF_PORT_TABLE )
const ( IFLA_VXLAN_UNSPEC uint16 = iota IFLA_VXLAN_ID IFLA_VXLAN_GROUP /* group or remote address */ IFLA_VXLAN_LINK IFLA_VXLAN_LOCAL IFLA_VXLAN_TTL IFLA_VXLAN_TOS IFLA_VXLAN_LEARNING IFLA_VXLAN_AGEING IFLA_VXLAN_LIMIT IFLA_VXLAN_PORT_RANGE /* source port */ IFLA_VXLAN_PROXY IFLA_VXLAN_RSC IFLA_VXLAN_L2MISS IFLA_VXLAN_L3MISS IFLA_VXLAN_PORT /* destination port */ IFLA_VXLAN_GROUP6 IFLA_VXLAN_LOCAL6 IFLA_VXLAN_UDP_CSUM IFLA_VXLAN_UDP_ZERO_CSUM6_TX IFLA_VXLAN_UDP_ZERO_CSUM6_RX IFLA_VXLAN_REMCSUM_TX IFLA_VXLAN_REMCSUM_RX IFLA_VXLAN_GBP IFLA_VXLAN_REMCSUM_NOPARTIAL IFLA_VXLAN_COLLECT_METADATA IFLA_VXLAN_LABEL IFLA_VXLAN_GPE IFLA_VXLAN_TTL_INHERIT )
vxlan attribute types
Variables ¶
var Version = "undefined"
Functions ¶
func IfInfomsgBytes ¶
func IsNotFound ¶
Types ¶
type AddrInfo ¶
type AddrInfo struct { Address *net.IPNet Local net.IP Label string Broadcast net.IP Anycast net.IP }
AddrInfo holds address attribute data.
type Address ¶
Address consolidates address information from rtnetlink.
func ReadAddrs ¶
ReadAddrs reads a set of addresses according to the provided specification. For example, if you specify the address family, only addresses from that family will be returned. Some basic attribute filtering is also implemented.
type Attributes ¶
type Attributes interface { Marshal(*Context) ([]byte, error) Unmarshal(*Context, []byte) error Resolve(*Context) error }
Attributes is an interface that is used on all types that can be marshaled and unmarshaled from rtnetlink attributes
type Context ¶
type Context struct { Target *Context // contains filtered or unexported fields }
func OpenContext ¶
OpenContext creates a context in the specified namespace
func OpenDefaultContext ¶
OpenDefaultContext creates a context in the default namespace
type Link ¶
Link consolidates link information from rtnetlink
func ReadLinks ¶
ReadLinks reads a set of links according to the provided specification. For example, if you specify the address family, only links from that family will be returned. Some basic attribute filtering is also implemented.
func (*Link) AddAltNames ¶ added in v0.1.13
AddAltNames: adds altnames of the interface/link analogous to `ip link property add dev <dev> altname <altName>` If any of the altNames are already assigned, returns an error
func (*Link) ApplyType ¶
func (l *Link) ApplyType(typ string) Attributes
ApplyType activates the link type defined by the provided string.
func (*Link) Attributes ¶
func (l *Link) Attributes() []Attributes
Attributes returns a set of Attributes objects from the link.
func (*Link) ChangeContext ¶ added in v0.1.11
func (*Link) DelAltNames ¶ added in v0.1.13
DelAltNames: adds altnames of the interface/link analogous to `ip link property del dev <dev> altname <altName>` If any of the altNames aren't assigned, returns an error
func (*Link) Modify ¶
Modify changes the link according to the supplied operation. Supported operations include RTM_NEWLINK, RTM_SETLINK, and RTM_DELLINK.
func (*Link) SetNoMaster ¶ added in v0.1.11
func (*Link) SetUntagged ¶
type LinkInfo ¶
type LinkInfo struct { // Name of the link Name string // Alt Names of the link AltNames []string // layer 2 address Address net.HardwareAddr Promisc bool // network namespace file descriptor Ns uint32 // maximum transmission unit Mtu uint32 // the network namespace the link is in LinkNS uint32 // bridge master Master uint32 // vlan-aware bridge properties Pvid uint16 Untagged []uint16 Tagged []uint16 // loopback properties Loopback *Loopback // veth properties Veth *Veth // vxlan properties Vxlan *Vxlan // bridge properties Bridge *Bridge // tap properties Tap *Tap // tun properties Tun *Tun // vrf properties Vrf *Vrf // macvlan properties Macvlan *Macvlan // wireguard properties Wireguard *Wireguard // Vlan properties Vlan *Vlan // VF Data Vfi VfInfos }
LinkInfo holds link attribute data
type LinkType ¶
type LinkType uint32
LinkType aliases link type enumerations in a type safe way
func ParseLinkType ¶
type Macvlan ¶ added in v0.1.3
type Macvlan struct { Mode MacvlanMode Link uint32 }
type MacvlanMode ¶ added in v0.1.3
type MacvlanMode uint32
const ( MACVLAN_MODE_PRIVATE MacvlanMode = 1 << iota MACVLAN_MODE_VEPA MACVLAN_MODE_BRIDGE MACVLAN_MODE_PASSTHRU MACVLAN_MODE_SOURCE )
func ParseMacvlanMode ¶ added in v0.1.3
func ParseMacvlanMode(mode string) (MacvlanMode, error)
type NbrMsg ¶
NbrMsg encapsulates a netlink NdMsg, providing Marshal/Unmarshal support
type NdMsg ¶
NdMsg is a Netlink message for communicating with the kernel about neighbors. The unix library does not have this one
type Neighbor ¶
type Neighbor struct { Mac net.HardwareAddr Vlan uint32 Port uint32 Master uint32 If uint32 Ifx string Dst net.IP Vni uint32 SrcVni uint32 Router bool Family uint8 }
Neighbor encapsulates information about neighbors
type Route ¶
type Route struct { Hdr unix.RtMsg Dest net.IP Src net.IP Gateway net.IP PrefSrc net.IP Oif uint32 Iif uint32 Priority uint32 Metrics uint32 Table uint32 }
Route encapsulates information about a route
type Rule ¶
type Veth ¶
Veth encapsulates information about virtual ethernet devices
func (*Veth) ResolvePeer ¶
ResolvePeer fills in this veth's peer interface name from its index.
type VfInfo ¶ added in v0.1.13
type VfInfo struct { // Mac address Address net.HardwareAddr // Vlan id assigned to the VF (VST?) Vlan uint32 // Quality-ofService Qos uint32 // limit on tx-rate, 0 is unlimited, in Mbps TxRate uint32 MinTxRate uint32 MaxTxRate uint32 // spoofcheck is enabled Spoofchk bool }
VfInfo holds data on a particular VF
type VfInfos ¶ added in v0.1.13
type VfInfos struct { // Number of VFs on the device (this comes from a separate field) NumVf uint32 // Info returned about each VF, indexed by VF number Map map[uint32]*VfInfo }
VfInfos holds virtual function data
type Vxlan ¶
type Vxlan struct { Vni uint32 Learning uint8 DstPort uint16 Local net.IP Link uint32 // interface index }
Vxlan encapsulates information about virtual extensible LAN devices.