package netlink
import "github.com/docker/libnetwork/Godeps/_workspace/src/github.com/vishvananda/netlink"
Package netlink provides a simple library for netlink. Netlink is the interface a user-space program in linux uses to communicate with the kernel. It can be used to add and remove interfaces, set up ip addresses and routes, and confiugre ipsec. Netlink communication requires elevated privileges, so in most cases this code needs to be run as root. The low level primitives for netlink are contained in the nl subpackage. This package attempts to provide a high-level interface that is loosly modeled on the iproute2 cli.
Index ¶
- Constants
- func AddrAdd(link Link, addr *Addr) error
- func AddrDel(link Link, addr *Addr) error
- func AdjustSize(sz uint, mpu uint, linklayer int) uint
- func AlignToAtm(size uint) uint
- func CalcRtable(rate *nl.TcRateSpec, rtab [256]uint32, cell_log int, mtu uint32, linklayer int) int
- func ClassAdd(class Class) error
- func ClassDel(class Class) error
- func ClockFactor() float64
- func DeserializeRtab(b []byte) [256]uint32
- func FilterAdd(filter Filter) error
- func FilterDel(filter Filter) error
- func HandleStr(handle uint32) string
- func Hz() float64
- func LinkAdd(link Link) error
- func LinkDel(link Link) error
- func LinkSetDown(link Link) error
- func LinkSetFastLeave(link Link, mode bool) error
- func LinkSetFlood(link Link, mode bool) error
- func LinkSetGuard(link Link, mode bool) error
- func LinkSetHairpin(link Link, mode bool) error
- func LinkSetHardwareAddr(link Link, hwaddr net.HardwareAddr) error
- func LinkSetLearning(link Link, mode bool) error
- func LinkSetMTU(link Link, mtu int) error
- func LinkSetMaster(link Link, master *Bridge) error
- func LinkSetMasterByIndex(link Link, masterIndex int) error
- func LinkSetName(link Link, name string) error
- func LinkSetNsFd(link Link, fd int) error
- func LinkSetNsPid(link Link, nspid int) error
- func LinkSetRootBlock(link Link, mode bool) error
- func LinkSetUp(link Link) error
- func LinkSubscribe(ch chan<- LinkUpdate, done <-chan struct{}) error
- func MajorMinor(handle uint32) (uint16, uint16)
- func MakeHandle(major, minor uint16) uint32
- func NeighAdd(neigh *Neigh) error
- func NeighAppend(neigh *Neigh) error
- func NeighDel(neigh *Neigh) error
- func NeighSet(neigh *Neigh) error
- func NewIPNet(ip net.IP) *net.IPNet
- func ParseIPNet(s string) (*net.IPNet, error)
- func QdiscAdd(qdisc Qdisc) error
- func QdiscDel(qdisc Qdisc) error
- func RouteAdd(route *Route) error
- func RouteDel(route *Route) error
- func RouteSubscribe(ch chan<- RouteUpdate, done <-chan struct{}) error
- func SerializeRtab(rtab [256]uint32) []byte
- func TickInUsec() float64
- func XfrmPolicyAdd(policy *XfrmPolicy) error
- func XfrmPolicyDel(policy *XfrmPolicy) error
- func XfrmStateAdd(state *XfrmState) error
- func XfrmStateDel(state *XfrmState) error
- func Xmittime(rate uint64, size uint32) float64
- type Addr
- func AddrList(link Link, family int) ([]Addr, error)
- func ParseAddr(s string) (*Addr, error)
- func (a Addr) Equal(x Addr) bool
- func (a Addr) String() string
- type Bridge
- type Class
- type ClassAttrs
- type Device
- type Dir
- type Dummy
- type EncapType
- type Filter
- type FilterAttrs
- type FilterFwAttrs
- type Fw
- func NewFw(attrs FilterAttrs, fattrs FilterFwAttrs) (*Fw, error)
- func (filter *Fw) Attrs() *FilterAttrs
- func (filter *Fw) Type() string
- type GenericClass
- type GenericFilter
- type GenericLink
- type GenericQdisc
- type Htb
- func NewHtb(attrs QdiscAttrs) *Htb
- func (qdisc *Htb) Attrs() *QdiscAttrs
- func (qdisc *Htb) Type() string
- type HtbClass
- func NewHtbClass(attrs ClassAttrs, cattrs HtbClassAttrs) *HtbClass
- func (class *HtbClass) Attrs() *ClassAttrs
- func (q HtbClass) String() string
- func (class *HtbClass) Type() string
- type HtbClassAttrs
- type IPVlan
- type IPVlanMode
- type Ifb
- type Ingress
- type Link
- func LinkByIndex(index int) (Link, error)
- func LinkByName(name string) (Link, error)
- func LinkList() ([]Link, error)
- type LinkAttrs
- type LinkUpdate
- type Macvlan
- type MacvlanMode
- type Macvtap
- type Mode
- type Ndmsg
- type Neigh
- func NeighDeserialize(m []byte) (*Neigh, error)
- func NeighList(linkIndex, family int) ([]Neigh, error)
- func (neigh *Neigh) String() string
- type NextHopFlag
- type NsFd
- type NsPid
- type PfifoFast
- type Prio
- func NewPrio(attrs QdiscAttrs) *Prio
- func (qdisc *Prio) Attrs() *QdiscAttrs
- func (qdisc *Prio) Type() string
- type Protinfo
- type Proto
- type Qdisc
- type QdiscAttrs
- type Route
- func RouteGet(destination net.IP) ([]Route, error)
- func RouteList(link Link, family int) ([]Route, error)
- func (r *Route) ClearFlag(flag NextHopFlag)
- func (r *Route) ListFlags() []string
- func (r *Route) SetFlag(flag NextHopFlag)
- func (r Route) String() string
- type RouteUpdate
- type Scope
- type Tbf
- type Tuntap
- type TuntapMode
- type U32
- type Veth
- type Vlan
- type Vxlan
- type XfrmPolicy
- type XfrmPolicyTmpl
- type XfrmState
- type XfrmStateAlgo
- type XfrmStateEncap
Constants ¶
const ( SizeOfIfReq = 40 IFNAMSIZ = 16 )
ideally golang.org/x/sys/unix would define IfReq but it only has IFNAMSIZ, hence this minimalistic implementation
const ( NDA_UNSPEC = iota NDA_DST NDA_LLADDR NDA_CACHEINFO NDA_PROBES NDA_VLAN NDA_PORT NDA_VNI NDA_IFINDEX NDA_MAX = NDA_IFINDEX )
const ( NUD_NONE = 0x00 NUD_INCOMPLETE = 0x01 NUD_REACHABLE = 0x02 NUD_STALE = 0x04 NUD_DELAY = 0x08 NUD_PROBE = 0x10 NUD_FAILED = 0x20 NUD_NOARP = 0x40 NUD_PERMANENT = 0x80 )
Neighbor Cache Entry States.
const ( NTF_USE = 0x01 NTF_SELF = 0x02 NTF_MASTER = 0x04 NTF_PROXY = 0x08 NTF_ROUTER = 0x80 )
Neighbor Flags
const ( // Family type definitions FAMILY_ALL = nl.FAMILY_ALL FAMILY_V4 = nl.FAMILY_V4 FAMILY_V6 = nl.FAMILY_V6 )
const ( HANDLE_NONE = 0 HANDLE_INGRESS = 0xFFFFFFF1 HANDLE_ROOT = 0xFFFFFFFF PRIORITY_MAP_LEN = 16 )
const (
TIME_UNITS_PER_SEC = 1000000
)
Functions ¶
func AddrAdd ¶
AddrAdd will add an IP address to a link device. Equivalent to: `ip addr add $addr dev $link`
func AddrDel ¶
AddrDel will delete an IP address from a link device. Equivalent to: `ip addr del $addr dev $link`
func AdjustSize ¶
func AlignToAtm ¶
func CalcRtable ¶
func ClassAdd ¶
ClassAdd will add a class to the system. Equivalent to: `tc class add $class`
func ClassDel ¶
ClassDel will delete a class from the system. Equivalent to: `tc class del $class`
func ClockFactor ¶
func ClockFactor() float64
func DeserializeRtab ¶
func FilterAdd ¶
FilterAdd will add a filter to the system. Equivalent to: `tc filter add $filter`
func FilterDel ¶
FilterDel will delete a filter from the system. Equivalent to: `tc filter del $filter`
func HandleStr ¶
func Hz ¶
func Hz() float64
func LinkAdd ¶
LinkAdd adds a new link device. The type and features of the device are taken fromt the parameters in the link object. Equivalent to: `ip link add $link`
func LinkDel ¶
LinkDel deletes link device. Either Index or Name must be set in the link object for it to be deleted. The other values are ignored. Equivalent to: `ip link del $link`
func LinkSetDown ¶
LinkSetDown disables link device. Equivalent to: `ip link set $link down`
func LinkSetFastLeave ¶
func LinkSetFlood ¶
func LinkSetGuard ¶
func LinkSetHairpin ¶
func LinkSetHardwareAddr ¶
func LinkSetHardwareAddr(link Link, hwaddr net.HardwareAddr) error
LinkSetHardwareAddr sets the hardware address of the link device. Equivalent to: `ip link set $link address $hwaddr`
func LinkSetLearning ¶
func LinkSetMTU ¶
LinkSetMTU sets the mtu of the link device. Equivalent to: `ip link set $link mtu $mtu`
func LinkSetMaster ¶
LinkSetMaster sets the master of the link device. Equivalent to: `ip link set $link master $master`
func LinkSetMasterByIndex ¶
LinkSetMasterByIndex sets the master of the link device. Equivalent to: `ip link set $link master $master`
func LinkSetName ¶
LinkSetName sets the name of the link device. Equivalent to: `ip link set $link name $name`
func LinkSetNsFd ¶
LinkSetNsFd puts the device into a new network namespace. The fd must be an open file descriptor to a network namespace. Similar to: `ip link set $link netns $ns`
func LinkSetNsPid ¶
LinkSetNsPid puts the device into a new network namespace. The pid must be a pid of a running process. Equivalent to: `ip link set $link netns $pid`
func LinkSetRootBlock ¶
func LinkSetUp ¶
LinkSetUp enables the link device. Equivalent to: `ip link set $link up`
func LinkSubscribe ¶
func LinkSubscribe(ch chan<- LinkUpdate, done <-chan struct{}) error
LinkSubscribe takes a chan down which notifications will be sent when links change. Close the 'done' chan to stop subscription.
func MajorMinor ¶
func MakeHandle ¶
func NeighAdd ¶
NeighAdd will add an IP to MAC mapping to the ARP table Equivalent to: `ip neigh add ....`
func NeighAppend ¶
NeighAppend will append an entry to FDB Equivalent to: `bridge fdb append...`
func NeighDel ¶
NeighDel will delete an IP address from a link device. Equivalent to: `ip addr del $addr dev $link`
func NeighSet ¶
NeighAdd will add or replace an IP to MAC mapping to the ARP table Equivalent to: `ip neigh replace....`
func NewIPNet ¶
NewIPNet generates an IPNet from an ip address using a netmask of 32.
func ParseIPNet ¶
ParseIPNet parses a string in ip/net format and returns a net.IPNet. This is valuable because addresses in netlink are often IPNets and ParseCIDR returns an IPNet with the IP part set to the base IP of the range.
func QdiscAdd ¶
QdiscAdd will add a qdisc to the system. Equivalent to: `tc qdisc add $qdisc`
func QdiscDel ¶
QdiscDel will delete a qdisc from the system. Equivalent to: `tc qdisc del $qdisc`
func RouteAdd ¶
RouteAdd will add a route to the system. Equivalent to: `ip route add $route`
func RouteDel ¶
RouteDel will delete a route from the system. Equivalent to: `ip route del $route`
func RouteSubscribe ¶
func RouteSubscribe(ch chan<- RouteUpdate, done <-chan struct{}) error
RouteSubscribe takes a chan down which notifications will be sent when routes are added or deleted. Close the 'done' chan to stop subscription.
func SerializeRtab ¶
func TickInUsec ¶
func TickInUsec() float64
func XfrmPolicyAdd ¶
func XfrmPolicyAdd(policy *XfrmPolicy) error
XfrmPolicyAdd will add an xfrm policy to the system. Equivalent to: `ip xfrm policy add $policy`
func XfrmPolicyDel ¶
func XfrmPolicyDel(policy *XfrmPolicy) error
XfrmPolicyDel will delete an xfrm policy from the system. Note that the Tmpls are ignored when matching the policy to delete. Equivalent to: `ip xfrm policy del $policy`
func XfrmStateAdd ¶
XfrmStateAdd will add an xfrm state to the system. Equivalent to: `ip xfrm state add $state`
func XfrmStateDel ¶
XfrmStateDel will delete an xfrm state from the system. Note that the Algos are ignored when matching the state to delete. Equivalent to: `ip xfrm state del $state`
func Xmittime ¶
Types ¶
type Addr ¶
Addr represents an IP address from netlink. Netlink ip addresses include a mask, so it stores the address as a net.IPNet.
func AddrList ¶
AddrList gets a list of IP addresses in the system. Equivalent to: `ip addr show`. The list can be filtered by link and ip family.
func ParseAddr ¶
ParseAddr parses the string representation of an address in the form $ip/$netmask $label. The label portion is optional
func (Addr) Equal ¶
Equal returns true if both Addrs have the same net.IPNet value.
func (Addr) String ¶
String returns $ip/$netmask $label
type Bridge ¶
type Bridge struct { LinkAttrs }
Bridge links are simple linux bridges
func (*Bridge) Attrs ¶
func (*Bridge) Type ¶
type Class ¶
type Class interface { Attrs() *ClassAttrs Type() string }
func ClassList ¶
ClassList gets a list of classes in the system. Equivalent to: `tc class show`. Generally retunrs nothing if link and parent are not specified.
type ClassAttrs ¶
Class represents a netlink class. A filter is associated with a link, has a handle and a parent. The root filter of a device should have a parent == HANDLE_ROOT.
func (ClassAttrs) String ¶
func (q ClassAttrs) String() string
type Device ¶
type Device struct { LinkAttrs }
Device links cannot be created via netlink. These links are links created by udev like 'lo' and 'etho0'
func (*Device) Attrs ¶
func (*Device) Type ¶
type Dir ¶
type Dir uint8
Dir is an enum representing an ipsec template direction.
const ( XFRM_DIR_IN Dir = iota XFRM_DIR_OUT XFRM_DIR_FWD XFRM_SOCKET_IN XFRM_SOCKET_OUT XFRM_SOCKET_FWD )
func (Dir) String ¶
type Dummy ¶
type Dummy struct { LinkAttrs }
Dummy links are dummy ethernet devices
func (*Dummy) Attrs ¶
func (*Dummy) Type ¶
type EncapType ¶
type EncapType uint8
EncapType is an enum representing an ipsec template direction.
func (EncapType) String ¶
type Filter ¶
type Filter interface { Attrs() *FilterAttrs Type() string }
func FilterList ¶
FilterList gets a list of filters in the system. Equivalent to: `tc filter show`. Generally retunrs nothing if link and parent are not specified.
type FilterAttrs ¶
type FilterAttrs struct { LinkIndex int Handle uint32 Parent uint32 Priority uint16 // lower is higher priority Protocol uint16 // syscall.ETH_P_* }
Filter represents a netlink filter. A filter is associated with a link, has a handle and a parent. The root filter of a device should have a parent == HANDLE_ROOT.
func (FilterAttrs) String ¶
func (q FilterAttrs) String() string
type FilterFwAttrs ¶
type FilterFwAttrs struct { ClassId uint32 InDev string Mask uint32 Index uint32 Buffer uint32 Mtu uint32 Mpu uint16 Rate uint32 AvRate uint32 PeakRate uint32 Action int Overhead uint16 LinkLayer int }
type Fw ¶
type Fw struct { FilterAttrs ClassId uint32 Police nl.TcPolice InDev string // TODO Action Mask uint32 AvRate uint32 Rtab [256]uint32 Ptab [256]uint32 }
FwFilter filters on firewall marks
func NewFw ¶
func NewFw(attrs FilterAttrs, fattrs FilterFwAttrs) (*Fw, error)
func (*Fw) Attrs ¶
func (filter *Fw) Attrs() *FilterAttrs
func (*Fw) Type ¶
type GenericClass ¶
type GenericClass struct { ClassAttrs ClassType string }
GenericClass classes represent types that are not currently understood by this netlink library.
func (*GenericClass) Attrs ¶
func (class *GenericClass) Attrs() *ClassAttrs
func (*GenericClass) Type ¶
func (class *GenericClass) Type() string
type GenericFilter ¶
type GenericFilter struct { FilterAttrs FilterType string }
GenericFilter filters represent types that are not currently understood by this netlink library.
func (*GenericFilter) Attrs ¶
func (filter *GenericFilter) Attrs() *FilterAttrs
func (*GenericFilter) Type ¶
func (filter *GenericFilter) Type() string
type GenericLink ¶
GenericLink links represent types that are not currently understood by this netlink library.
func (*GenericLink) Attrs ¶
func (generic *GenericLink) Attrs() *LinkAttrs
func (*GenericLink) Type ¶
func (generic *GenericLink) Type() string
type GenericQdisc ¶
type GenericQdisc struct { QdiscAttrs QdiscType string }
GenericQdisc qdiscs represent types that are not currently understood by this netlink library.
func (*GenericQdisc) Attrs ¶
func (qdisc *GenericQdisc) Attrs() *QdiscAttrs
func (*GenericQdisc) Type ¶
func (qdisc *GenericQdisc) Type() string
type Htb ¶
type Htb struct { QdiscAttrs Version uint32 Rate2Quantum uint32 Defcls uint32 Debug uint32 DirectPkts uint32 }
Htb is a classful qdisc that rate limits based on tokens
func NewHtb ¶
func NewHtb(attrs QdiscAttrs) *Htb
func (*Htb) Attrs ¶
func (qdisc *Htb) Attrs() *QdiscAttrs
func (*Htb) Type ¶
type HtbClass ¶
type HtbClass struct { ClassAttrs Rate uint64 Ceil uint64 Buffer uint32 Cbuffer uint32 Quantum uint32 Level uint32 Prio uint32 }
Htb class
func NewHtbClass ¶
func NewHtbClass(attrs ClassAttrs, cattrs HtbClassAttrs) *HtbClass
func (*HtbClass) Attrs ¶
func (class *HtbClass) Attrs() *ClassAttrs
func (HtbClass) String ¶
func (*HtbClass) Type ¶
type HtbClassAttrs ¶
type HtbClassAttrs struct { // TODO handle all attributes Rate uint64 Ceil uint64 Buffer uint32 Cbuffer uint32 Quantum uint32 Level uint32 Prio uint32 }
func (HtbClassAttrs) String ¶
func (q HtbClassAttrs) String() string
type IPVlan ¶
type IPVlan struct { LinkAttrs Mode IPVlanMode }
func (*IPVlan) Attrs ¶
func (*IPVlan) Type ¶
type IPVlanMode ¶
type IPVlanMode uint16
const ( IPVLAN_MODE_L2 IPVlanMode = iota IPVLAN_MODE_L3 IPVLAN_MODE_MAX )
type Ifb ¶
type Ifb struct { LinkAttrs }
Ifb links are advanced dummy devices for packet filtering
func (*Ifb) Attrs ¶
func (*Ifb) Type ¶
type Ingress ¶
type Ingress struct { QdiscAttrs }
Ingress is a qdisc for adding ingress filters
func (*Ingress) Attrs ¶
func (qdisc *Ingress) Attrs() *QdiscAttrs
func (*Ingress) Type ¶
type Link ¶
Link represents a link device from netlink. Shared link attributes like name may be retrieved using the Attrs() method. Unique data can be retrieved by casting the object to the proper type.
func LinkByIndex ¶
LinkByIndex finds a link by index and returns a pointer to the object.
func LinkByName ¶
LinkByName finds a link by name and returns a pointer to the object.
func LinkList ¶
LinkList gets a list of link devices. Equivalent to: `ip link show`
type LinkAttrs ¶
type LinkAttrs struct { Index int MTU int TxQLen int // Transmit Queue Length Name string HardwareAddr net.HardwareAddr Flags net.Flags ParentIndex int // index of the parent link device MasterIndex int // must be the index of a bridge Namespace interface{} // nil | NsPid | NsFd }
LinkAttrs represents data shared by most link types
func NewLinkAttrs ¶
func NewLinkAttrs() LinkAttrs
NewLinkAttrs returns LinkAttrs structure filled with default values
type LinkUpdate ¶
LinkUpdate is used to pass information back from LinkSubscribe()
type Macvlan ¶
type Macvlan struct { LinkAttrs Mode MacvlanMode }
Macvlan links have ParentIndex set in their Attrs()
func (*Macvlan) Attrs ¶
func (*Macvlan) Type ¶
type MacvlanMode ¶
type MacvlanMode uint16
const ( MACVLAN_MODE_DEFAULT MacvlanMode = iota MACVLAN_MODE_PRIVATE MACVLAN_MODE_VEPA MACVLAN_MODE_BRIDGE MACVLAN_MODE_PASSTHRU MACVLAN_MODE_SOURCE )
type Macvtap ¶
type Macvtap struct { Macvlan }
Macvtap - macvtap is a virtual interfaces based on macvlan
func (Macvtap) Type ¶
type Mode ¶
type Mode uint8
Mode is an enum representing an ipsec transport.
const ( XFRM_MODE_TRANSPORT Mode = iota XFRM_MODE_TUNNEL XFRM_MODE_ROUTEOPTIMIZATION XFRM_MODE_IN_TRIGGER XFRM_MODE_BEET XFRM_MODE_MAX )
func (Mode) String ¶
type Ndmsg ¶
func (*Ndmsg) Len ¶
func (*Ndmsg) Serialize ¶
type Neigh ¶
type Neigh struct { LinkIndex int Family int State int Type int Flags int IP net.IP HardwareAddr net.HardwareAddr }
Neigh represents a link layer neighbor from netlink.
func NeighDeserialize ¶
func NeighList ¶
NeighList gets a list of IP-MAC mappings in the system (ARP table). Equivalent to: `ip neighbor show`. The list can be filtered by link and ip family.
func (*Neigh) String ¶
String returns $ip/$hwaddr $label
type NextHopFlag ¶
type NextHopFlag int
const ( FLAG_ONLINK NextHopFlag = syscall.RTNH_F_ONLINK FLAG_PERVASIVE NextHopFlag = syscall.RTNH_F_PERVASIVE )
type NsFd ¶
type NsFd int
type NsPid ¶
type NsPid int
type PfifoFast ¶
type PfifoFast struct { QdiscAttrs Bands uint8 PriorityMap [PRIORITY_MAP_LEN]uint8 }
PfifoFast is the default qdisc created by the kernel if one has not been defined for the interface
func (*PfifoFast) Attrs ¶
func (qdisc *PfifoFast) Attrs() *QdiscAttrs
func (*PfifoFast) Type ¶
type Prio ¶
type Prio struct { QdiscAttrs Bands uint8 PriorityMap [PRIORITY_MAP_LEN]uint8 }
Prio is a basic qdisc that works just like PfifoFast
func NewPrio ¶
func NewPrio(attrs QdiscAttrs) *Prio
func (*Prio) Attrs ¶
func (qdisc *Prio) Attrs() *QdiscAttrs
func (*Prio) Type ¶
type Protinfo ¶
type Protinfo struct { Hairpin bool Guard bool FastLeave bool RootBlock bool Learning bool Flood bool }
Protinfo represents bridge flags from netlink.
func LinkGetProtinfo ¶
func (*Protinfo) String ¶
String returns a list of enabled flags
type Proto ¶
type Proto uint8
Proto is an enum representing an ipsec protocol.
const ( XFRM_PROTO_ROUTE2 Proto = syscall.IPPROTO_ROUTING XFRM_PROTO_ESP Proto = syscall.IPPROTO_ESP XFRM_PROTO_AH Proto = syscall.IPPROTO_AH XFRM_PROTO_HAO Proto = syscall.IPPROTO_DSTOPTS XFRM_PROTO_COMP Proto = syscall.IPPROTO_COMP XFRM_PROTO_IPSEC_ANY Proto = syscall.IPPROTO_RAW )
func (Proto) String ¶
type Qdisc ¶
type Qdisc interface { Attrs() *QdiscAttrs Type() string }
func QdiscList ¶
QdiscList gets a list of qdiscs in the system. Equivalent to: `tc qdisc show`. The list can be filtered by link.
type QdiscAttrs ¶
Qdisc represents a netlink qdisc. A qdisc is associated with a link, has a handle, a parent and a refcnt. The root qdisc of a device should have parent == HANDLE_ROOT.
func (QdiscAttrs) String ¶
func (q QdiscAttrs) String() string
type Route ¶
Route represents a netlink route. A route is associated with a link, has a destination network, an optional source ip, and optional gateway. Advanced route parameters and non-main routing tables are currently not supported.
func RouteGet ¶
RouteGet gets a route to a specific destination from the host system. Equivalent to: 'ip route get'.
func RouteList ¶
RouteList gets a list of routes in the system. Equivalent to: `ip route show`. The list can be filtered by link and ip family.
func (*Route) ClearFlag ¶
func (r *Route) ClearFlag(flag NextHopFlag)
func (*Route) ListFlags ¶
func (*Route) SetFlag ¶
func (r *Route) SetFlag(flag NextHopFlag)
func (Route) String ¶
type RouteUpdate ¶
RouteUpdate is sent when a route changes - type is RTM_NEWROUTE or RTM_DELROUTE
type Scope ¶
type Scope uint8
Scope is an enum representing a route scope.
const ( SCOPE_UNIVERSE Scope = syscall.RT_SCOPE_UNIVERSE SCOPE_SITE Scope = syscall.RT_SCOPE_SITE SCOPE_LINK Scope = syscall.RT_SCOPE_LINK SCOPE_HOST Scope = syscall.RT_SCOPE_HOST SCOPE_NOWHERE Scope = syscall.RT_SCOPE_NOWHERE )
type Tbf ¶
type Tbf struct { QdiscAttrs // TODO: handle 64bit rate properly Rate uint64 Limit uint32 Buffer uint32 }
Tbf is a classless qdisc that rate limits based on tokens
func (*Tbf) Attrs ¶
func (qdisc *Tbf) Attrs() *QdiscAttrs
func (*Tbf) Type ¶
type Tuntap ¶
type Tuntap struct { LinkAttrs Mode TuntapMode }
Tuntap links created via /dev/tun/tap, but can be destroyed via netlink
func (*Tuntap) Attrs ¶
func (*Tuntap) Type ¶
type TuntapMode ¶
type TuntapMode uint16
const ( TUNTAP_MODE_TUN TuntapMode = syscall.IFF_TUN TUNTAP_MODE_TAP TuntapMode = syscall.IFF_TAP )
type U32 ¶
type U32 struct { FilterAttrs // Currently only supports redirecting to another interface RedirIndex int }
U32 filters on many packet related properties
func (*U32) Attrs ¶
func (filter *U32) Attrs() *FilterAttrs
func (*U32) Type ¶
type Veth ¶
Veth devices must specify PeerName on create
func (*Veth) Attrs ¶
func (*Veth) Type ¶
type Vlan ¶
Vlan links have ParentIndex set in their Attrs()
func (*Vlan) Attrs ¶
func (*Vlan) Type ¶
type Vxlan ¶
type Vxlan struct { LinkAttrs VxlanId int VtepDevIndex int SrcAddr net.IP Group net.IP TTL int TOS int Learning bool Proxy bool RSC bool L2miss bool L3miss bool NoAge bool GBP bool Age int Limit int Port int PortLow int PortHigh int }
func (*Vxlan) Attrs ¶
func (*Vxlan) Type ¶
type XfrmPolicy ¶
type XfrmPolicy struct { Dst *net.IPNet Src *net.IPNet Dir Dir Priority int Index int Tmpls []XfrmPolicyTmpl }
XfrmPolicy represents an ipsec policy. It represents the overlay network and has a list of XfrmPolicyTmpls representing the base addresses of the policy.
func XfrmPolicyList ¶
func XfrmPolicyList(family int) ([]XfrmPolicy, error)
XfrmPolicyList gets a list of xfrm policies in the system. Equivalent to: `ip xfrm policy show`. The list can be filtered by ip family.
type XfrmPolicyTmpl ¶
XfrmPolicyTmpl encapsulates a rule for the base addresses of an ipsec policy. These rules are matched with XfrmState to determine encryption and authentication algorithms.
type XfrmState ¶
type XfrmState struct { Dst net.IP Src net.IP Proto Proto Mode Mode Spi int Reqid int ReplayWindow int Auth *XfrmStateAlgo Crypt *XfrmStateAlgo Encap *XfrmStateEncap }
XfrmState represents the state of an ipsec policy. It optionally contains an XfrmStateAlgo for encryption and one for authentication.
func XfrmStateList ¶
XfrmStateList gets a list of xfrm states in the system. Equivalent to: `ip xfrm state show`. The list can be filtered by ip family.
type XfrmStateAlgo ¶
XfrmStateAlgo represents the algorithm to use for the ipsec encryption.
type XfrmStateEncap ¶
XfrmEncap represents the encapsulation to use for the ipsec encryption.
Source Files ¶
addr.go addr_linux.go class.go class_linux.go filter.go filter_linux.go link.go link_linux.go link_tuntap_linux.go neigh.go neigh_linux.go netlink.go protinfo.go protinfo_linux.go qdisc.go qdisc_linux.go route.go route_linux.go xfrm.go xfrm_policy.go xfrm_policy_linux.go xfrm_state.go xfrm_state_linux.go
Directories ¶
Path | Synopsis |
---|---|
Godeps/_workspace/src/github.com/vishvananda/netlink/nl | Package nl has low level primitives for making Netlink calls. |
- Version
- v0.5.1
- Published
- Dec 7, 2015
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 11 hours ago –
Tools for package owners.