netlink: github.com/vishvananda/netlink Index | Files | Directories

package netlink

import "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

Package Files

addr.go addr_linux.go bpf_linux.go bridge_linux.go class.go class_linux.go conntrack_linux.go devlink_linux.go filter.go filter_linux.go fou.go fou_linux.go genetlink_linux.go gtp_linux.go handle_linux.go ioctl_linux.go link.go link_linux.go link_tuntap_linux.go neigh.go neigh_linux.go netlink.go netlink_linux.go netns_linux.go order.go protinfo.go protinfo_linux.go qdisc.go qdisc_linux.go rdma_link_linux.go route.go route_linux.go rule.go rule_linux.go socket.go socket_linux.go xfrm.go xfrm_monitor_linux.go xfrm_policy.go xfrm_policy_linux.go xfrm_state.go xfrm_state_linux.go

Constants

const (
    // ConntrackTable Conntrack table
    // https://github.com/torvalds/linux/blob/master/include/uapi/linux/netfilter/nfnetlink.h -> #define NFNL_SUBSYS_CTNETLINK		 1
    ConntrackTable = 1
    // ConntrackExpectTable Conntrack expect table
    // https://github.com/torvalds/linux/blob/master/include/uapi/linux/netfilter/nfnetlink.h -> #define NFNL_SUBSYS_CTNETLINK_EXP 2
    ConntrackExpectTable = 2
)
const (
    ConntrackOrigSrcIP   = iota                // -orig-src ip    Source address from original direction
    ConntrackOrigDstIP                         // -orig-dst ip    Destination address from original direction
    ConntrackReplySrcIP                        // --reply-src ip  Reply Source IP
    ConntrackReplyDstIP                        // --reply-dst ip  Reply Destination IP
    ConntrackReplyAnyIP                        // Match source or destination reply IP
    ConntrackOrigSrcPort                       // --orig-port-src port    Source port in original direction
    ConntrackOrigDstPort                       // --orig-port-dst port    Destination port in original direction
    ConntrackNatSrcIP    = ConntrackReplySrcIP // deprecated use instead ConntrackReplySrcIP
    ConntrackNatDstIP    = ConntrackReplyDstIP // deprecated use instead ConntrackReplyDstIP
    ConntrackNatAnyIP    = ConntrackReplyAnyIP // deprecated use instead ConntrackReplyAnyIP
)
const (
    TC_U32_TERMINAL  = nl.TC_U32_TERMINAL
    TC_U32_OFFSET    = nl.TC_U32_OFFSET
    TC_U32_VAROFFSET = nl.TC_U32_VAROFFSET
    TC_U32_EAT       = nl.TC_U32_EAT
)

Constants used in TcU32Sel.Flags.

const (
    FOU_CMD_UNSPEC uint8 = iota
    FOU_CMD_ADD
    FOU_CMD_DEL
    FOU_CMD_GET
    FOU_CMD_MAX = FOU_CMD_GET
)
const (
    FOU_ATTR_UNSPEC = iota
    FOU_ATTR_PORT
    FOU_ATTR_AF
    FOU_ATTR_IPPROTO
    FOU_ATTR_TYPE
    FOU_ATTR_REMCSUM_NOPARTIAL
    FOU_ATTR_MAX = FOU_ATTR_REMCSUM_NOPARTIAL
)
const (
    FOU_ENCAP_UNSPEC = iota
    FOU_ENCAP_DIRECT
    FOU_ENCAP_GUE
    FOU_ENCAP_MAX = FOU_ENCAP_GUE
)
const (
    // ETHTOOL_GSSET_INFO gets string set info
    ETHTOOL_GSSET_INFO = 0x00000037
    // SIOCETHTOOL is Ethtool interface
    SIOCETHTOOL = 0x8946
    // ETHTOOL_GSTRINGS gets specified string set
    ETHTOOL_GSTRINGS = 0x0000001b
    // ETHTOOL_GSTATS gets NIC-specific statistics
    ETHTOOL_GSTATS = 0x0000001d
)

ioctl for statistics.

const (
    // ETH_SS_TEST is self-test result names, for use with %ETHTOOL_TEST
    ETH_SS_TEST = iota
    // ETH_SS_STATS statistic names, for use with %ETHTOOL_GSTATS
    ETH_SS_STATS
    // ETH_SS_PRIV_FLAGS are driver private flag names
    ETH_SS_PRIV_FLAGS

    // ETH_SS_FEATURES are device feature names
    ETH_SS_FEATURES
    // ETH_SS_RSS_HASH_FUNCS is RSS hush function names
    ETH_SS_RSS_HASH_FUNCS
)

string set id.

const (
    OperUnknown        = iota // Status can't be determined.
    OperNotPresent            // Some component is missing.
    OperDown                  // Down.
    OperLowerLayerDown        // Down due to state of lower layer.
    OperTesting               // In some test mode.
    OperDormant               // Not up but pending an external event.
    OperUp                    // Up, ready to send packets.
)
const (
    BOND_MODE_MASK uint64 = 1 << (1 + iota)
    BOND_ACTIVE_SLAVE_MASK
    BOND_MIIMON_MASK
    BOND_UPDELAY_MASK
    BOND_DOWNDELAY_MASK
    BOND_USE_CARRIER_MASK
    BOND_ARP_INTERVAL_MASK
    BOND_ARP_VALIDATE_MASK
    BOND_ARP_ALL_TARGETS_MASK
    BOND_PRIMARY_MASK
    BOND_PRIMARY_RESELECT_MASK
    BOND_FAIL_OVER_MAC_MASK
    BOND_XMIT_HASH_POLICY_MASK
    BOND_RESEND_IGMP_MASK
    BOND_NUM_PEER_NOTIF_MASK
    BOND_ALL_SLAVES_ACTIVE_MASK
    BOND_MIN_LINKS_MASK
    BOND_LP_INTERVAL_MASK
    BOND_PACKETS_PER_SLAVE_MASK
    BOND_LACP_RATE_MASK
    BOND_AD_SELECT_MASK
)

Flag mask for bond options. Bond.Flagmask must be set to on for option to work.

const (
    BondStateActive = iota // Link is active.
    BondStateBackup        // Link is backup.
)
const (
    BondLinkUp   = iota // link is up and running.
    BondLinkFail        // link has just gone down.
    BondLinkDown        // link has been down for too long time.
    BondLinkBack        // link is going back.
)
const (
    IPOIB_MODE_DATAGRAM = iota
    IPOIB_MODE_CONNECTED
)
const (
    SizeofLinkStats32 = 0x5c
    SizeofLinkStats64 = 0xb8
)
const (
    TUNTAP_MODE_TUN             TuntapMode = unix.IFF_TUN
    TUNTAP_MODE_TAP             TuntapMode = unix.IFF_TAP
    TUNTAP_DEFAULTS             TuntapFlag = unix.IFF_TUN_EXCL | unix.IFF_ONE_QUEUE
    TUNTAP_VNET_HDR             TuntapFlag = unix.IFF_VNET_HDR
    TUNTAP_TUN_EXCL             TuntapFlag = unix.IFF_TUN_EXCL
    TUNTAP_NO_PI                TuntapFlag = unix.IFF_NO_PI
    TUNTAP_ONE_QUEUE            TuntapFlag = unix.IFF_ONE_QUEUE
    TUNTAP_MULTI_QUEUE          TuntapFlag = unix.IFF_MULTI_QUEUE
    TUNTAP_MULTI_QUEUE_DEFAULTS TuntapFlag = TUNTAP_MULTI_QUEUE | TUNTAP_NO_PI
)
const (
    VF_LINK_STATE_AUTO    uint32 = 0
    VF_LINK_STATE_ENABLE  uint32 = 1
    VF_LINK_STATE_DISABLE uint32 = 2
)
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_MASTER
    NDA_LINK_NETNSID
    NDA_SRC_VNI
    NDA_MAX = NDA_SRC_VNI
)
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_ALL  = nl.FAMILY_ALL
    FAMILY_V4   = nl.FAMILY_V4
    FAMILY_V6   = nl.FAMILY_V6
    FAMILY_MPLS = nl.FAMILY_MPLS
)

Family type definitions

const (
    NETNSA_NSID
    NETNSA_PID
    NETNSA_FD
)

These can be replaced by the values from sys/unix when it is next released.

const (
    HANDLE_NONE      = 0
    HANDLE_INGRESS   = 0xFFFFFFF1
    HANDLE_CLSACT    = HANDLE_INGRESS
    HANDLE_ROOT      = 0xFFFFFFFF
    PRIORITY_MAP_LEN = 16
)
const (
    HANDLE_MIN_INGRESS = 0xFFFFFFF2
    HANDLE_MIN_EGRESS  = 0xFFFFFFF3
)
const (
    RT_FILTER_PROTOCOL uint64 = 1 << (1 + iota)
    RT_FILTER_SCOPE
    RT_FILTER_TYPE
    RT_FILTER_TOS
    RT_FILTER_IIF
    RT_FILTER_OIF
    RT_FILTER_DST
    RT_FILTER_SRC
    RT_FILTER_GW
    RT_FILTER_TABLE
    RT_FILTER_HOPLIMIT
    RT_FILTER_PRIORITY
    RT_FILTER_MARK
    RT_FILTER_MASK
)
const (
    FOU_GENL_NAME = "fou"
)
const FibRuleInvert = 0x2
const (
    TIME_UNITS_PER_SEC = 1000000
)

Variables

var (
    // ErrAttrHeaderTruncated is returned when a netlink attribute's header is
    // truncated.
    ErrAttrHeaderTruncated = errors.New("attribute header truncated")
    // ErrAttrBodyTruncated is returned when a netlink attribute's body is
    // truncated.
    ErrAttrBodyTruncated = errors.New("attribute body truncated")
)
var (
    // ErrNotImplemented is returned when a requested feature is not implemented.
    ErrNotImplemented = errors.New("not implemented")
)
var StringToBondLacpRateMap = map[string]BondLacpRate{
    "slow": BOND_LACP_RATE_SLOW,
    "fast": BOND_LACP_RATE_FAST,
}
var StringToBondModeMap = map[string]BondMode{
    "balance-rr":    BOND_MODE_BALANCE_RR,
    "active-backup": BOND_MODE_ACTIVE_BACKUP,
    "balance-xor":   BOND_MODE_BALANCE_XOR,
    "broadcast":     BOND_MODE_BROADCAST,
    "802.3ad":       BOND_MODE_802_3AD,
    "balance-tlb":   BOND_MODE_BALANCE_TLB,
    "balance-alb":   BOND_MODE_BALANCE_ALB,
}
var StringToBondXmitHashPolicyMap = map[string]BondXmitHashPolicy{
    "layer2":   BOND_XMIT_HASH_POLICY_LAYER2,
    "layer3+4": BOND_XMIT_HASH_POLICY_LAYER3_4,
    "layer2+3": BOND_XMIT_HASH_POLICY_LAYER2_3,
    "encap2+3": BOND_XMIT_HASH_POLICY_ENCAP2_3,
    "encap3+4": BOND_XMIT_HASH_POLICY_ENCAP3_4,
}
var StringToIPoIBMode = map[string]IPoIBMode{
    "datagram":  IPOIB_MODE_DATAGRAM,
    "connected": IPOIB_MODE_CONNECTED,
}
var StringToVlanProtocolMap = map[string]VlanProtocol{
    "802.1q":  VLAN_PROTOCOL_8021Q,
    "802.1ad": VLAN_PROTOCOL_8021AD,
}
var VlanProtocolToString = map[VlanProtocol]string{
    VLAN_PROTOCOL_8021Q:  "802.1q",
    VLAN_PROTOCOL_8021AD: "802.1ad",
}

func AddrAdd Uses

func AddrAdd(link Link, addr *Addr) error

AddrAdd will add an IP address to a link device.

Equivalent to: `ip addr add $addr dev $link`

If `addr` is an IPv4 address and the broadcast address is not given, it will be automatically computed based on the IP mask if /30 or larger.

func AddrDel Uses

func AddrDel(link Link, addr *Addr) error

AddrDel will delete an IP address from a link device.

Equivalent to: `ip addr del $addr dev $link`

If `addr` is an IPv4 address and the broadcast address is not given, it will be automatically computed based on the IP mask if /30 or larger.

func AddrReplace Uses

func AddrReplace(link Link, addr *Addr) error

AddrReplace will replace (or, if not present, add) an IP address on a link device.

Equivalent to: `ip addr replace $addr dev $link`

If `addr` is an IPv4 address and the broadcast address is not given, it will be automatically computed based on the IP mask if /30 or larger.

func AddrSubscribe Uses

func AddrSubscribe(ch chan<- AddrUpdate, done <-chan struct{}) error

AddrSubscribe takes a chan down which notifications will be sent when addresses change. Close the 'done' chan to stop subscription.

func AddrSubscribeAt Uses

func AddrSubscribeAt(ns netns.NsHandle, ch chan<- AddrUpdate, done <-chan struct{}) error

AddrSubscribeAt works like AddrSubscribe plus it allows the caller to choose the network namespace in which to subscribe (ns).

func AddrSubscribeWithOptions Uses

func AddrSubscribeWithOptions(ch chan<- AddrUpdate, done <-chan struct{}, options AddrSubscribeOptions) error

AddrSubscribeWithOptions work like AddrSubscribe but enable to provide additional options to modify the behavior. Currently, the namespace can be provided as well as an error callback.

func AdjustSize Uses

func AdjustSize(sz uint, mpu uint, linklayer int) uint

func AlignToAtm Uses

func AlignToAtm(size uint) uint

func BridgeSetMcastSnoop Uses

func BridgeSetMcastSnoop(link Link, on bool) error

func BridgeSetVlanFiltering Uses

func BridgeSetVlanFiltering(link Link, on bool) error

func BridgeVlanAdd Uses

func BridgeVlanAdd(link Link, vid uint16, pvid, untagged, self, master bool) error

BridgeVlanAdd adds a new vlan filter entry Equivalent to: `bridge vlan add dev DEV vid VID [ pvid ] [ untagged ] [ self ] [ master ]`

func BridgeVlanDel Uses

func BridgeVlanDel(link Link, vid uint16, pvid, untagged, self, master bool) error

BridgeVlanDel adds a new vlan filter entry Equivalent to: `bridge vlan del dev DEV vid VID [ pvid ] [ untagged ] [ self ] [ master ]`

func BridgeVlanList Uses

func BridgeVlanList() (map[int32][]*nl.BridgeVlanInfo, error)

BridgeVlanList gets a map of device id to bridge vlan infos. Equivalent to: `bridge vlan show`

func CalcRtable Uses

func CalcRtable(rate *nl.TcRateSpec, rtab []uint32, cellLog int, mtu uint32, linklayer int) int

func ClassAdd Uses

func ClassAdd(class Class) error

ClassAdd will add a class to the system. Equivalent to: `tc class add $class`

func ClassChange Uses

func ClassChange(class Class) error

ClassChange will change a class in place Equivalent to: `tc class change $class` The parent and handle MUST NOT be changed.

func ClassDel Uses

func ClassDel(class Class) error

ClassDel will delete a class from the system. Equivalent to: `tc class del $class`

func ClassReplace Uses

func ClassReplace(class Class) error

ClassReplace will replace a class to the system. quivalent to: `tc class replace $class` The handle MAY be changed. If a class already exist with this parent/handle pair, the class is changed. If a class does not already exist with this parent/handle, a new class is created.

func ClockFactor Uses

func ClockFactor() float64

func ConntrackDeleteFilter Uses

func ConntrackDeleteFilter(table ConntrackTableType, family InetFamily, filter CustomConntrackFilter) (uint, error)

ConntrackDeleteFilter deletes entries on the specified table on the base of the filter conntrack -D [table] parameters Delete conntrack or expectation

func ConntrackTableFlush Uses

func ConntrackTableFlush(table ConntrackTableType) error

ConntrackTableFlush flushes all the flows of a specified table conntrack -F [table] Flush table The flush operation applies to all the family types

func DeserializeRtab Uses

func DeserializeRtab(b []byte) [256]uint32

func DevLinkSetEswitchMode Uses

func DevLinkSetEswitchMode(Dev *DevlinkDevice, NewMode string) error

DevLinkSetEswitchMode sets eswitch mode if able to set successfully or returns an error code. Equivalent to: `devlink dev eswitch set $dev mode switchdev` Equivalent to: `devlink dev eswitch set $dev mode legacy`

func EncodeActions Uses

func EncodeActions(attr *nl.RtAttr, actions []Action) error

func FilterAdd Uses

func FilterAdd(filter Filter) error

FilterAdd will add a filter to the system. Equivalent to: `tc filter add $filter`

func FilterDel Uses

func FilterDel(filter Filter) error

FilterDel will delete a filter from the system. Equivalent to: `tc filter del $filter`

func FilterReplace Uses

func FilterReplace(filter Filter) error

FilterReplace will replace a filter. Equivalent to: `tc filter replace $filter`

func FouAdd Uses

func FouAdd(f Fou) error

func FouDel Uses

func FouDel(f Fou) error

func FouFamilyId Uses

func FouFamilyId() (int, error)

func GTPPDPAdd Uses

func GTPPDPAdd(link Link, pdp *PDP) error

func GTPPDPDel Uses

func GTPPDPDel(link Link, pdp *PDP) error

func GetNetNsIdByFd Uses

func GetNetNsIdByFd(fd int) (int, error)

GetNetNsIdByFd looks up the network namespace ID for a given fd. fd must be an open file descriptor to a namespace file. Returns -1 if the namespace does not have an ID set.

func GetNetNsIdByPid Uses

func GetNetNsIdByPid(pid int) (int, error)

GetNetNsIdByPid looks up the network namespace ID for a given pid (really thread id). Returns -1 if the namespace does not have an ID set.

func HandleStr Uses

func HandleStr(handle uint32) string

func Hz Uses

func Hz() float64

func LinkAdd Uses

func LinkAdd(link Link) error

LinkAdd adds a new link device. The type and features of the device are taken from the parameters in the link object. Equivalent to: `ip link add $link`

func LinkDel Uses

func LinkDel(link Link) error

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 LinkSetARPOff Uses

func LinkSetARPOff(link Link) error

func LinkSetARPOn Uses

func LinkSetARPOn(link Link) error

func LinkSetAlias Uses

func LinkSetAlias(link Link, name string) error

LinkSetAlias sets the alias of the link device. Equivalent to: `ip link set dev $link alias $name`

func LinkSetAllmulticastOff Uses

func LinkSetAllmulticastOff(link Link) error

LinkSetAllmulticastOff disables the reception of all hardware multicast packets for the link device. Equivalent to: `ip link set $link allmulticast off`

func LinkSetAllmulticastOn Uses

func LinkSetAllmulticastOn(link Link) error

LinkSetAllmulticastOn enables the reception of all hardware multicast packets for the link device. Equivalent to: `ip link set $link allmulticast on`

func LinkSetBondSlave Uses

func LinkSetBondSlave(link Link, master *Bond) error

LinkSetBondSlave add slave to bond link via ioctl interface.

func LinkSetBondSlaveQueueId Uses

func LinkSetBondSlaveQueueId(link Link, queueId uint16) error

LinkSetBondSlaveQueueId modify bond slave queue-id.

func LinkSetBrProxyArp Uses

func LinkSetBrProxyArp(link Link, mode bool) error

func LinkSetBrProxyArpWiFi Uses

func LinkSetBrProxyArpWiFi(link Link, mode bool) error

func LinkSetDown Uses

func LinkSetDown(link Link) error

LinkSetDown disables link device. Equivalent to: `ip link set $link down`

func LinkSetFastLeave Uses

func LinkSetFastLeave(link Link, mode bool) error

func LinkSetFlood Uses

func LinkSetFlood(link Link, mode bool) error

func LinkSetGroup Uses

func LinkSetGroup(link Link, group int) error

LinkSetGroup sets the link group id which can be used to perform mass actions with iproute2 as well use it as a reference in nft filters. Equivalent to: `ip link set $link group $id`

func LinkSetGuard Uses

func LinkSetGuard(link Link, mode bool) error

func LinkSetHairpin Uses

func LinkSetHairpin(link Link, mode bool) error

func LinkSetHardwareAddr Uses

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 Uses

func LinkSetLearning(link Link, mode bool) error

func LinkSetMTU Uses

func LinkSetMTU(link Link, mtu int) error

LinkSetMTU sets the mtu of the link device. Equivalent to: `ip link set $link mtu $mtu`

func LinkSetMaster Uses

func LinkSetMaster(link Link, master Link) error

LinkSetMaster sets the master of the link device. Equivalent to: `ip link set $link master $master`

func LinkSetMasterByIndex Uses

func LinkSetMasterByIndex(link Link, masterIndex int) error

LinkSetMasterByIndex sets the master of the link device. Equivalent to: `ip link set $link master $master`

func LinkSetName Uses

func LinkSetName(link Link, name string) error

LinkSetName sets the name of the link device. Equivalent to: `ip link set $link name $name`

func LinkSetNoMaster Uses

func LinkSetNoMaster(link Link) error

LinkSetNoMaster removes the master of the link device. Equivalent to: `ip link set $link nomaster`

func LinkSetNsFd Uses

func LinkSetNsFd(link Link, fd int) error

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 Uses

func LinkSetNsPid(link Link, nspid int) error

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 Uses

func LinkSetRootBlock(link Link, mode bool) error

func LinkSetTxQLen Uses

func LinkSetTxQLen(link Link, qlen int) error

LinkSetTxQLen sets the transaction queue length for the link. Equivalent to: `ip link set $link txqlen $qlen`

func LinkSetUp Uses

func LinkSetUp(link Link) error

LinkSetUp enables the link device. Equivalent to: `ip link set $link up`

func LinkSetVfHardwareAddr Uses

func LinkSetVfHardwareAddr(link Link, vf int, hwaddr net.HardwareAddr) error

LinkSetVfHardwareAddr sets the hardware address of a vf for the link. Equivalent to: `ip link set $link vf $vf mac $hwaddr`

func LinkSetVfNodeGUID Uses

func LinkSetVfNodeGUID(link Link, vf int, nodeguid net.HardwareAddr) error

LinkSetVfNodeGUID sets the node GUID of a vf for the link. Equivalent to: `ip link set dev $link vf $vf node_guid $nodeguid`

func LinkSetVfPortGUID Uses

func LinkSetVfPortGUID(link Link, vf int, portguid net.HardwareAddr) error

LinkSetVfPortGUID sets the port GUID of a vf for the link. Equivalent to: `ip link set dev $link vf $vf port_guid $portguid`

func LinkSetVfRate Uses

func LinkSetVfRate(link Link, vf, minRate, maxRate int) error

LinkSetVfRate sets the min and max tx rate of a vf for the link. Equivalent to: `ip link set $link vf $vf min_tx_rate $min_rate max_tx_rate $max_rate`

func LinkSetVfSpoofchk Uses

func LinkSetVfSpoofchk(link Link, vf int, check bool) error

LinkSetVfSpoofchk enables/disables spoof check on a vf for the link. Equivalent to: `ip link set $link vf $vf spoofchk $check`

func LinkSetVfState Uses

func LinkSetVfState(link Link, vf int, state uint32) error

LinkSetVfState enables/disables virtual link state on a vf. Equivalent to: `ip link set $link vf $vf state $state`

func LinkSetVfTrust Uses

func LinkSetVfTrust(link Link, vf int, state bool) error

LinkSetVfTrust enables/disables trust state on a vf for the link. Equivalent to: `ip link set $link vf $vf trust $state`

func LinkSetVfTxRate Uses

func LinkSetVfTxRate(link Link, vf, rate int) error

LinkSetVfTxRate sets the tx rate of a vf for the link. Equivalent to: `ip link set $link vf $vf rate $rate`

func LinkSetVfVlan Uses

func LinkSetVfVlan(link Link, vf, vlan int) error

LinkSetVfVlan sets the vlan of a vf for the link. Equivalent to: `ip link set $link vf $vf vlan $vlan`

func LinkSetVfVlanQos Uses

func LinkSetVfVlanQos(link Link, vf, vlan, qos int) error

LinkSetVfVlanQos sets the vlan and qos priority of a vf for the link. Equivalent to: `ip link set $link vf $vf vlan $vlan qos $qos`

func LinkSetXdpFd Uses

func LinkSetXdpFd(link Link, fd int) error

LinkSetXdpFd adds a bpf function to the driver. The fd must be a bpf program loaded with bpf(type=BPF_PROG_TYPE_XDP)

func LinkSetXdpFdWithFlags Uses

func LinkSetXdpFdWithFlags(link Link, fd, flags int) error

LinkSetXdpFdWithFlags adds a bpf function to the driver with the given options. The fd must be a bpf program loaded with bpf(type=BPF_PROG_TYPE_XDP)

func LinkSubscribe Uses

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 LinkSubscribeAt Uses

func LinkSubscribeAt(ns netns.NsHandle, ch chan<- LinkUpdate, done <-chan struct{}) error

LinkSubscribeAt works like LinkSubscribe plus it allows the caller to choose the network namespace in which to subscribe (ns).

func LinkSubscribeWithOptions Uses

func LinkSubscribeWithOptions(ch chan<- LinkUpdate, done <-chan struct{}, options LinkSubscribeOptions) error

LinkSubscribeWithOptions work like LinkSubscribe but enable to provide additional options to modify the behavior. Currently, the namespace can be provided as well as an error callback.

func MacvlanMACAddrAdd Uses

func MacvlanMACAddrAdd(link Link, addr net.HardwareAddr) error

func MacvlanMACAddrDel Uses

func MacvlanMACAddrDel(link Link, addr net.HardwareAddr) error

func MacvlanMACAddrFlush Uses

func MacvlanMACAddrFlush(link Link) error

func MacvlanMACAddrSet Uses

func MacvlanMACAddrSet(link Link, addrs []net.HardwareAddr) error

func MajorMinor Uses

func MajorMinor(handle uint32) (uint16, uint16)

func MakeHandle Uses

func MakeHandle(major, minor uint16) uint32

func NeighAdd Uses

func NeighAdd(neigh *Neigh) error

NeighAdd will add an IP to MAC mapping to the ARP table Equivalent to: `ip neigh add ....`

func NeighAppend Uses

func NeighAppend(neigh *Neigh) error

NeighAppend will append an entry to FDB Equivalent to: `bridge fdb append...`

func NeighDel Uses

func NeighDel(neigh *Neigh) error

NeighDel will delete an IP address from a link device. Equivalent to: `ip addr del $addr dev $link`

func NeighSet Uses

func NeighSet(neigh *Neigh) error

NeighSet will add or replace an IP to MAC mapping to the ARP table Equivalent to: `ip neigh replace....`

func NeighSubscribe Uses

func NeighSubscribe(ch chan<- NeighUpdate, done <-chan struct{}) error

NeighSubscribe takes a chan down which notifications will be sent when neighbors are added or deleted. Close the 'done' chan to stop subscription.

func NeighSubscribeAt Uses

func NeighSubscribeAt(ns netns.NsHandle, ch chan<- NeighUpdate, done <-chan struct{}) error

NeighSubscribeAt works like NeighSubscribe plus it allows the caller to choose the network namespace in which to subscribe (ns).

func NeighSubscribeWithOptions Uses

func NeighSubscribeWithOptions(ch chan<- NeighUpdate, done <-chan struct{}, options NeighSubscribeOptions) error

NeighSubscribeWithOptions work like NeighSubscribe but enable to provide additional options to modify the behavior. Currently, the namespace can be provided as well as an error callback.

func NewIPNet Uses

func NewIPNet(ip net.IP) *net.IPNet

NewIPNet generates an IPNet from an ip address using a netmask of 32 or 128.

func ParseIPNet Uses

func ParseIPNet(s string) (*net.IPNet, error)

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 Percentage2u32 Uses

func Percentage2u32(percentage float32) uint32

func QdiscAdd Uses

func QdiscAdd(qdisc Qdisc) error

QdiscAdd will add a qdisc to the system. Equivalent to: `tc qdisc add $qdisc`

func QdiscChange Uses

func QdiscChange(qdisc Qdisc) error

QdiscChange will change a qdisc in place Equivalent to: `tc qdisc change $qdisc` The parent and handle MUST NOT be changed.

func QdiscDel Uses

func QdiscDel(qdisc Qdisc) error

QdiscDel will delete a qdisc from the system. Equivalent to: `tc qdisc del $qdisc`

func QdiscReplace Uses

func QdiscReplace(qdisc Qdisc) error

QdiscReplace will replace a qdisc to the system. Equivalent to: `tc qdisc replace $qdisc` The handle MUST change.

func RdmaLinkSetName Uses

func RdmaLinkSetName(link *RdmaLink, name string) error

RdmaLinkSetName sets the name of the rdma link device. Return nil on success or error otherwise. Equivalent to: `rdma dev set $old_devname name $name`

func RdmaLinkSetNsFd Uses

func RdmaLinkSetNsFd(link *RdmaLink, fd uint32) error

RdmaLinkSetNsFd puts the RDMA device into a new network namespace. The fd must be an open file descriptor to a network namespace. Similar to: `rdma dev set $dev netns $ns`

func RdmaSystemGetNetnsMode Uses

func RdmaSystemGetNetnsMode() (string, error)

RdmaSystemGetNetnsMode gets the net namespace mode for RDMA subsystem Returns mode string and error status as nil on success or returns error otherwise. Equivalent to: `rdma system show netns'

func RdmaSystemSetNetnsMode Uses

func RdmaSystemSetNetnsMode(NewMode string) error

RdmaSystemSetNetnsMode sets the net namespace mode for RDMA subsystem Returns nil on success or appropriate error code. Equivalent to: `rdma system set netns { shared | exclusive }'

func RouteAdd Uses

func RouteAdd(route *Route) error

RouteAdd will add a route to the system. Equivalent to: `ip route add $route`

func RouteDel Uses

func RouteDel(route *Route) error

RouteDel will delete a route from the system. Equivalent to: `ip route del $route`

func RouteReplace Uses

func RouteReplace(route *Route) error

RouteReplace will add a route to the system. Equivalent to: `ip route replace $route`

func RouteSubscribe Uses

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 RouteSubscribeAt Uses

func RouteSubscribeAt(ns netns.NsHandle, ch chan<- RouteUpdate, done <-chan struct{}) error

RouteSubscribeAt works like RouteSubscribe plus it allows the caller to choose the network namespace in which to subscribe (ns).

func RouteSubscribeWithOptions Uses

func RouteSubscribeWithOptions(ch chan<- RouteUpdate, done <-chan struct{}, options RouteSubscribeOptions) error

RouteSubscribeWithOptions work like RouteSubscribe but enable to provide additional options to modify the behavior. Currently, the namespace can be provided as well as an error callback.

func RuleAdd Uses

func RuleAdd(rule *Rule) error

RuleAdd adds a rule to the system. Equivalent to: ip rule add

func RuleDel Uses

func RuleDel(rule *Rule) error

RuleDel deletes a rule from the system. Equivalent to: ip rule del

func SerializeRtab Uses

func SerializeRtab(rtab [256]uint32) []byte

func SetNetNsIdByFd Uses

func SetNetNsIdByFd(fd, nsid int) error

SetNetNSIdByFd sets the ID of the network namespace for a given fd. fd must be an open file descriptor to a namespace file. The ID can only be set for namespaces without an ID already set.

func SetNetNsIdByPid Uses

func SetNetNsIdByPid(pid, nsid int) error

SetNetNSIdByPid sets the ID of the network namespace for a given pid (really thread id). The ID can only be set for namespaces without an ID already set.

func SetPromiscOff Uses

func SetPromiscOff(link Link) error

func SetPromiscOn Uses

func SetPromiscOn(link Link) error

func TickInUsec Uses

func TickInUsec() float64

func VethPeerIndex Uses

func VethPeerIndex(link *Veth) (int, error)

VethPeerIndex get veth peer index.

func XfrmMonitor Uses

func XfrmMonitor(ch chan<- XfrmMsg, done <-chan struct{}, errorChan chan<- error,
    types ...nl.XfrmMsgType) error

func XfrmPolicyAdd Uses

func XfrmPolicyAdd(policy *XfrmPolicy) error

XfrmPolicyAdd will add an xfrm policy to the system. Equivalent to: `ip xfrm policy add $policy`

func XfrmPolicyDel Uses

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 XfrmPolicyFlush Uses

func XfrmPolicyFlush() error

XfrmPolicyFlush will flush the policies on the system. Equivalent to: `ip xfrm policy flush`

func XfrmPolicyUpdate Uses

func XfrmPolicyUpdate(policy *XfrmPolicy) error

XfrmPolicyUpdate will update an xfrm policy to the system. Equivalent to: `ip xfrm policy update $policy`

func XfrmStateAdd Uses

func XfrmStateAdd(state *XfrmState) error

XfrmStateAdd will add an xfrm state to the system. Equivalent to: `ip xfrm state add $state`

func XfrmStateDel Uses

func XfrmStateDel(state *XfrmState) error

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 XfrmStateFlush Uses

func XfrmStateFlush(proto Proto) error

XfrmStateFlush will flush the xfrm state on the system. proto = 0 means any transformation protocols Equivalent to: `ip xfrm state flush [ proto XFRM-PROTO ]`

func XfrmStateUpdate Uses

func XfrmStateUpdate(state *XfrmState) error

XfrmStateUpdate will update an xfrm state to the system. Equivalent to: `ip xfrm state update $state`

func Xmittime Uses

func Xmittime(rate uint64, size uint32) float64

type Action Uses

type Action interface {
    Attrs() *ActionAttrs
    Type() string
}

Action represents an action in any supported filter.

type ActionAttrs Uses

type ActionAttrs struct {
    Index   int
    Capab   int
    Action  TcAct
    Refcnt  int
    Bindcnt int
}

func (ActionAttrs) String Uses

func (q ActionAttrs) String() string

type Addr Uses

type Addr struct {
    *net.IPNet
    Label       string
    Flags       int
    Scope       int
    Peer        *net.IPNet
    Broadcast   net.IP
    PreferedLft int
    ValidLft    int
    LinkIndex   int
}

Addr represents an IP address from netlink. Netlink ip addresses include a mask, so it stores the address as a net.IPNet.

func AddrList Uses

func AddrList(link Link, family int) ([]Addr, error)

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 Uses

func ParseAddr(s string) (*Addr, error)

ParseAddr parses the string representation of an address in the form $ip/$netmask $label. The label portion is optional

func (Addr) Equal Uses

func (a Addr) Equal(x Addr) bool

Equal returns true if both Addrs have the same net.IPNet value.

func (Addr) PeerEqual Uses

func (a Addr) PeerEqual(x Addr) bool

func (Addr) String Uses

func (a Addr) String() string

String returns $ip/$netmask $label

type AddrSubscribeOptions Uses

type AddrSubscribeOptions struct {
    Namespace         *netns.NsHandle
    ErrorCallback     func(error)
    ListExisting      bool
    ReceiveBufferSize int
}

AddrSubscribeOptions contains a set of options to use with AddrSubscribeWithOptions.

type AddrUpdate Uses

type AddrUpdate struct {
    LinkAddress net.IPNet
    LinkIndex   int
    Flags       int
    Scope       int
    PreferedLft int
    ValidLft    int
    NewAddr     bool // true=added false=deleted
}

type BPFAttr Uses

type BPFAttr struct {
    ProgType    uint32
    InsnCnt     uint32
    Insns       uintptr
    License     uintptr
    LogLevel    uint32
    LogSize     uint32
    LogBuf      uintptr
    KernVersion uint32
}

type Bond Uses

type Bond struct {
    LinkAttrs
    Mode            BondMode
    ActiveSlave     int
    Miimon          int
    UpDelay         int
    DownDelay       int
    UseCarrier      int
    ArpInterval     int
    ArpIpTargets    []net.IP
    ArpValidate     BondArpValidate
    ArpAllTargets   BondArpAllTargets
    Primary         int
    PrimaryReselect BondPrimaryReselect
    FailOverMac     BondFailOverMac
    XmitHashPolicy  BondXmitHashPolicy
    ResendIgmp      int
    NumPeerNotif    int
    AllSlavesActive int
    MinLinks        int
    LpInterval      int
    PackersPerSlave int
    LacpRate        BondLacpRate
    AdSelect        BondAdSelect
    // looking at iproute tool AdInfo can only be retrived. It can't be set.
    AdInfo         *BondAdInfo
    AdActorSysPrio int
    AdUserPortKey  int
    AdActorSystem  net.HardwareAddr
    TlbDynamicLb   int
}

Bond representation

func NewLinkBond Uses

func NewLinkBond(atr LinkAttrs) *Bond

func (*Bond) Attrs Uses

func (bond *Bond) Attrs() *LinkAttrs

Attrs implementation.

func (*Bond) Type Uses

func (bond *Bond) Type() string

Type implementation fro Vxlan.

type BondAdInfo Uses

type BondAdInfo struct {
    AggregatorId int
    NumPorts     int
    ActorKey     int
    PartnerKey   int
    PartnerMac   net.HardwareAddr
}

BondAdInfo represents ad info for bond

type BondAdSelect Uses

type BondAdSelect int

BondAdSelect type

const (
    BOND_AD_SELECT_STABLE BondAdSelect = iota
    BOND_AD_SELECT_BANDWIDTH
    BOND_AD_SELECT_COUNT
)

Possible BondAdSelect value

type BondArpAllTargets Uses

type BondArpAllTargets int

BondArpAllTargets type

const (
    BOND_ARP_ALL_TARGETS_ANY BondArpAllTargets = iota
    BOND_ARP_ALL_TARGETS_ALL
)

Possible BondArpAllTargets value

type BondArpValidate Uses

type BondArpValidate int

BondArpValidate type

const (
    BOND_ARP_VALIDATE_NONE BondArpValidate = iota
    BOND_ARP_VALIDATE_ACTIVE
    BOND_ARP_VALIDATE_BACKUP
    BOND_ARP_VALIDATE_ALL
)

Possible BondArpValidate value

type BondFailOverMac Uses

type BondFailOverMac int

BondFailOverMac type

const (
    BOND_FAIL_OVER_MAC_NONE BondFailOverMac = iota
    BOND_FAIL_OVER_MAC_ACTIVE
    BOND_FAIL_OVER_MAC_FOLLOW
)

Possible BondFailOverMac value

type BondLacpRate Uses

type BondLacpRate int

BondLacpRate type

const (
    BOND_LACP_RATE_SLOW BondLacpRate = iota
    BOND_LACP_RATE_FAST
    BOND_LACP_RATE_UNKNOWN
)

Possible BondLacpRate value

func StringToBondLacpRate Uses

func StringToBondLacpRate(s string) BondLacpRate

StringToBondLacpRate returns bond lacp arte, or unknown is the s is invalid.

func (BondLacpRate) String Uses

func (b BondLacpRate) String() string

type BondMode Uses

type BondMode int

BondMode type

const (
    BOND_MODE_BALANCE_RR BondMode = iota
    BOND_MODE_ACTIVE_BACKUP
    BOND_MODE_BALANCE_XOR
    BOND_MODE_BROADCAST
    BOND_MODE_802_3AD
    BOND_MODE_BALANCE_TLB
    BOND_MODE_BALANCE_ALB
    BOND_MODE_UNKNOWN
)

Possible BondMode

func StringToBondMode Uses

func StringToBondMode(s string) BondMode

StringToBondMode returns bond mode, or unknown is the s is invalid.

func (BondMode) String Uses

func (b BondMode) String() string

type BondPrimaryReselect Uses

type BondPrimaryReselect int

BondPrimaryReselect type

const (
    BOND_PRIMARY_RESELECT_ALWAYS BondPrimaryReselect = iota
    BOND_PRIMARY_RESELECT_BETTER
    BOND_PRIMARY_RESELECT_FAILURE
)

Possible BondPrimaryReselect value

type BondSlave Uses

type BondSlave struct {
    State                  BondSlaveState
    MiiStatus              BondSlaveMiiStatus
    LinkFailureCount       uint32
    PermHardwareAddr       net.HardwareAddr
    QueueId                uint16
    AggregatorId           uint16
    AdActorOperPortState   uint8
    AdPartnerOperPortState uint16
}

func (*BondSlave) SlaveType Uses

func (b *BondSlave) SlaveType() string

type BondSlaveMiiStatus Uses

type BondSlaveMiiStatus uint8

BondSlaveState represents the values of the IFLA_BOND_SLAVE_MII_STATUS bond slave attribute, which contains the status of MII link monitoring

func (BondSlaveMiiStatus) String Uses

func (s BondSlaveMiiStatus) String() string

type BondSlaveState Uses

type BondSlaveState uint8

BondSlaveState represents the values of the IFLA_BOND_SLAVE_STATE bond slave attribute, which contains the state of the bond slave.

func (BondSlaveState) String Uses

func (s BondSlaveState) String() string

type BondXmitHashPolicy Uses

type BondXmitHashPolicy int

BondXmitHashPolicy type

const (
    BOND_XMIT_HASH_POLICY_LAYER2 BondXmitHashPolicy = iota
    BOND_XMIT_HASH_POLICY_LAYER3_4
    BOND_XMIT_HASH_POLICY_LAYER2_3
    BOND_XMIT_HASH_POLICY_ENCAP2_3
    BOND_XMIT_HASH_POLICY_ENCAP3_4
    BOND_XMIT_HASH_POLICY_UNKNOWN
)

Possible BondXmitHashPolicy value

func StringToBondXmitHashPolicy Uses

func StringToBondXmitHashPolicy(s string) BondXmitHashPolicy

StringToBondXmitHashPolicy returns bond lacp arte, or unknown is the s is invalid.

func (BondXmitHashPolicy) String Uses

func (b BondXmitHashPolicy) String() string

type BpfAction Uses

type BpfAction struct {
    ActionAttrs
    Fd   int
    Name string
}

func (*BpfAction) Attrs Uses

func (action *BpfAction) Attrs() *ActionAttrs

func (*BpfAction) Type Uses

func (action *BpfAction) Type() string

type BpfFilter Uses

type BpfFilter struct {
    FilterAttrs
    ClassId      uint32
    Fd           int
    Name         string
    DirectAction bool
    Id           int
    Tag          string
}

func (*BpfFilter) Attrs Uses

func (filter *BpfFilter) Attrs() *FilterAttrs

func (*BpfFilter) Type Uses

func (filter *BpfFilter) Type() string

type BpfProgType Uses

type BpfProgType uint32
const (
    BPF_PROG_TYPE_UNSPEC BpfProgType = iota
    BPF_PROG_TYPE_SOCKET_FILTER
    BPF_PROG_TYPE_KPROBE
    BPF_PROG_TYPE_SCHED_CLS
    BPF_PROG_TYPE_SCHED_ACT
    BPF_PROG_TYPE_TRACEPOINT
    BPF_PROG_TYPE_XDP
)

type Bridge Uses

type Bridge struct {
    LinkAttrs
    MulticastSnooping *bool
    HelloTime         *uint32
    VlanFiltering     *bool
}

Bridge links are simple linux bridges

func (*Bridge) Attrs Uses

func (bridge *Bridge) Attrs() *LinkAttrs

func (*Bridge) Type Uses

func (bridge *Bridge) Type() string

type Class Uses

type Class interface {
    Attrs() *ClassAttrs
    Type() string
}

Class interfaces for all classes

func ClassList Uses

func ClassList(link Link, parent uint32) ([]Class, error)

ClassList gets a list of classes in the system. Equivalent to: `tc class show`. Generally returns nothing if link and parent are not specified.

type ClassAttrs Uses

type ClassAttrs struct {
    LinkIndex  int
    Handle     uint32
    Parent     uint32
    Leaf       uint32
    Statistics *ClassStatistics
}

ClassAttrs 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 Uses

func (q ClassAttrs) String() string

type ClassStatistics Uses

type ClassStatistics struct {
    Basic   *GnetStatsBasic
    Queue   *GnetStatsQueue
    RateEst *GnetStatsRateEst
}

ClassStatistics representation based on generic networking statistics for netlink. See Documentation/networking/gen_stats.txt in Linux source code for more details.

func NewClassStatistics Uses

func NewClassStatistics() *ClassStatistics

NewClassStatistics Construct a ClassStatistics struct which fields are all initialized by 0.

type ConnmarkAction Uses

type ConnmarkAction struct {
    ActionAttrs
    Zone uint16
}

func NewConnmarkAction Uses

func NewConnmarkAction() *ConnmarkAction

func (*ConnmarkAction) Attrs Uses

func (action *ConnmarkAction) Attrs() *ActionAttrs

func (*ConnmarkAction) Type Uses

func (action *ConnmarkAction) Type() string

type ConntrackFilter Uses

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

func (*ConntrackFilter) AddIP Uses

func (f *ConntrackFilter) AddIP(tp ConntrackFilterType, ip net.IP) error

AddIP adds an IP to the conntrack filter

func (*ConntrackFilter) AddPort Uses

func (f *ConntrackFilter) AddPort(tp ConntrackFilterType, port uint16) error

AddPort adds a Port to the conntrack filter if the Layer 4 protocol allows it

func (*ConntrackFilter) AddProtocol Uses

func (f *ConntrackFilter) AddProtocol(proto uint8) error

AddProtocol adds the Layer 4 protocol to the conntrack filter

func (*ConntrackFilter) MatchConntrackFlow Uses

func (f *ConntrackFilter) MatchConntrackFlow(flow *ConntrackFlow) bool

MatchConntrackFlow applies the filter to the flow and returns true if the flow matches the filter false otherwise

type ConntrackFilterType Uses

type ConntrackFilterType uint8

Filter types

type ConntrackFlow Uses

type ConntrackFlow struct {
    FamilyType uint8
    Forward    ipTuple
    Reverse    ipTuple
    Mark       uint32
}

func ConntrackTableList Uses

func ConntrackTableList(table ConntrackTableType, family InetFamily) ([]*ConntrackFlow, error)

ConntrackTableList returns the flow list of a table of a specific family conntrack -L [table] [options] List conntrack or expectation table

func (*ConntrackFlow) String Uses

func (s *ConntrackFlow) String() string

type ConntrackTableType Uses

type ConntrackTableType uint8

ConntrackTableType Conntrack table for the netlink operation

type CustomConntrackFilter Uses

type CustomConntrackFilter interface {
    // MatchConntrackFlow applies the filter to the flow and returns true if the flow matches
    // the filter or false otherwise
    MatchConntrackFlow(flow *ConntrackFlow) bool
}

type Destination Uses

type Destination interface {
    Family() int
    Decode([]byte) error
    Encode() ([]byte, error)
    String() string
    Equal(Destination) bool
}

type Device Uses

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 Uses

func (device *Device) Attrs() *LinkAttrs

func (*Device) Type Uses

func (device *Device) Type() string

type DevlinkDevAttrs Uses

type DevlinkDevAttrs struct {
    Eswitch DevlinkDevEswitchAttr
}

DevlinkDevAttrs represents device attributes

type DevlinkDevEswitchAttr Uses

type DevlinkDevEswitchAttr struct {
    Mode       string
    InlineMode string
    EncapMode  string
}

DevlinkDevEswitchAttr represents device's eswitch attributes

type DevlinkDevice Uses

type DevlinkDevice struct {
    BusName    string
    DeviceName string
    Attrs      DevlinkDevAttrs
}

DevlinkDevice represents device and its attributes

func DevLinkGetDeviceByName Uses

func DevLinkGetDeviceByName(Bus string, Device string) (*DevlinkDevice, error)

DevlinkGetDeviceByName provides a pointer to devlink device and nil error, otherwise returns an error code.

func DevLinkGetDeviceList Uses

func DevLinkGetDeviceList() ([]*DevlinkDevice, error)

DevLinkGetDeviceList provides a pointer to devlink devices and nil error, otherwise returns an error code.

type Dir Uses

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 Uses

func (d Dir) String() string

type Dummy Uses

type Dummy struct {
    LinkAttrs
}

Dummy links are dummy ethernet devices

func (*Dummy) Attrs Uses

func (dummy *Dummy) Attrs() *LinkAttrs

func (*Dummy) Type Uses

func (dummy *Dummy) Type() string

type Encap Uses

type Encap interface {
    Type() int
    Decode([]byte) error
    Encode() ([]byte, error)
    String() string
    Equal(Encap) bool
}

type EncapType Uses

type EncapType uint8

EncapType is an enum representing the optional packet encapsulation.

const (
    XFRM_ENCAP_ESPINUDP_NONIKE EncapType = iota + 1
    XFRM_ENCAP_ESPINUDP
)

func (EncapType) String Uses

func (e EncapType) String() string

type Filter Uses

type Filter interface {
    Attrs() *FilterAttrs
    Type() string
}

func FilterList Uses

func FilterList(link Link, parent uint32) ([]Filter, error)

FilterList gets a list of filters in the system. Equivalent to: `tc filter show`. Generally returns nothing if link and parent are not specified.

type FilterAttrs Uses

type FilterAttrs struct {
    LinkIndex int
    Handle    uint32
    Parent    uint32
    Priority  uint16 // lower is higher priority
    Protocol  uint16 // unix.ETH_P_*
}

FilterAttrs 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 Uses

func (q FilterAttrs) String() string

type FilterFwAttrs Uses

type FilterFwAttrs struct {
    ClassId   uint32
    InDev     string
    Mask      uint32
    Index     uint32
    Buffer    uint32
    Mtu       uint32
    Mpu       uint16
    Rate      uint32
    AvRate    uint32
    PeakRate  uint32
    Action    TcPolAct
    Overhead  uint16
    LinkLayer int
}

type Fou Uses

type Fou struct {
    Family    int
    Port      int
    Protocol  int
    EncapType int
}

func FouList Uses

func FouList(fam int) ([]Fou, error)

type Fq Uses

type Fq struct {
    QdiscAttrs
    PacketLimit     uint32
    FlowPacketLimit uint32
    // In bytes
    Quantum        uint32
    InitialQuantum uint32
    // called RateEnable under the hood
    Pacing          uint32
    FlowDefaultRate uint32
    FlowMaxRate     uint32
    // called BucketsLog under the hood
    Buckets          uint32
    FlowRefillDelay  uint32
    LowRateThreshold uint32
}

Fq is a classless packet scheduler meant to be mostly used for locally generated traffic.

func NewFq Uses

func NewFq(attrs QdiscAttrs) *Fq

func (*Fq) Attrs Uses

func (qdisc *Fq) Attrs() *QdiscAttrs

func (*Fq) String Uses

func (fq *Fq) String() string

func (*Fq) Type Uses

func (qdisc *Fq) Type() string

type FqCodel Uses

type FqCodel struct {
    QdiscAttrs
    Target   uint32
    Limit    uint32
    Interval uint32
    ECN      uint32
    Flows    uint32
    Quantum  uint32
}

FQ_Codel (Fair Queuing Controlled Delay) is queuing discipline that combines Fair Queuing with the CoDel AQM scheme.

func NewFqCodel Uses

func NewFqCodel(attrs QdiscAttrs) *FqCodel

func (*FqCodel) Attrs Uses

func (qdisc *FqCodel) Attrs() *QdiscAttrs

func (*FqCodel) String Uses

func (fqcodel *FqCodel) String() string

func (*FqCodel) Type Uses

func (qdisc *FqCodel) Type() string

type Fw Uses

type Fw struct {
    FilterAttrs
    ClassId uint32
    // TODO remove nl type from interface
    Police nl.TcPolice
    InDev  string
    // TODO Action
    Mask   uint32
    AvRate uint32
    Rtab   [256]uint32
    Ptab   [256]uint32
}

Fw filter filters on firewall marks NOTE: this is in filter_linux because it refers to nl.TcPolice which

is defined in nl/tc_linux.go

func NewFw Uses

func NewFw(attrs FilterAttrs, fattrs FilterFwAttrs) (*Fw, error)

func (*Fw) Attrs Uses

func (filter *Fw) Attrs() *FilterAttrs

func (*Fw) Type Uses

func (filter *Fw) Type() string

type GTP Uses

type GTP struct {
    LinkAttrs
    FD0         int
    FD1         int
    Role        int
    PDPHashsize int
}

func (*GTP) Attrs Uses

func (gtp *GTP) Attrs() *LinkAttrs

func (*GTP) Type Uses

func (gtp *GTP) Type() string

type GenericAction Uses

type GenericAction struct {
    ActionAttrs
}

func (*GenericAction) Attrs Uses

func (action *GenericAction) Attrs() *ActionAttrs

func (*GenericAction) Type Uses

func (action *GenericAction) Type() string

type GenericClass Uses

type GenericClass struct {
    ClassAttrs
    ClassType string
}

GenericClass classes represent types that are not currently understood by this netlink library.

func (*GenericClass) Attrs Uses

func (class *GenericClass) Attrs() *ClassAttrs

Attrs return the class attributes

func (*GenericClass) Type Uses

func (class *GenericClass) Type() string

Type return the class type

type GenericFilter Uses

type GenericFilter struct {
    FilterAttrs
    FilterType string
}

GenericFilter filters represent types that are not currently understood by this netlink library.

func (*GenericFilter) Attrs Uses

func (filter *GenericFilter) Attrs() *FilterAttrs

func (*GenericFilter) Type Uses

func (filter *GenericFilter) Type() string
type GenericLink struct {
    LinkAttrs
    LinkType string
}

GenericLink links represent types that are not currently understood by this netlink library.

func (*GenericLink) Attrs Uses

func (generic *GenericLink) Attrs() *LinkAttrs

func (*GenericLink) Type Uses

func (generic *GenericLink) Type() string

type GenericQdisc Uses

type GenericQdisc struct {
    QdiscAttrs
    QdiscType string
}

GenericQdisc qdiscs represent types that are not currently understood by this netlink library.

func (*GenericQdisc) Attrs Uses

func (qdisc *GenericQdisc) Attrs() *QdiscAttrs

func (*GenericQdisc) Type Uses

func (qdisc *GenericQdisc) Type() string

type GenlFamily Uses

type GenlFamily struct {
    ID      uint16
    HdrSize uint32
    Name    string
    Version uint32
    MaxAttr uint32
    Ops     []GenlOp
    Groups  []GenlMulticastGroup
}

func GenlFamilyGet Uses

func GenlFamilyGet(name string) (*GenlFamily, error)

func GenlFamilyList Uses

func GenlFamilyList() ([]*GenlFamily, error)

type GenlMulticastGroup Uses

type GenlMulticastGroup struct {
    ID   uint32
    Name string
}

type GenlOp Uses

type GenlOp struct {
    ID    uint32
    Flags uint32
}

type GnetStatsBasic Uses

type GnetStatsBasic struct {
    Bytes   uint64 // number of seen bytes
    Packets uint32 // number of seen packets
}

GnetStatsBasic Ref: struct gnet_stats_basic { ... }

type GnetStatsQueue Uses

type GnetStatsQueue struct {
    Qlen       uint32 // queue length
    Backlog    uint32 // backlog size of queue
    Drops      uint32 // number of dropped packets
    Requeues   uint32 // number of requues
    Overlimits uint32 // number of enqueues over the limit
}

GnetStatsQueue Ref: struct gnet_stats_queue { ... }

type GnetStatsRateEst Uses

type GnetStatsRateEst struct {
    Bps uint32 // current byte rate
    Pps uint32 // current packet rate
}

GnetStatsRateEst Ref: struct gnet_stats_rate_est { ... }

type GnetStatsRateEst64 Uses

type GnetStatsRateEst64 struct {
    Bps uint64 // current byte rate
    Pps uint64 // current packet rate
}

GnetStatsRateEst64 Ref: struct gnet_stats_rate_est64 { ... }

type Gretap Uses

type Gretap struct {
    LinkAttrs
    IKey       uint32
    OKey       uint32
    EncapSport uint16
    EncapDport uint16
    Local      net.IP
    Remote     net.IP
    IFlags     uint16
    OFlags     uint16
    PMtuDisc   uint8
    Ttl        uint8
    Tos        uint8
    EncapType  uint16
    EncapFlags uint16
    Link       uint32
    FlowBased  bool
}

Gretap devices must specify LocalIP and RemoteIP on create

func (*Gretap) Attrs Uses

func (gretap *Gretap) Attrs() *LinkAttrs

func (*Gretap) Type Uses

func (gretap *Gretap) Type() string

type Gretun Uses

type Gretun struct {
    LinkAttrs
    Link       uint32
    IFlags     uint16
    OFlags     uint16
    IKey       uint32
    OKey       uint32
    Local      net.IP
    Remote     net.IP
    Ttl        uint8
    Tos        uint8
    PMtuDisc   uint8
    EncapType  uint16
    EncapFlags uint16
    EncapSport uint16
    EncapDport uint16
}

func (*Gretun) Attrs Uses

func (gretun *Gretun) Attrs() *LinkAttrs

func (*Gretun) Type Uses

func (gretun *Gretun) Type() string

type Handle Uses

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

Handle is an handle for the netlink requests on a specific network namespace. All the requests on the same netlink family share the same netlink socket, which gets released when the handle is deleted.

func NewHandle Uses

func NewHandle(nlFamilies ...int) (*Handle, error)

NewHandle returns a netlink handle on the current network namespace. Caller may specify the netlink families the handle should support. If no families are specified, all the families the netlink package supports will be automatically added.

func NewHandleAt Uses

func NewHandleAt(ns netns.NsHandle, nlFamilies ...int) (*Handle, error)

NewHandleAt returns a netlink handle on the network namespace specified by ns. If ns=netns.None(), current network namespace will be assumed

func NewHandleAtFrom Uses

func NewHandleAtFrom(newNs, curNs netns.NsHandle) (*Handle, error)

NewHandleAtFrom works as NewHandle but allows client to specify the new and the origin netns Handle.

func (*Handle) AddrAdd Uses

func (h *Handle) AddrAdd(link Link, addr *Addr) error

AddrAdd will add an IP address to a link device.

Equivalent to: `ip addr add $addr dev $link`

If `addr` is an IPv4 address and the broadcast address is not given, it will be automatically computed based on the IP mask if /30 or larger.

func (*Handle) AddrDel Uses

func (h *Handle) AddrDel(link Link, addr *Addr) error

AddrDel will delete an IP address from a link device. Equivalent to: `ip addr del $addr dev $link`

If `addr` is an IPv4 address and the broadcast address is not given, it will be automatically computed based on the IP mask if /30 or larger.

func (*Handle) AddrList Uses

func (h *Handle) AddrList(link Link, family int) ([]Addr, error)

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 (*Handle) AddrReplace Uses

func (h *Handle) AddrReplace(link Link, addr *Addr) error

AddrReplace will replace (or, if not present, add) an IP address on a link device.

Equivalent to: `ip addr replace $addr dev $link`

If `addr` is an IPv4 address and the broadcast address is not given, it will be automatically computed based on the IP mask if /30 or larger.

func (*Handle) BridgeSetMcastSnoop Uses

func (h *Handle) BridgeSetMcastSnoop(link Link, on bool) error

func (*Handle) BridgeSetVlanFiltering Uses

func (h *Handle) BridgeSetVlanFiltering(link Link, on bool) error

func (*Handle) BridgeVlanAdd Uses

func (h *Handle) BridgeVlanAdd(link Link, vid uint16, pvid, untagged, self, master bool) error

BridgeVlanAdd adds a new vlan filter entry Equivalent to: `bridge vlan add dev DEV vid VID [ pvid ] [ untagged ] [ self ] [ master ]`

func (*Handle) BridgeVlanDel Uses

func (h *Handle) BridgeVlanDel(link Link, vid uint16, pvid, untagged, self, master bool) error

BridgeVlanDel adds a new vlan filter entry Equivalent to: `bridge vlan del dev DEV vid VID [ pvid ] [ untagged ] [ self ] [ master ]`

func (*Handle) BridgeVlanList Uses

func (h *Handle) BridgeVlanList() (map[int32][]*nl.BridgeVlanInfo, error)

BridgeVlanList gets a map of device id to bridge vlan infos. Equivalent to: `bridge vlan show`

func (*Handle) ClassAdd Uses

func (h *Handle) ClassAdd(class Class) error

ClassAdd will add a class to the system. Equivalent to: `tc class add $class`

func (*Handle) ClassChange Uses

func (h *Handle) ClassChange(class Class) error

ClassChange will change a class in place Equivalent to: `tc class change $class` The parent and handle MUST NOT be changed.

func (*Handle) ClassDel Uses

func (h *Handle) ClassDel(class Class) error

ClassDel will delete a class from the system. Equivalent to: `tc class del $class`

func (*Handle) ClassList Uses

func (h *Handle) ClassList(link Link, parent uint32) ([]Class, error)

ClassList gets a list of classes in the system. Equivalent to: `tc class show`. Generally returns nothing if link and parent are not specified.

func (*Handle) ClassReplace Uses

func (h *Handle) ClassReplace(class Class) error

ClassReplace will replace a class to the system. quivalent to: `tc class replace $class` The handle MAY be changed. If a class already exist with this parent/handle pair, the class is changed. If a class does not already exist with this parent/handle, a new class is created.

func (*Handle) ConntrackDeleteFilter Uses

func (h *Handle) ConntrackDeleteFilter(table ConntrackTableType, family InetFamily, filter CustomConntrackFilter) (uint, error)

ConntrackDeleteFilter deletes entries on the specified table on the base of the filter using the netlink handle passed conntrack -D [table] parameters Delete conntrack or expectation

func (*Handle) ConntrackTableFlush Uses

func (h *Handle) ConntrackTableFlush(table ConntrackTableType) error

ConntrackTableFlush flushes all the flows of a specified table using the netlink handle passed conntrack -F [table] Flush table The flush operation applies to all the family types

func (*Handle) ConntrackTableList Uses

func (h *Handle) ConntrackTableList(table ConntrackTableType, family InetFamily) ([]*ConntrackFlow, error)

ConntrackTableList returns the flow list of a table of a specific family using the netlink handle passed conntrack -L [table] [options] List conntrack or expectation table

func (*Handle) Delete Uses

func (h *Handle) Delete()

Delete releases the resources allocated to this handle

func (*Handle) DevLinkGetDeviceByName Uses

func (h *Handle) DevLinkGetDeviceByName(Bus string, Device string) (*DevlinkDevice, error)

DevlinkGetDeviceByName provides a pointer to devlink device and nil error, otherwise returns an error code.

func (*Handle) DevLinkGetDeviceList Uses

func (h *Handle) DevLinkGetDeviceList() ([]*DevlinkDevice, error)

DevLinkGetDeviceList provides a pointer to devlink devices and nil error, otherwise returns an error code.

func (*Handle) DevLinkSetEswitchMode Uses

func (h *Handle) DevLinkSetEswitchMode(Dev *DevlinkDevice, NewMode string) error

DevLinkSetEswitchMode sets eswitch mode if able to set successfully or returns an error code. Equivalent to: `devlink dev eswitch set $dev mode switchdev` Equivalent to: `devlink dev eswitch set $dev mode legacy`

func (*Handle) FilterAdd Uses

func (h *Handle) FilterAdd(filter Filter) error

FilterAdd will add a filter to the system. Equivalent to: `tc filter add $filter`

func (*Handle) FilterDel Uses

func (h *Handle) FilterDel(filter Filter) error

FilterDel will delete a filter from the system. Equivalent to: `tc filter del $filter`

func (*Handle) FilterList Uses

func (h *Handle) FilterList(link Link, parent uint32) ([]Filter, error)

FilterList gets a list of filters in the system. Equivalent to: `tc filter show`. Generally returns nothing if link and parent are not specified.

func (*Handle) FilterReplace Uses

func (h *Handle) FilterReplace(filter Filter) error

FilterReplace will replace a filter. Equivalent to: `tc filter replace $filter`

func (*Handle) FouAdd Uses

func (h *Handle) FouAdd(f Fou) error

func (*Handle) FouDel Uses

func (h *Handle) FouDel(f Fou) error

func (*Handle) FouList Uses

func (h *Handle) FouList(fam int) ([]Fou, error)

func (*Handle) GTPPDPAdd Uses

func (h *Handle) GTPPDPAdd(link Link, pdp *PDP) error

func (*Handle) GTPPDPByITEI Uses

func (h *Handle) GTPPDPByITEI(link Link, itei int) (*PDP, error)

func (*Handle) GTPPDPByMSAddress Uses

func (h *Handle) GTPPDPByMSAddress(link Link, addr net.IP) (*PDP, error)

func (*Handle) GTPPDPByTID Uses

func (h *Handle) GTPPDPByTID(link Link, tid int) (*PDP, error)

func (*Handle) GTPPDPDel Uses

func (h *Handle) GTPPDPDel(link Link, pdp *PDP) error

func (*Handle) GTPPDPList Uses

func (h *Handle) GTPPDPList() ([]*PDP, error)

func (*Handle) GenlFamilyGet Uses

func (h *Handle) GenlFamilyGet(name string) (*GenlFamily, error)

func (*Handle) GenlFamilyList Uses

func (h *Handle) GenlFamilyList() ([]*GenlFamily, error)

func (*Handle) GetNetNsIdByFd Uses

func (h *Handle) GetNetNsIdByFd(fd int) (int, error)

GetNetNsIdByFd looks up the network namespace ID for a given fd. fd must be an open file descriptor to a namespace file. Returns -1 if the namespace does not have an ID set.

func (*Handle) GetNetNsIdByPid Uses

func (h *Handle) GetNetNsIdByPid(pid int) (int, error)

GetNetNsIdByPid looks up the network namespace ID for a given pid (really thread id). Returns -1 if the namespace does not have an ID set.

func (*Handle) GetSocketReceiveBufferSize Uses

func (h *Handle) GetSocketReceiveBufferSize() ([]int, error)

GetSocketReceiveBufferSize gets the receiver buffer size for each socket in the netlink handle. The retrieved value should be the double to the one set for SetSocketReceiveBufferSize.

func (*Handle) LinkAdd Uses

func (h *Handle) LinkAdd(link Link) error

LinkAdd adds a new link device. The type and features of the device are taken from the parameters in the link object. Equivalent to: `ip link add $link`

func (*Handle) LinkByAlias Uses

func (h *Handle) LinkByAlias(alias string) (Link, error)

LinkByAlias finds a link by its alias and returns a pointer to the object. If there are multiple links with the alias it returns the first one

func (*Handle) LinkByIndex Uses

func (h *Handle) LinkByIndex(index int) (Link, error)

LinkByIndex finds a link by index and returns a pointer to the object.

func (*Handle) LinkByName Uses

func (h *Handle) LinkByName(name string) (Link, error)

LinkByName finds a link by name and returns a pointer to the object.

func (*Handle) LinkDel Uses

func (h *Handle) LinkDel(link Link) error

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 (*Handle) LinkGetProtinfo Uses

func (h *Handle) LinkGetProtinfo(link Link) (Protinfo, error)
func (h *Handle) LinkList() ([]Link, error)

LinkList gets a list of link devices. Equivalent to: `ip link show`

func (*Handle) LinkModify Uses

func (h *Handle) LinkModify(link Link) error

func (*Handle) LinkSetARPOff Uses

func (h *Handle) LinkSetARPOff(link Link) error

func (*Handle) LinkSetARPOn Uses

func (h *Handle) LinkSetARPOn(link Link) error

func (*Handle) LinkSetAlias Uses

func (h *Handle) LinkSetAlias(link Link, name string) error

LinkSetAlias sets the alias of the link device. Equivalent to: `ip link set dev $link alias $name`

func (*Handle) LinkSetAllmulticastOff Uses

func (h *Handle) LinkSetAllmulticastOff(link Link) error

LinkSetAllmulticastOff disables the reception of all hardware multicast packets for the link device. Equivalent to: `ip link set $link allmulticast off`

func (*Handle) LinkSetAllmulticastOn Uses

func (h *Handle) LinkSetAllmulticastOn(link Link) error

LinkSetAllmulticastOn enables the reception of all hardware multicast packets for the link device. Equivalent to: `ip link set $link allmulticast on`

func (*Handle) LinkSetBondSlaveQueueId Uses

func (h *Handle) LinkSetBondSlaveQueueId(link Link, queueId uint16) error

LinkSetBondSlaveQueueId modify bond slave queue-id.

func (*Handle) LinkSetBrProxyArp Uses

func (h *Handle) LinkSetBrProxyArp(link Link, mode bool) error

func (*Handle) LinkSetBrProxyArpWiFi Uses

func (h *Handle) LinkSetBrProxyArpWiFi(link Link, mode bool) error

func (*Handle) LinkSetDown Uses

func (h *Handle) LinkSetDown(link Link) error

LinkSetDown disables link device. Equivalent to: `ip link set $link down`

func (*Handle) LinkSetFastLeave Uses

func (h *Handle) LinkSetFastLeave(link Link, mode bool) error

func (*Handle) LinkSetFlood Uses

func (h *Handle) LinkSetFlood(link Link, mode bool) error

func (*Handle) LinkSetGroup Uses

func (h *Handle) LinkSetGroup(link Link, group int) error

LinkSetGroup sets the link group id which can be used to perform mass actions with iproute2 as well use it as a reference in nft filters. Equivalent to: `ip link set $link group $id`

func (*Handle) LinkSetGuard Uses

func (h *Handle) LinkSetGuard(link Link, mode bool) error

func (*Handle) LinkSetHairpin Uses

func (h *Handle) LinkSetHairpin(link Link, mode bool) error

func (*Handle) LinkSetHardwareAddr Uses

func (h *Handle) 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 (*Handle) LinkSetLearning Uses

func (h *Handle) LinkSetLearning(link Link, mode bool) error

func (*Handle) LinkSetMTU Uses

func (h *Handle) LinkSetMTU(link Link, mtu int) error

LinkSetMTU sets the mtu of the link device. Equivalent to: `ip link set $link mtu $mtu`

func (*Handle) LinkSetMaster Uses

func (h *Handle) LinkSetMaster(link Link, master Link) error

LinkSetMaster sets the master of the link device. Equivalent to: `ip link set $link master $master`

func (*Handle) LinkSetMasterByIndex Uses

func (h *Handle) LinkSetMasterByIndex(link Link, masterIndex int) error

LinkSetMasterByIndex sets the master of the link device. Equivalent to: `ip link set $link master $master`

func (*Handle) LinkSetName Uses

func (h *Handle) LinkSetName(link Link, name string) error

LinkSetName sets the name of the link device. Equivalent to: `ip link set $link name $name`

func (*Handle) LinkSetNoMaster Uses

func (h *Handle) LinkSetNoMaster(link Link) error

LinkSetNoMaster removes the master of the link device. Equivalent to: `ip link set $link nomaster`

func (*Handle) LinkSetNsFd Uses

func (h *Handle) LinkSetNsFd(link Link, fd int) error

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 (*Handle) LinkSetNsPid Uses

func (h *Handle) LinkSetNsPid(link Link, nspid int) error

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 (*Handle) LinkSetRootBlock Uses

func (h *Handle) LinkSetRootBlock(link Link, mode bool) error

func (*Handle) LinkSetTxQLen Uses

func (h *Handle) LinkSetTxQLen(link Link, qlen int) error

LinkSetTxQLen sets the transaction queue length for the link. Equivalent to: `ip link set $link txqlen $qlen`

func (*Handle) LinkSetUp Uses

func (h *Handle) LinkSetUp(link Link) error

LinkSetUp enables the link device. Equivalent to: `ip link set $link up`

func (*Handle) LinkSetVfGUID Uses

func (h *Handle) LinkSetVfGUID(link Link, vf int, vfGuid net.HardwareAddr, guidType int) error

LinkSetVfGUID sets the node or port GUID of a vf for the link.

func (*Handle) LinkSetVfHardwareAddr Uses

func (h *Handle) LinkSetVfHardwareAddr(link Link, vf int, hwaddr net.HardwareAddr) error

LinkSetVfHardwareAddr sets the hardware address of a vf for the link. Equivalent to: `ip link set $link vf $vf mac $hwaddr`

func (*Handle) LinkSetVfRate Uses

func (h *Handle) LinkSetVfRate(link Link, vf, minRate, maxRate int) error

LinkSetVfRate sets the min and max tx rate of a vf for the link. Equivalent to: `ip link set $link vf $vf min_tx_rate $min_rate max_tx_rate $max_rate`

func (*Handle) LinkSetVfSpoofchk Uses

func (h *Handle) LinkSetVfSpoofchk(link Link, vf int, check bool) error

LinkSetVfSpoofchk enables/disables spoof check on a vf for the link. Equivalent to: `ip link set $link vf $vf spoofchk $check`

func (*Handle) LinkSetVfState Uses

func (h *Handle) LinkSetVfState(link Link, vf int, state uint32) error

LinkSetVfState enables/disables virtual link state on a vf. Equivalent to: `ip link set $link vf $vf state $state`

func (*Handle) LinkSetVfTrust Uses

func (h *Handle) LinkSetVfTrust(link Link, vf int, state bool) error

LinkSetVfTrust enables/disables trust state on a vf for the link. Equivalent to: `ip link set $link vf $vf trust $state`

func (*Handle) LinkSetVfTxRate Uses

func (h *Handle) LinkSetVfTxRate(link Link, vf, rate int) error

LinkSetVfTxRate sets the tx rate of a vf for the link. Equivalent to: `ip link set $link vf $vf rate $rate`

func (*Handle) LinkSetVfVlan Uses

func (h *Handle) LinkSetVfVlan(link Link, vf, vlan int) error

LinkSetVfVlan sets the vlan of a vf for the link. Equivalent to: `ip link set $link vf $vf vlan $vlan`

func (*Handle) LinkSetVfVlanQos Uses

func (h *Handle) LinkSetVfVlanQos(link Link, vf, vlan, qos int) error

LinkSetVfVlanQos sets the vlan and qos priority of a vf for the link. Equivalent to: `ip link set $link vf $vf vlan $vlan qos $qos`

func (*Handle) MacvlanMACAddrAdd Uses

func (h *Handle) MacvlanMACAddrAdd(link Link, addr net.HardwareAddr) error

func (*Handle) MacvlanMACAddrDel Uses

func (h *Handle) MacvlanMACAddrDel(link Link, addr net.HardwareAddr) error

func (*Handle) MacvlanMACAddrFlush Uses

func (h *Handle) MacvlanMACAddrFlush(link Link) error

func (*Handle) MacvlanMACAddrSet Uses

func (h *Handle) MacvlanMACAddrSet(link Link, addrs []net.HardwareAddr) error

func (*Handle) NeighAdd Uses

func (h *Handle) NeighAdd(neigh *Neigh) error

NeighAdd will add an IP to MAC mapping to the ARP table Equivalent to: `ip neigh add ....`

func (*Handle) NeighAppend Uses

func (h *Handle) NeighAppend(neigh *Neigh) error

NeighAppend will append an entry to FDB Equivalent to: `bridge fdb append...`

func (*Handle) NeighDel Uses

func (h *Handle) NeighDel(neigh *Neigh) error

NeighDel will delete an IP address from a link device. Equivalent to: `ip addr del $addr dev $link`

func (*Handle) NeighList Uses

func (h *Handle) NeighList(linkIndex, family int) ([]Neigh, error)

NeighList returns 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 (*Handle) NeighListExecute Uses

func (h *Handle) NeighListExecute(msg Ndmsg) ([]Neigh, error)

NeighListExecute returns a list of neighbour entries filtered by link, ip family, flag and state.

func (*Handle) NeighProxyList Uses

func (h *Handle) NeighProxyList(linkIndex, family int) ([]Neigh, error)

NeighProxyList returns a list of neighbor proxies in the system. Equivalent to: `ip neighbor show proxy`. The list can be filtered by link, ip family.

func (*Handle) NeighSet Uses

func (h *Handle) NeighSet(neigh *Neigh) error

NeighSet will add or replace an IP to MAC mapping to the ARP table Equivalent to: `ip neigh replace....`

func (*Handle) QdiscAdd Uses

func (h *Handle) QdiscAdd(qdisc Qdisc) error

QdiscAdd will add a qdisc to the system. Equivalent to: `tc qdisc add $qdisc`

func (*Handle) QdiscChange Uses

func (h *Handle) QdiscChange(qdisc Qdisc) error

QdiscChange will change a qdisc in place Equivalent to: `tc qdisc change $qdisc` The parent and handle MUST NOT be changed.

func (*Handle) QdiscDel Uses

func (h *Handle) QdiscDel(qdisc Qdisc) error

QdiscDel will delete a qdisc from the system. Equivalent to: `tc qdisc del $qdisc`

func (*Handle) QdiscList Uses

func (h *Handle) QdiscList(link Link) ([]Qdisc, error)

QdiscList gets a list of qdiscs in the system. Equivalent to: `tc qdisc show`. The list can be filtered by link.

func (*Handle) QdiscReplace Uses

func (h *Handle) QdiscReplace(qdisc Qdisc) error

QdiscReplace will replace a qdisc to the system. Equivalent to: `tc qdisc replace $qdisc` The handle MUST change.

func (*Handle) RdmaLinkByName Uses

func (h *Handle) RdmaLinkByName(name string) (*RdmaLink, error)

RdmaLinkByName finds a link by name and returns a pointer to the object if found and nil error, otherwise returns error code.

func (h *Handle) RdmaLinkList() ([]*RdmaLink, error)

RdmaLinkList gets a list of RDMA link devices. Equivalent to: `rdma dev show`

func (*Handle) RdmaLinkSetName Uses

func (h *Handle) RdmaLinkSetName(link *RdmaLink, name string) error

RdmaLinkSetName sets the name of the rdma link device. Return nil on success or error otherwise. Equivalent to: `rdma dev set $old_devname name $name`

func (*Handle) RdmaLinkSetNsFd Uses

func (h *Handle) RdmaLinkSetNsFd(link *RdmaLink, fd uint32) error

RdmaLinkSetNsFd puts the RDMA device into a new network namespace. The fd must be an open file descriptor to a network namespace. Similar to: `rdma dev set $dev netns $ns`

func (*Handle) RdmaSystemGetNetnsMode Uses

func (h *Handle) RdmaSystemGetNetnsMode() (string, error)

RdmaSystemGetNetnsMode gets the net namespace mode for RDMA subsystem Returns mode string and error status as nil on success or returns error otherwise. Equivalent to: `rdma system show netns'

func (*Handle) RdmaSystemSetNetnsMode Uses

func (h *Handle) RdmaSystemSetNetnsMode(NewMode string) error

RdmaSystemSetNetnsMode sets the net namespace mode for RDMA subsystem Returns nil on success or appropriate error code. Equivalent to: `rdma system set netns { shared | exclusive }'

func (*Handle) RouteAdd Uses

func (h *Handle) RouteAdd(route *Route) error

RouteAdd will add a route to the system. Equivalent to: `ip route add $route`

func (*Handle) RouteDel Uses

func (h *Handle) RouteDel(route *Route) error

RouteDel will delete a route from the system. Equivalent to: `ip route del $route`

func (*Handle) RouteGet Uses

func (h *Handle) RouteGet(destination net.IP) ([]Route, error)

RouteGet gets a route to a specific destination from the host system. Equivalent to: 'ip route get'.

func (*Handle) RouteGetWithOptions Uses

func (h *Handle) RouteGetWithOptions(destination net.IP, options *RouteGetOptions) ([]Route, error)

RouteGetWithOptions gets a route to a specific destination from the host system. Equivalent to: 'ip route get <> vrf <VrfName>'.

func (*Handle) RouteList Uses

func (h *Handle) RouteList(link Link, family int) ([]Route, error)

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 (*Handle) RouteListFiltered Uses

func (h *Handle) RouteListFiltered(family int, filter *Route, filterMask uint64) ([]Route, error)

RouteListFiltered gets a list of routes in the system filtered with specified rules. All rules must be defined in RouteFilter struct

func (*Handle) RouteReplace Uses

func (h *Handle) RouteReplace(route *Route) error

RouteReplace will add a route to the system. Equivalent to: `ip route replace $route`

func (*Handle) RuleAdd Uses

func (h *Handle) RuleAdd(rule *Rule) error

RuleAdd adds a rule to the system. Equivalent to: ip rule add

func (*Handle) RuleDel Uses

func (h *Handle) RuleDel(rule *Rule) error

RuleDel deletes a rule from the system. Equivalent to: ip rule del

func (*Handle) RuleList Uses

func (h *Handle) RuleList(family int) ([]Rule, error)

RuleList lists rules in the system. Equivalent to: ip rule list

func (*Handle) RuleListFiltered Uses

func (h *Handle) RuleListFiltered(family int, filter *Rule, filterMask uint64) ([]Rule, error)

RuleListFiltered lists rules in the system. Equivalent to: ip rule list

func (*Handle) SetNetNsIdByFd Uses

func (h *Handle) SetNetNsIdByFd(fd, nsid int) error

SetNetNSIdByFd sets the ID of the network namespace for a given fd. fd must be an open file descriptor to a namespace file. The ID can only be set for namespaces without an ID already set.

func (*Handle) SetNetNsIdByPid Uses

func (h *Handle) SetNetNsIdByPid(pid, nsid int) error

SetNetNSIdByPid sets the ID of the network namespace for a given pid (really thread id). The ID can only be set for namespaces without an ID already set.

func (*Handle) SetPromiscOff Uses

func (h *Handle) SetPromiscOff(link Link) error

func (*Handle) SetPromiscOn Uses

func (h *Handle) SetPromiscOn(link Link) error

func (*Handle) SetSocketReceiveBufferSize Uses

func (h *Handle) SetSocketReceiveBufferSize(size int, force bool) error

SetSocketReceiveBufferSize sets the receive buffer size for each socket in the netlink handle. The maximum value is capped by /proc/sys/net/core/rmem_max.

func (*Handle) SetSocketTimeout Uses

func (h *Handle) SetSocketTimeout(to time.Duration) error

SetSocketTimeout sets the send and receive timeout for each socket in the netlink handle. Although the socket timeout has granularity of one microsecond, the effective granularity is floored by the kernel timer tick, which default value is four milliseconds.

func (*Handle) SupportsNetlinkFamily Uses

func (h *Handle) SupportsNetlinkFamily(nlFamily int) bool

SupportsNetlinkFamily reports whether the passed netlink family is supported by this Handle

func (*Handle) XfrmPolicyAdd Uses

func (h *Handle) XfrmPolicyAdd(policy *XfrmPolicy) error

XfrmPolicyAdd will add an xfrm policy to the system. Equivalent to: `ip xfrm policy add $policy`

func (*Handle) XfrmPolicyDel Uses

func (h *Handle) 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 (*Handle) XfrmPolicyFlush Uses

func (h *Handle) XfrmPolicyFlush() error

XfrmPolicyFlush will flush the policies on the system. Equivalent to: `ip xfrm policy flush`

func (*Handle) XfrmPolicyGet Uses

func (h *Handle) XfrmPolicyGet(policy *XfrmPolicy) (*XfrmPolicy, error)

XfrmPolicyGet gets a the policy described by the index or selector, if found. Equivalent to: `ip xfrm policy get { SELECTOR | index INDEX } dir DIR [ctx CTX ] [ mark MARK [ mask MASK ] ] [ ptype PTYPE ]`.

func (*Handle) XfrmPolicyList Uses

func (h *Handle) 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.

func (*Handle) XfrmPolicyUpdate Uses

func (h *Handle) XfrmPolicyUpdate(policy *XfrmPolicy) error

XfrmPolicyUpdate will update an xfrm policy to the system. Equivalent to: `ip xfrm policy update $policy`

func (*Handle) XfrmStateAdd Uses

func (h *Handle) XfrmStateAdd(state *XfrmState) error

XfrmStateAdd will add an xfrm state to the system. Equivalent to: `ip xfrm state add $state`

func (*Handle) XfrmStateDel Uses

func (h *Handle) XfrmStateDel(state *XfrmState) error

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 (*Handle) XfrmStateFlush Uses

func (h *Handle) XfrmStateFlush(proto Proto) error

XfrmStateFlush will flush the xfrm state on the system. proto = 0 means any transformation protocols Equivalent to: `ip xfrm state flush [ proto XFRM-PROTO ]`

func (*Handle) XfrmStateGet Uses

func (h *Handle) XfrmStateGet(state *XfrmState) (*XfrmState, error)

XfrmStateGet gets the xfrm state described by the ID, if found. Equivalent to: `ip xfrm state get ID [ mark MARK [ mask MASK ] ]`. Only the fields which constitue the SA ID must be filled in: ID := [ src ADDR ] [ dst ADDR ] [ proto XFRM-PROTO ] [ spi SPI ] mark is optional

func (*Handle) XfrmStateList Uses

func (h *Handle) XfrmStateList(family int) ([]XfrmState, error)

XfrmStateList gets a list of xfrm states in the system. Equivalent to: `ip xfrm state show`. The list can be filtered by ip family.

func (*Handle) XfrmStateUpdate Uses

func (h *Handle) XfrmStateUpdate(state *XfrmState) error

XfrmStateUpdate will update an xfrm state to the system. Equivalent to: `ip xfrm state update $state`

type Hfsc Uses

type Hfsc struct {
    QdiscAttrs
    Defcls uint16
}

func NewHfsc Uses

func NewHfsc(attrs QdiscAttrs) *Hfsc

func (*Hfsc) Attrs Uses

func (hfsc *Hfsc) Attrs() *QdiscAttrs

func (*Hfsc) String Uses

func (hfsc *Hfsc) String() string

func (*Hfsc) Type Uses

func (hfsc *Hfsc) Type() string

type HfscClass Uses

type HfscClass struct {
    ClassAttrs
    Rsc ServiceCurve
    Fsc ServiceCurve
    Usc ServiceCurve
}

HfscClass is a representation of the HFSC class

func NewHfscClass Uses

func NewHfscClass(attrs ClassAttrs) *HfscClass

NewHfscClass returns a new HFSC struct with the set parameters

func (*HfscClass) Attrs Uses

func (hfsc *HfscClass) Attrs() *ClassAttrs

Attrs return the Hfsc parameters

func (*HfscClass) SetFsc Uses

func (hfsc *HfscClass) SetFsc(m1 uint32, d uint32, m2 uint32)

SetFsc sets the Fsc curve. The bandwidth (m1 and m2) is specified in bits and the delay in seconds.

func (*HfscClass) SetLS Uses

func (hfsc *HfscClass) SetLS(m1 uint32, d uint32, m2 uint32)

SetLS implements the LS from the `tc` CLI. This function behaves the same as if one would set the USC through the `tc` command-line tool. This means bandwidth (m1 and m2) is specified in bits and the delay in ms.

func (*HfscClass) SetRsc Uses

func (hfsc *HfscClass) SetRsc(m1 uint32, d uint32, m2 uint32)

SetRsc sets the Rsc curve. The bandwidth (m1 and m2) is specified in bits and the delay in seconds.

func (*HfscClass) SetSC Uses

func (hfsc *HfscClass) SetSC(m1 uint32, d uint32, m2 uint32)

SetSC implements the SC from the `tc` CLI. This function behaves the same as if one would set the USC through the `tc` command-line tool. This means bandwidth (m1 and m2) is specified in bits and the delay in ms.

func (*HfscClass) SetUL Uses

func (hfsc *HfscClass) SetUL(m1 uint32, d uint32, m2 uint32)

SetUL implements the UL from the `tc` CLI. This function behaves the same as if one would set the USC through the `tc` command-line tool. This means bandwidth (m1 and m2) is specified in bits and the delay in ms.

func (*HfscClass) SetUsc Uses

func (hfsc *HfscClass) SetUsc(m1 uint32, d uint32, m2 uint32)

SetUsc sets the USC curve. The bandwidth (m1 and m2) is specified in bits and the delay in seconds.

func (*HfscClass) String Uses

func (hfsc *HfscClass) String() string

String() returns a string that contains the information and attributes of the HFSC class

func (*HfscClass) Type Uses

func (hfsc *HfscClass) Type() string

Type return the type of the class

type Htb Uses

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 Uses

func NewHtb(attrs QdiscAttrs) *Htb

func (*Htb) Attrs Uses

func (qdisc *Htb) Attrs() *QdiscAttrs

func (*Htb) Type Uses

func (qdisc *Htb) Type() string

type HtbClass Uses

type HtbClass struct {
    ClassAttrs
    Rate    uint64
    Ceil    uint64
    Buffer  uint32
    Cbuffer uint32
    Quantum uint32
    Level   uint32
    Prio    uint32
}

HtbClass represents an Htb class

func NewHtbClass Uses

func NewHtbClass(attrs ClassAttrs, cattrs HtbClassAttrs) *HtbClass

NewHtbClass NOTE: function is in here because it uses other linux functions

func (*HtbClass) Attrs Uses

func (q *HtbClass) Attrs() *ClassAttrs

Attrs returns the class attributes

func (HtbClass) String Uses

func (q HtbClass) String() string

func (*HtbClass) Type Uses

func (q *HtbClass) Type() string

Type return the class type

type HtbClassAttrs Uses

type HtbClassAttrs struct {
    // TODO handle all attributes
    Rate    uint64
    Ceil    uint64
    Buffer  uint32
    Cbuffer uint32
    Quantum uint32
    Level   uint32
    Prio    uint32
}

HtbClassAttrs stores the attributes of HTB class

func (HtbClassAttrs) String Uses

func (q HtbClassAttrs) String() string

type IPVlan Uses

type IPVlan struct {
    LinkAttrs
    Mode IPVlanMode
    Flag IPVlanFlag
}

func (*IPVlan) Attrs Uses

func (ipvlan *IPVlan) Attrs() *LinkAttrs

func (*IPVlan) Type Uses

func (ipvlan *IPVlan) Type() string

type IPVlanFlag Uses

type IPVlanFlag uint16
const (
    IPVLAN_FLAG_BRIDGE IPVlanFlag = iota
    IPVLAN_FLAG_PRIVATE
    IPVLAN_FLAG_VEPA
)

type IPVlanMode Uses

type IPVlanMode uint16
const (
    IPVLAN_MODE_L2 IPVlanMode = iota
    IPVLAN_MODE_L3
    IPVLAN_MODE_L3S
    IPVLAN_MODE_MAX
)

type IPoIB Uses

type IPoIB struct {
    LinkAttrs
    Pkey   uint16
    Mode   IPoIBMode
    Umcast uint16
}

func (*IPoIB) Attrs Uses

func (ipoib *IPoIB) Attrs() *LinkAttrs

func (*IPoIB) Type Uses

func (ipoib *IPoIB) Type() string

type IPoIBMode Uses

type IPoIBMode uint16

func (*IPoIBMode) String Uses

func (m *IPoIBMode) String() string

type Ifb Uses

type Ifb struct {
    LinkAttrs
}

Ifb links are advanced dummy devices for packet filtering

func (*Ifb) Attrs Uses

func (ifb *Ifb) Attrs() *LinkAttrs

func (*Ifb) Type Uses

func (ifb *Ifb) Type() string

type Ifreq Uses

type Ifreq struct {
    Name [unix.IFNAMSIZ]byte
    Data uintptr
}

Ifreq is a struct for ioctl ethernet manipulation syscalls.

type IfreqSlave Uses

type IfreqSlave struct {
    Name  [unix.IFNAMSIZ]byte
    Slave [unix.IFNAMSIZ]byte
}

IfreqSlave is a struct for ioctl bond manipulation syscalls. It is used to assign slave to bond interface with Name.

type InetFamily Uses

type InetFamily uint8

InetFamily Family type

type Ingress Uses

type Ingress struct {
    QdiscAttrs
}

Ingress is a qdisc for adding ingress filters

func (*Ingress) Attrs Uses

func (qdisc *Ingress) Attrs() *QdiscAttrs

func (*Ingress) Type Uses

func (qdisc *Ingress) Type() string

type Ip6tnl Uses

type Ip6tnl struct {
    LinkAttrs
    Link       uint32
    Local      net.IP
    Remote     net.IP
    Ttl        uint8
    Tos        uint8
    EncapLimit uint8
    Flags      uint32
    Proto      uint8
    FlowInfo   uint32
}

func (*Ip6tnl) Attrs Uses

func (ip6tnl *Ip6tnl) Attrs() *LinkAttrs

func (*Ip6tnl) Type Uses

func (ip6tnl *Ip6tnl) Type() string

type Iptun Uses

type Iptun struct {
    LinkAttrs
    Ttl        uint8
    Tos        uint8
    PMtuDisc   uint8
    Link       uint32
    Local      net.IP
    Remote     net.IP
    EncapSport uint16
    EncapDport uint16
    EncapType  uint16
    EncapFlags uint16
    FlowBased  bool
}

func (*Iptun) Attrs Uses

func (iptun *Iptun) Attrs() *LinkAttrs

func (*Iptun) Type Uses

func (iptun *Iptun) Type() string
type Link interface {
    Attrs() *LinkAttrs
    Type() string
}

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 LinkByAlias Uses

func LinkByAlias(alias string) (Link, error)

LinkByAlias finds a link by its alias and returns a pointer to the object. If there are multiple links with the alias it returns the first one

func LinkByIndex Uses

func LinkByIndex(index int) (Link, error)

LinkByIndex finds a link by index and returns a pointer to the object.

func LinkByName Uses

func LinkByName(name string) (Link, error)

LinkByName finds a link by name and returns a pointer to the object.

func LinkDeserialize Uses

func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error)

linkDeserialize deserializes a raw message received from netlink into a link object.

func LinkList() ([]Link, error)

LinkList gets a list of link devices. Equivalent to: `ip link show`

type LinkAttrs Uses

type LinkAttrs struct {
    Index        int
    MTU          int
    TxQLen       int // Transmit Queue Length
    Name         string
    HardwareAddr net.HardwareAddr
    Flags        net.Flags
    RawFlags     uint32
    ParentIndex  int         // index of the parent link device
    MasterIndex  int         // must be the index of a bridge
    Namespace    interface{} // nil | NsPid | NsFd
    Alias        string
    Statistics   *LinkStatistics
    Promisc      int
    Xdp          *LinkXdp
    EncapType    string
    Protinfo     *Protinfo
    OperState    LinkOperState
    NetNsID      int
    NumTxQueues  int
    NumRxQueues  int
    GSOMaxSize   uint32
    GSOMaxSegs   uint32
    Vfs          []VfInfo // virtual functions available on link
    Group        uint32
    Slave        LinkSlave
}

LinkAttrs represents data shared by most link types

func NewLinkAttrs Uses

func NewLinkAttrs() LinkAttrs

NewLinkAttrs returns LinkAttrs structure filled with default values

type LinkNotFoundError Uses

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

LinkNotFoundError wraps the various not found errors when getting/reading links. This is intended for better error handling by dependent code so that "not found error" can be distinguished from other errors

type LinkOperState Uses

type LinkOperState uint8

LinkOperState represents the values of the IFLA_OPERSTATE link attribute, which contains the RFC2863 state of the interface.

func (LinkOperState) String Uses

func (s LinkOperState) String() string

type LinkSlave Uses

type LinkSlave interface {
    SlaveType() string
}

LinkSlave represents a slave device.

type LinkStatistics Uses

type LinkStatistics LinkStatistics64

type LinkStatistics32 Uses

type LinkStatistics32 struct {
    RxPackets         uint32
    TxPackets         uint32
    RxBytes           uint32
    TxBytes           uint32
    RxErrors          uint32
    TxErrors          uint32
    RxDropped         uint32
    TxDropped         uint32
    Multicast         uint32
    Collisions        uint32
    RxLengthErrors    uint32
    RxOverErrors      uint32
    RxCrcErrors       uint32
    RxFrameErrors     uint32
    RxFifoErrors      uint32
    RxMissedErrors    uint32
    TxAbortedErrors   uint32
    TxCarrierErrors   uint32
    TxFifoErrors      uint32
    TxHeartbeatErrors uint32
    TxWindowErrors    uint32
    RxCompressed      uint32
    TxCompressed      uint32
}

Ref: struct rtnl_link_stats {...}

type LinkStatistics64 Uses

type LinkStatistics64 struct {
    RxPackets         uint64
    TxPackets         uint64
    RxBytes           uint64
    TxBytes           uint64
    RxErrors          uint64
    TxErrors          uint64
    RxDropped         uint64
    TxDropped         uint64
    Multicast         uint64
    Collisions        uint64
    RxLengthErrors    uint64
    RxOverErrors      uint64
    RxCrcErrors       uint64
    RxFrameErrors     uint64
    RxFifoErrors      uint64
    RxMissedErrors    uint64
    TxAbortedErrors   uint64
    TxCarrierErrors   uint64
    TxFifoErrors      uint64
    TxHeartbeatErrors uint64
    TxWindowErrors    uint64
    RxCompressed      uint64
    TxCompressed      uint64
}

Ref: struct rtnl_link_stats64 {...}

type LinkSubscribeOptions Uses

type LinkSubscribeOptions struct {
    Namespace     *netns.NsHandle
    ErrorCallback func(error)
    ListExisting  bool
}

LinkSubscribeOptions contains a set of options to use with LinkSubscribeWithOptions.

type LinkUpdate Uses

type LinkUpdate struct {
    nl.IfInfomsg
    Header unix.NlMsghdr
    Link
}

LinkUpdate is used to pass information back from LinkSubscribe()

type LinkXdp Uses

type LinkXdp struct {
    Fd         int
    Attached   bool
    AttachMode uint32
    Flags      uint32
    ProgId     uint32
}

type MPLSDestination Uses

type MPLSDestination struct {
    Labels []int
}

func (*MPLSDestination) Decode Uses

func (d *MPLSDestination) Decode(buf []byte) error

func (*MPLSDestination) Encode Uses

func (d *MPLSDestination) Encode() ([]byte, error)

func (*MPLSDestination) Equal Uses

func (d *MPLSDestination) Equal(x Destination) bool

func (*MPLSDestination) Family Uses

func (d *MPLSDestination) Family() int

func (*MPLSDestination) String Uses

func (d *MPLSDestination) String() string

type MPLSEncap Uses

type MPLSEncap struct {
    Labels []int
}

func (*MPLSEncap) Decode Uses

func (e *MPLSEncap) Decode(buf []byte) error

func (*MPLSEncap) Encode Uses

func (e *MPLSEncap) Encode() ([]byte, error)

func (*MPLSEncap) Equal Uses

func (e *MPLSEncap) Equal(x Encap) bool

func (*MPLSEncap) String Uses

func (e *MPLSEncap) String() string

func (*MPLSEncap) Type Uses

func (e *MPLSEncap) Type() int

type Macvlan Uses

type Macvlan struct {
    LinkAttrs
    Mode MacvlanMode

    // MACAddrs is only populated for Macvlan SOURCE links
    MACAddrs []net.HardwareAddr
}

Macvlan links have ParentIndex set in their Attrs()

func (*Macvlan) Attrs Uses

func (macvlan *Macvlan) Attrs() *LinkAttrs

func (*Macvlan) Type Uses

func (macvlan *Macvlan) Type() string

type MacvlanMode Uses

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 Uses

type Macvtap struct {
    Macvlan
}

Macvtap - macvtap is a virtual interfaces based on macvlan

func (Macvtap) Type Uses

func (macvtap Macvtap) Type() string

type MatchAll Uses

type MatchAll struct {
    FilterAttrs
    ClassId uint32
    Actions []Action
}

MatchAll filters match all packets

func (*MatchAll) Attrs Uses

func (filter *MatchAll) Attrs() *FilterAttrs

func (*MatchAll) Type Uses

func (filter *MatchAll) Type() string

type MirredAct Uses

type MirredAct uint8
const (
    TCA_EGRESS_REDIR   MirredAct = 1 /* packet redirect to EGRESS*/
    TCA_EGRESS_MIRROR  MirredAct = 2 /* mirror packet to EGRESS */
    TCA_INGRESS_REDIR  MirredAct = 3 /* packet redirect to INGRESS*/
    TCA_INGRESS_MIRROR MirredAct = 4 /* mirror packet to INGRESS */
)

func (MirredAct) String Uses

func (a MirredAct) String() string

type MirredAction Uses

type MirredAction struct {
    ActionAttrs
    MirredAction MirredAct
    Ifindex      int
}

func NewMirredAction Uses

func NewMirredAction(redirIndex int) *MirredAction

func (*MirredAction) Attrs Uses

func (action *MirredAction) Attrs() *ActionAttrs

func (*MirredAction) Type Uses

func (action *MirredAction) Type() string

type Mode Uses

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 Uses

func (m Mode) String() string

type Ndmsg Uses

type Ndmsg struct {
    Family uint8
    Index  uint32
    State  uint16
    Flags  uint8
    Type   uint8
}

Ndmsg is for adding, removing or receiving information about a neighbor table entry

func (*Ndmsg) Len Uses

func (msg *Ndmsg) Len() int

func (*Ndmsg) Serialize Uses

func (msg *Ndmsg) Serialize() []byte

type Neigh Uses

type Neigh struct {
    LinkIndex    int
    Family       int
    State        int
    Type         int
    Flags        int
    IP           net.IP
    HardwareAddr net.HardwareAddr
    LLIPAddr     net.IP //Used in the case of NHRP
    Vlan         int
    VNI          int
    MasterIndex  int
}

Neigh represents a link layer neighbor from netlink.

func NeighDeserialize Uses

func NeighDeserialize(m []byte) (*Neigh, error)

func NeighList Uses

func NeighList(linkIndex, family int) ([]Neigh, error)

NeighList returns 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 NeighListExecute Uses

func NeighListExecute(msg Ndmsg) ([]Neigh, error)

NeighListExecute returns a list of neighbour entries filtered by link, ip family, flag and state.

func NeighProxyList Uses

func NeighProxyList(linkIndex, family int) ([]Neigh, error)

NeighProxyList returns a list of neighbor proxies in the system. Equivalent to: `ip neighbor show proxy`. The list can be filtered by link and ip family.

func (*Neigh) String Uses

func (neigh *Neigh) String() string

String returns $ip/$hwaddr $label

type NeighSubscribeOptions Uses

type NeighSubscribeOptions struct {
    Namespace     *netns.NsHandle
    ErrorCallback func(error)
    ListExisting  bool
}

NeighSubscribeOptions contains a set of options to use with NeighSubscribeWithOptions.

type NeighUpdate Uses

type NeighUpdate struct {
    Type uint16
    Neigh
}

NeighUpdate is sent when a neighbor changes - type is RTM_NEWNEIGH or RTM_DELNEIGH.

type Netem Uses

type Netem struct {
    QdiscAttrs
    Latency       uint32
    DelayCorr     uint32
    Limit         uint32
    Loss          uint32
    LossCorr      uint32
    Gap           uint32
    Duplicate     uint32
    DuplicateCorr uint32
    Jitter        uint32
    ReorderProb   uint32
    ReorderCorr   uint32
    CorruptProb   uint32
    CorruptCorr   uint32
}

func NewNetem Uses

func NewNetem(attrs QdiscAttrs, nattrs NetemQdiscAttrs) *Netem

NOTE function is here because it uses other linux functions

func (*Netem) Attrs Uses

func (qdisc *Netem) Attrs() *QdiscAttrs

func (*Netem) String Uses

func (netem *Netem) String() string

func (*Netem) Type Uses

func (qdisc *Netem) Type() string

type NetemQdiscAttrs Uses

type NetemQdiscAttrs struct {
    Latency       uint32  // in us
    DelayCorr     float32 // in %
    Limit         uint32
    Loss          float32 // in %
    LossCorr      float32 // in %
    Gap           uint32
    Duplicate     float32 // in %
    DuplicateCorr float32 // in %
    Jitter        uint32  // in us
    ReorderProb   float32 // in %
    ReorderCorr   float32 // in %
    CorruptProb   float32 // in %
    CorruptCorr   float32 // in %
}

func (NetemQdiscAttrs) String Uses

func (q NetemQdiscAttrs) String() string

type NextHopFlag Uses

type NextHopFlag int
const (
    FLAG_ONLINK    NextHopFlag = unix.RTNH_F_ONLINK
    FLAG_PERVASIVE NextHopFlag = unix.RTNH_F_PERVASIVE
)

type NexthopInfo Uses

type NexthopInfo struct {
    LinkIndex int
    Hops      int
    Gw        net.IP
    Flags     int
    NewDst    Destination
    Encap     Encap
}

func (NexthopInfo) Equal Uses

func (n NexthopInfo) Equal(x NexthopInfo) bool

func (*NexthopInfo) ListFlags Uses

func (n *NexthopInfo) ListFlags() []string

func (*NexthopInfo) String Uses

func (n *NexthopInfo) String() string

type NsFd Uses

type NsFd int

type NsPid Uses

type NsPid int

type PDP Uses

type PDP struct {
    Version     uint32
    TID         uint64
    PeerAddress net.IP
    MSAddress   net.IP
    Flow        uint16
    NetNSFD     uint32
    ITEI        uint32
    OTEI        uint32
}

func GTPPDPByITEI Uses

func GTPPDPByITEI(link Link, itei int) (*PDP, error)

func GTPPDPByMSAddress Uses

func GTPPDPByMSAddress(link Link, addr net.IP) (*PDP, error)

func GTPPDPByTID Uses

func GTPPDPByTID(link Link, tid int) (*PDP, error)

func GTPPDPList Uses

func GTPPDPList() ([]*PDP, error)

func (*PDP) String Uses

func (pdp *PDP) String() string

type PfifoFast Uses

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 Uses

func (qdisc *PfifoFast) Attrs() *QdiscAttrs

func (*PfifoFast) Type Uses

func (qdisc *PfifoFast) Type() string

type PolicyAction Uses

type PolicyAction uint8

PolicyAction is an enum representing an ipsec policy action.

const (
    XFRM_POLICY_ALLOW PolicyAction = 0
    XFRM_POLICY_BLOCK PolicyAction = 1
)

func (PolicyAction) String Uses

func (a PolicyAction) String() string

type Prio Uses

type Prio struct {
    QdiscAttrs
    Bands       uint8
    PriorityMap [PRIORITY_MAP_LEN]uint8
}

Prio is a basic qdisc that works just like PfifoFast

func NewPrio Uses

func NewPrio(attrs QdiscAttrs) *Prio

func (*Prio) Attrs Uses

func (qdisc *Prio) Attrs() *QdiscAttrs

func (*Prio) Type Uses

func (qdisc *Prio) Type() string

type Protinfo Uses

type Protinfo struct {
    Hairpin      bool
    Guard        bool
    FastLeave    bool
    RootBlock    bool
    Learning     bool
    Flood        bool
    ProxyArp     bool
    ProxyArpWiFi bool
}

Protinfo represents bridge flags from netlink.

func LinkGetProtinfo Uses

func LinkGetProtinfo(link Link) (Protinfo, error)

func (*Protinfo) String Uses

func (prot *Protinfo) String() string

String returns a list of enabled flags

type Proto Uses

type Proto uint8

Proto is an enum representing an ipsec protocol.

const (
    XFRM_PROTO_ROUTE2    Proto = unix.IPPROTO_ROUTING
    XFRM_PROTO_ESP       Proto = unix.IPPROTO_ESP
    XFRM_PROTO_AH        Proto = unix.IPPROTO_AH
    XFRM_PROTO_HAO       Proto = unix.IPPROTO_DSTOPTS
    XFRM_PROTO_COMP      Proto = 0x6c // NOTE not defined on darwin
    XFRM_PROTO_IPSEC_ANY Proto = unix.IPPROTO_RAW
)

func (Proto) String Uses

func (p Proto) String() string

type Qdisc Uses

type Qdisc interface {
    Attrs() *QdiscAttrs
    Type() string
}

func QdiscList Uses

func QdiscList(link Link) ([]Qdisc, error)

QdiscList gets a list of qdiscs in the system. Equivalent to: `tc qdisc show`. The list can be filtered by link.

type QdiscAttrs Uses

type QdiscAttrs struct {
    LinkIndex int
    Handle    uint32
    Parent    uint32
    Refcnt    uint32 // read only
}

QdiscAttrs 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 Uses

func (q QdiscAttrs) String() string
type RdmaLink struct {
    Attrs RdmaLinkAttrs
}

Link represents a rdma device from netlink.

func RdmaLinkByName Uses

func RdmaLinkByName(name string) (*RdmaLink, error)

RdmaLinkByName finds a link by name and returns a pointer to the object if found and nil error, otherwise returns error code.

func RdmaLinkList() ([]*RdmaLink, error)

RdmaLinkList gets a list of RDMA link devices. Equivalent to: `rdma dev show`

type RdmaLinkAttrs Uses

type RdmaLinkAttrs struct {
    Index           uint32
    Name            string
    FirmwareVersion string
    NodeGuid        string
    SysImageGuid    string
}

LinkAttrs represents data shared by most link types

type Route Uses

type Route struct {
    LinkIndex  int
    ILinkIndex int
    Scope      Scope
    Dst        *net.IPNet
    Src        net.IP
    Gw         net.IP
    MultiPath  []*NexthopInfo
    Protocol   int
    Priority   int
    Table      int
    Type       int
    Tos        int
    Flags      int
    MPLSDst    *int
    NewDst     Destination
    Encap      Encap
    MTU        int
    AdvMSS     int
    Hoplimit   int
}

Route represents a netlink route.

func RouteGet Uses

func RouteGet(destination net.IP) ([]Route, error)

RouteGet gets a route to a specific destination from the host system. Equivalent to: 'ip route get'.

func RouteGetWithOptions Uses

func RouteGetWithOptions(destination net.IP, options *RouteGetOptions) ([]Route, error)

RouteGetWithOptions gets a route to a specific destination from the host system. Equivalent to: 'ip route get <> vrf <VrfName>'.

func RouteList Uses

func RouteList(link Link, family int) ([]Route, error)

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 RouteListFiltered Uses

func RouteListFiltered(family int, filter *Route, filterMask uint64) ([]Route, error)

RouteListFiltered gets a list of routes in the system filtered with specified rules. All rules must be defined in RouteFilter struct

func (*Route) ClearFlag Uses

func (r *Route) ClearFlag(flag NextHopFlag)

func (Route) Equal Uses

func (r Route) Equal(x Route) bool

func (*Route) ListFlags Uses

func (r *Route) ListFlags() []string

func (*Route) SetFlag Uses

func (r *Route) SetFlag(flag NextHopFlag)

func (Route) String Uses

func (r Route) String() string

type RouteGetOptions Uses

type RouteGetOptions struct {
    VrfName string
}

RouteGetOptions contains a set of options to use with RouteGetWithOptions

type RouteSubscribeOptions Uses

type RouteSubscribeOptions struct {
    Namespace     *netns.NsHandle
    ErrorCallback func(error)
    ListExisting  bool
}

RouteSubscribeOptions contains a set of options to use with RouteSubscribeWithOptions.

type RouteUpdate Uses

type RouteUpdate struct {
    Type uint16
    Route
}

RouteUpdate is sent when a route changes - type is RTM_NEWROUTE or RTM_DELROUTE

type Rule Uses

type Rule struct {
    Priority          int
    Family            int
    Table             int
    Mark              int
    Mask              int
    Tos               uint
    TunID             uint
    Goto              int
    Src               *net.IPNet
    Dst               *net.IPNet
    Flow              int
    IifName           string
    OifName           string
    SuppressIfgroup   int
    SuppressPrefixlen int
    Invert            bool
    Dport             *RulePortRange
    Sport             *RulePortRange
}

Rule represents a netlink rule.

func NewRule Uses

func NewRule() *Rule

NewRule return empty rules.

func RuleList Uses

func RuleList(family int) ([]Rule, error)

RuleList lists rules in the system. Equivalent to: ip rule list

func RuleListFiltered Uses

func RuleListFiltered(family int, filter *Rule, filterMask uint64) ([]Rule, error)

RuleListFiltered gets a list of rules in the system filtered by the specified rule template `filter`. Equivalent to: ip rule list

func (Rule) String Uses

func (r Rule) String() string

type RulePortRange Uses

type RulePortRange struct {
    Start uint16
    End   uint16
}

RulePortRange represents rule sport/dport range.

func NewRulePortRange Uses

func NewRulePortRange(start, end uint16) *RulePortRange

NewRulePortRange creates rule sport/dport range.

type SEG6Encap Uses

type SEG6Encap struct {
    Mode     int
    Segments []net.IP
}

SEG6 definitions

func (*SEG6Encap) Decode Uses

func (e *SEG6Encap) Decode(buf []byte) error

func (*SEG6Encap) Encode Uses

func (e *SEG6Encap) Encode() ([]byte, error)

func (*SEG6Encap) Equal Uses

func (e *SEG6Encap) Equal(x Encap) bool

func (*SEG6Encap) String Uses

func (e *SEG6Encap) String() string

func (*SEG6Encap) Type Uses

func (e *SEG6Encap) Type() int

type SEG6LocalEncap Uses

type SEG6LocalEncap struct {
    Flags    [nl.SEG6_LOCAL_MAX]bool
    Action   int
    Segments []net.IP // from SRH in seg6_local_lwt
    Table    int      // table id for End.T and End.DT6
    InAddr   net.IP
    In6Addr  net.IP
    Iif      int
    Oif      int
}

SEG6LocalEncap definitions

func (*SEG6LocalEncap) Decode Uses

func (e *SEG6LocalEncap) Decode(buf []byte) error

func (*SEG6LocalEncap) Encode Uses

func (e *SEG6LocalEncap) Encode() ([]byte, error)

func (*SEG6LocalEncap) Equal Uses

func (e *SEG6LocalEncap) Equal(x Encap) bool

func (*SEG6LocalEncap) String Uses

func (e *SEG6LocalEncap) String() string

func (*SEG6LocalEncap) Type Uses

func (e *SEG6LocalEncap) Type() int

type Scope Uses

type Scope uint8

Scope is an enum representing a route scope.

const (
    SCOPE_UNIVERSE Scope = unix.RT_SCOPE_UNIVERSE
    SCOPE_SITE     Scope = unix.RT_SCOPE_SITE
    SCOPE_LINK     Scope = unix.RT_SCOPE_LINK
    SCOPE_HOST     Scope = unix.RT_SCOPE_HOST
    SCOPE_NOWHERE  Scope = unix.RT_SCOPE_NOWHERE
)

type ServiceCurve Uses

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

ServiceCurve is a nondecreasing function of some time unit, returning the amount of service (an allowed or allocated amount of bandwidth) at some specific point in time. The purpose of it should be subconsciously obvious: if a class was allowed to transfer not less than the amount specified by its service curve, then the service curve is not violated.

func (*ServiceCurve) Attrs Uses

func (c *ServiceCurve) Attrs() (uint32, uint32, uint32)

Attrs return the parameters of the service curve

func (*ServiceCurve) Burst Uses

func (c *ServiceCurve) Burst() uint32

Burst returns the burst rate (m1) of the curve

func (*ServiceCurve) Delay Uses

func (c *ServiceCurve) Delay() uint32

Delay return the delay (d) of the curve

func (*ServiceCurve) Rate Uses

func (c *ServiceCurve) Rate() uint32

Rate returns the rate (m2) of the curve

type Sittun Uses

type Sittun struct {
    LinkAttrs
    Link       uint32
    Local      net.IP
    Remote     net.IP
    Ttl        uint8
    Tos        uint8
    PMtuDisc   uint8
    EncapType  uint16
    EncapFlags uint16
    EncapSport uint16
    EncapDport uint16
}

func (*Sittun) Attrs Uses

func (sittun *Sittun) Attrs() *LinkAttrs

func (*Sittun) Type Uses

func (sittun *Sittun) Type() string

type SkbEditAction Uses

type SkbEditAction struct {
    ActionAttrs
    QueueMapping *uint16
    PType        *uint16
    Priority     *uint32
    Mark         *uint32
}

func NewSkbEditAction Uses

func NewSkbEditAction() *SkbEditAction

func (*SkbEditAction) Attrs Uses

func (action *SkbEditAction) Attrs() *ActionAttrs

func (*SkbEditAction) Type Uses

func (action *SkbEditAction) Type() string

type Socket Uses

type Socket struct {
    Family  uint8
    State   uint8
    Timer   uint8
    Retrans uint8
    ID      SocketID
    Expires uint32
    RQueue  uint32
    WQueue  uint32
    UID     uint32
    INode   uint32
}

Socket represents a netlink socket.

func SocketGet Uses

func SocketGet(local, remote net.Addr) (*Socket, error)

SocketGet returns the Socket identified by its local and remote addresses.

type SocketID Uses

type SocketID struct {
    SourcePort      uint16
    DestinationPort uint16
    Source          net.IP
    Destination     net.IP
    Interface       uint32
    Cookie          [2]uint32
}

SocketID identifies a single socket.

type Tbf Uses

type Tbf struct {
    QdiscAttrs
    Rate     uint64
    Limit    uint32
    Buffer   uint32
    Peakrate uint64
    Minburst uint32
}

Tbf is a classless qdisc that rate limits based on tokens

func (*Tbf) Attrs Uses

func (qdisc *Tbf) Attrs() *QdiscAttrs

func (*Tbf) Type Uses

func (qdisc *Tbf) Type() string

type TcAct Uses

type TcAct int32
const (
    TC_ACT_UNSPEC     TcAct = -1
    TC_ACT_OK         TcAct = 0
    TC_ACT_RECLASSIFY TcAct = 1
    TC_ACT_SHOT       TcAct = 2
    TC_ACT_PIPE       TcAct = 3
    TC_ACT_STOLEN     TcAct = 4
    TC_ACT_QUEUED     TcAct = 5
    TC_ACT_REPEAT     TcAct = 6
    TC_ACT_REDIRECT   TcAct = 7
    TC_ACT_JUMP       TcAct = 0x10000000
)

func (TcAct) String Uses

func (a TcAct) String() string

type TcPolAct Uses

type TcPolAct int32
const (
    TC_POLICE_UNSPEC     TcPolAct = TcPolAct(TC_ACT_UNSPEC)
    TC_POLICE_OK         TcPolAct = TcPolAct(TC_ACT_OK)
    TC_POLICE_RECLASSIFY TcPolAct = TcPolAct(TC_ACT_RECLASSIFY)
    TC_POLICE_SHOT       TcPolAct = TcPolAct(TC_ACT_SHOT)
    TC_POLICE_PIPE       TcPolAct = TcPolAct(TC_ACT_PIPE)
)

func (TcPolAct) String Uses

func (a TcPolAct) String() string

type TcU32Key Uses

type TcU32Key = nl.TcU32Key

TcU32Key contained of Sel in the U32 filters. This is the type alias and the frontend representation of nl.TcU32Key. It is serialized into chanonical nl.TcU32Sel with the appropriate endianness.

type TcU32Sel Uses

type TcU32Sel = nl.TcU32Sel

Sel of the U32 filters that contains multiple TcU32Key. This is the type alias and the frontend representation of nl.TcU32Sel. It is serialized into canonical nl.TcU32Sel with the appropriate endianness.

type TunnelKeyAct Uses

type TunnelKeyAct int8
const (
    TCA_TUNNEL_KEY_SET   TunnelKeyAct = 1 // set tunnel key
    TCA_TUNNEL_KEY_UNSET TunnelKeyAct = 2 // unset tunnel key
)

type TunnelKeyAction Uses

type TunnelKeyAction struct {
    ActionAttrs
    Action  TunnelKeyAct
    SrcAddr net.IP
    DstAddr net.IP
    KeyID   uint32
}

func NewTunnelKeyAction Uses

func NewTunnelKeyAction() *TunnelKeyAction

func (*TunnelKeyAction) Attrs Uses

func (action *TunnelKeyAction) Attrs() *ActionAttrs

func (*TunnelKeyAction) Type Uses

func (action *TunnelKeyAction) Type() string

type Tuntap Uses

type Tuntap struct {
    LinkAttrs
    Mode       TuntapMode
    Flags      TuntapFlag
    NonPersist bool
    Queues     int
    Fds        []*os.File
    Owner      uint32
    Group      uint32
}

Tuntap links created via /dev/tun/tap, but can be destroyed via netlink

func (*Tuntap) Attrs Uses

func (tuntap *Tuntap) Attrs() *LinkAttrs

func (*Tuntap) Type Uses

func (tuntap *Tuntap) Type() string

type TuntapFlag Uses

type TuntapFlag uint16

type TuntapMode Uses

type TuntapMode uint16

type U32 Uses

type U32 struct {
    FilterAttrs
    ClassId    uint32
    Divisor    uint32 // Divisor MUST be power of 2.
    Hash       uint32
    RedirIndex int
    Sel        *TcU32Sel
    Actions    []Action
}

U32 filters on many packet related properties

func (*U32) Attrs Uses

func (filter *U32) Attrs() *FilterAttrs

func (*U32) Type Uses

func (filter *U32) Type() string

type Veth Uses

type Veth struct {
    LinkAttrs
    PeerName         string // veth on create only
    PeerHardwareAddr net.HardwareAddr
}

Veth devices must specify PeerName on create

func (*Veth) Attrs Uses

func (veth *Veth) Attrs() *LinkAttrs

func (*Veth) Type Uses

func (veth *Veth) Type() string

type VfInfo Uses

type VfInfo struct {
    ID        int
    Mac       net.HardwareAddr
    Vlan      int
    Qos       int
    TxRate    int // IFLA_VF_TX_RATE  Max TxRate
    Spoofchk  bool
    LinkState uint32
    MaxTxRate uint32 // IFLA_VF_RATE Max TxRate
    MinTxRate uint32 // IFLA_VF_RATE Min TxRate
}

VfInfo represents configuration of virtual function

type Vlan Uses

type Vlan struct {
    LinkAttrs
    VlanId       int
    VlanProtocol VlanProtocol
}

Vlan links have ParentIndex set in their Attrs()

func (*Vlan) Attrs Uses

func (vlan *Vlan) Attrs() *LinkAttrs

func (*Vlan) Type Uses

func (vlan *Vlan) Type() string

type VlanProtocol Uses

type VlanProtocol int

VlanProtocol type

const (
    VLAN_PROTOCOL_UNKNOWN VlanProtocol = 0
    VLAN_PROTOCOL_8021Q   VlanProtocol = 0x8100
    VLAN_PROTOCOL_8021AD  VlanProtocol = 0x88A8
)

VlanProtocol possible values

func StringToVlanProtocol Uses

func StringToVlanProtocol(s string) VlanProtocol

StringToVlanProtocol returns vlan protocol, or unknown is the s is invalid.

func (VlanProtocol) String Uses

func (p VlanProtocol) String() string

type Vrf Uses

type Vrf struct {
    LinkAttrs
    Table uint32
}

func (*Vrf) Attrs Uses

func (vrf *Vrf) Attrs() *LinkAttrs

func (*Vrf) Type Uses

func (vrf *Vrf) Type() string

type Vti Uses

type Vti struct {
    LinkAttrs
    IKey   uint32
    OKey   uint32
    Link   uint32
    Local  net.IP
    Remote net.IP
}

func (*Vti) Attrs Uses

func (vti *Vti) Attrs() *LinkAttrs

func (*Vti) Type Uses

func (vti *Vti) Type() string

type Vxlan Uses

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
    UDPCSum        bool
    UDP6ZeroCSumTx bool
    UDP6ZeroCSumRx bool
    NoAge          bool
    GBP            bool
    FlowBased      bool
    Age            int
    Limit          int
    Port           int
    PortLow        int
    PortHigh       int
}

func (*Vxlan) Attrs Uses

func (vxlan *Vxlan) Attrs() *LinkAttrs

func (*Vxlan) Type Uses

func (vxlan *Vxlan) Type() string

type Wireguard Uses

type Wireguard struct {
    LinkAttrs
}

Wireguard represent links of type "wireguard", see https://www.wireguard.com/

func (*Wireguard) Attrs Uses

func (wg *Wireguard) Attrs() *LinkAttrs

func (*Wireguard) Type Uses

func (wg *Wireguard) Type() string

type XfrmMark Uses

type XfrmMark struct {
    Value uint32
    Mask  uint32
}

XfrmMark represents the mark associated to the state or policy

func (*XfrmMark) String Uses

func (m *XfrmMark) String() string

type XfrmMsg Uses

type XfrmMsg interface {
    Type() nl.XfrmMsgType
}

type XfrmMsgExpire Uses

type XfrmMsgExpire struct {
    XfrmState *XfrmState
    Hard      bool
}

func (*XfrmMsgExpire) Type Uses

func (ue *XfrmMsgExpire) Type() nl.XfrmMsgType

type XfrmPolicy Uses

type XfrmPolicy struct {
    Dst      *net.IPNet
    Src      *net.IPNet
    Proto    Proto
    DstPort  int
    SrcPort  int
    Dir      Dir
    Priority int
    Index    int
    Action   PolicyAction
    Ifindex  int
    Ifid     int
    Mark     *XfrmMark
    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 XfrmPolicyGet Uses

func XfrmPolicyGet(policy *XfrmPolicy) (*XfrmPolicy, error)

XfrmPolicyGet gets a the policy described by the index or selector, if found. Equivalent to: `ip xfrm policy get { SELECTOR | index INDEX } dir DIR [ctx CTX ] [ mark MARK [ mask MASK ] ] [ ptype PTYPE ]`.

func XfrmPolicyList Uses

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.

func (XfrmPolicy) String Uses

func (p XfrmPolicy) String() string

type XfrmPolicyTmpl Uses

type XfrmPolicyTmpl struct {
    Dst   net.IP
    Src   net.IP
    Proto Proto
    Mode  Mode
    Spi   int
    Reqid int
}

XfrmPolicyTmpl encapsulates a rule for the base addresses of an ipsec policy. These rules are matched with XfrmState to determine encryption and authentication algorithms.

func (XfrmPolicyTmpl) String Uses

func (t XfrmPolicyTmpl) String() string

type XfrmState Uses

type XfrmState struct {
    Dst          net.IP
    Src          net.IP
    Proto        Proto
    Mode         Mode
    Spi          int
    Reqid        int
    ReplayWindow int
    Limits       XfrmStateLimits
    Statistics   XfrmStateStats
    Mark         *XfrmMark
    OutputMark   int
    Ifid         int
    Auth         *XfrmStateAlgo
    Crypt        *XfrmStateAlgo
    Aead         *XfrmStateAlgo
    Encap        *XfrmStateEncap
    ESN          bool
}

XfrmState represents the state of an ipsec policy. It optionally contains an XfrmStateAlgo for encryption and one for authentication.

func XfrmStateAllocSpi Uses

func XfrmStateAllocSpi(state *XfrmState) (*XfrmState, error)

XfrmStateAllocSpi will allocate an xfrm state in the system. Equivalent to: `ip xfrm state allocspi`

func XfrmStateGet Uses

func XfrmStateGet(state *XfrmState) (*XfrmState, error)

XfrmStateGet gets the xfrm state described by the ID, if found. Equivalent to: `ip xfrm state get ID [ mark MARK [ mask MASK ] ]`. Only the fields which constitue the SA ID must be filled in: ID := [ src ADDR ] [ dst ADDR ] [ proto XFRM-PROTO ] [ spi SPI ] mark is optional

func XfrmStateList Uses

func XfrmStateList(family int) ([]XfrmState, error)

XfrmStateList gets a list of xfrm states in the system. Equivalent to: `ip [-4|-6] xfrm state show`. The list can be filtered by ip family.

func (XfrmState) Print Uses

func (sa XfrmState) Print(stats bool) string

func (XfrmState) String Uses

func (sa XfrmState) String() string

type XfrmStateAlgo Uses

type XfrmStateAlgo struct {
    Name        string
    Key         []byte
    TruncateLen int // Auth only
    ICVLen      int // AEAD only
}

XfrmStateAlgo represents the algorithm to use for the ipsec encryption.

func (XfrmStateAlgo) String Uses

func (a XfrmStateAlgo) String() string

type XfrmStateEncap Uses

type XfrmStateEncap struct {
    Type            EncapType
    SrcPort         int
    DstPort         int
    OriginalAddress net.IP
}

XfrmStateEncap represents the encapsulation to use for the ipsec encryption.

func (XfrmStateEncap) String Uses

func (e XfrmStateEncap) String() string

type XfrmStateLimits Uses

type XfrmStateLimits struct {
    ByteSoft    uint64
    ByteHard    uint64
    PacketSoft  uint64
    PacketHard  uint64
    TimeSoft    uint64
    TimeHard    uint64
    TimeUseSoft uint64
    TimeUseHard uint64
}

XfrmStateLimits represents the configured limits for the state.

type XfrmStateStats Uses

type XfrmStateStats struct {
    ReplayWindow uint32
    Replay       uint32
    Failed       uint32
    Bytes        uint64
    Packets      uint64
    AddTime      uint64
    UseTime      uint64
}

XfrmStateStats represents the current number of bytes/packets processed by this State, the State's installation and first use time and the replay window counters.

type Xfrmi Uses

type Xfrmi struct {
    LinkAttrs
    Ifid uint32
}

Virtual XFRM Interfaces

Named "xfrmi" to prevent confusion with XFRM objects

func (*Xfrmi) Attrs Uses

func (xfrm *Xfrmi) Attrs() *LinkAttrs

func (*Xfrmi) Type Uses

func (xfrm *Xfrmi) Type() string

Directories

PathSynopsis
nlPackage nl has low level primitives for making Netlink calls.

Package netlink imports 17 packages (graph) and is imported by 1890 packages. Updated 2020-06-25. Refresh now. Tools for package owners.