ip

package
v6.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteVDPADevice

func DeleteVDPADevice(vDPADevName string) error

DeleteVDPADevice deletes a vDPA management device.

func ParseIPNet added in v6.0.5

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

ParseIPNet parses a CIDR string and returns a *net.IPNet containing both the full address and the netmask, Unlike net.ParseCIDR which zeroes out the host part in the returned *net.IPNet and returns the full address separately.

Types

type Action

type Action interface {
	// contains filtered or unexported methods
}

Action represents an action in filter.

type ActionPolice

type ActionPolice struct {
	Rate  uint32 // in byte/s
	Burst uint32 // in byte
	Mtu   uint32 // in byte
	Drop  bool
}

ActionPolice represents an action of 'police' type.

type Addr

type Addr struct {
	DevName string
	Address *net.IPNet
	Scope   string
	Family  Family
}

Addr represents arguments for address protocol manipulation.

func (*Addr) Add

func (a *Addr) Add() error

Add adds new protocol address.

func (*Addr) Flush

func (a *Addr) Flush() error

Flush flushes protocol addresses.

type Bridge

type Bridge struct {
	Link
}

Bridge represents arguments for link device of type bridge.

func (*Bridge) Add

func (b *Bridge) Add() error

Add adds new virtual link.

type Class

type Class struct {
	Dev     string
	Parent  string
	Classid string
}

Class represents qdisc class object.

type ClassHTB

type ClassHTB struct {
	Class
	Rate string
}

ClassHTB represents htb qdisc class object.

func (*ClassHTB) Add

func (class *ClassHTB) Add() error

Add adds class to a node.

type Dummy

type Dummy struct {
	Link
}

Dummy represents arguments for link device of type dummy.

func (*Dummy) Add

func (d *Dummy) Add() error

Add adds new virtual link.

type Family added in v6.0.5

type Family int

Family can be { FamilyAll, FamilyV4, FamilyV6 }.

const (
	// FamilyAll specifies any/all family.
	FamilyAll Family = unix.AF_UNSPEC

	// FamilyV4 specifies the IPv4 family.
	FamilyV4 Family = unix.AF_INET

	// FamilyV6 specifies the IPv6 family.
	FamilyV6 Family = unix.AF_INET6
)

type Filter

type Filter struct {
	Dev      string
	Parent   string
	Protocol string
	Flowid   string
}

Filter represents filter object.

type Gretap

type Gretap struct {
	Link
	Local  net.IP
	Remote net.IP
}

Gretap represents arguments for link of type gretap.

func (*Gretap) Add

func (g *Gretap) Add() error

Add adds new virtual link.

type Link struct {
	Name          string
	Kind          string
	MTU           uint32
	Parent        string
	Address       net.HardwareAddr
	TXQueueLength uint32
	AllMulticast  bool
	Master        string
	Up            bool
}

Link represents base arguments for link device.

func (*Link) BridgeLinkSetHairpin

func (l *Link) BridgeLinkSetHairpin(hairpin bool) error

BridgeLinkSetHairpin sets bridge 'hairpin' attribute on a port.

func (*Link) BridgeLinkSetIsolated

func (l *Link) BridgeLinkSetIsolated(isolated bool) error

BridgeLinkSetIsolated sets bridge 'isolated' attribute on a port.

func (*Link) BridgeVLANAdd

func (l *Link) BridgeVLANAdd(vid string, pvid bool, untagged bool, self bool) error

BridgeVLANAdd adds a new vlan filter entry.

func (*Link) BridgeVLANDelete

func (l *Link) BridgeVLANDelete(vid string, self bool) error

BridgeVLANDelete removes an existing vlan filter entry.

func (*Link) Delete

func (l *Link) Delete() error

Delete deletes the link device.

func (*Link) GetVFInfo

func (l *Link) GetVFInfo(vfID int) (VirtFuncInfo, error)

GetVFInfo returns info about virtual function.

func (*Link) SetAddress

func (l *Link) SetAddress(address net.HardwareAddr) error

SetAddress sets the address of the link device.

func (*Link) SetAllMulticast

func (l *Link) SetAllMulticast(enabled bool) error

SetAllMulticast when enabled instructs network driver to retrieve all multicast packets from the network to the kernel for further processing.

func (*Link) SetDown

func (l *Link) SetDown() error

SetDown disables the link device.

func (*Link) SetMTU

func (l *Link) SetMTU(mtu uint32) error

SetMTU sets the MTU of the link device.

func (*Link) SetMaster

func (l *Link) SetMaster(master string) error

SetMaster sets the master of the link device.

func (*Link) SetName

func (l *Link) SetName(newName string) error

SetName sets the name of the link device.

func (*Link) SetNetns

func (l *Link) SetNetns(netnsPid string) error

SetNetns moves the link to the selected network namespace.

func (*Link) SetNoMaster

func (l *Link) SetNoMaster() error

SetNoMaster removes the master of the link device.

func (*Link) SetTXQueueLength

func (l *Link) SetTXQueueLength(queueLength uint32) error

SetTXQueueLength sets the txqueuelen of the link device.

func (*Link) SetUp

func (l *Link) SetUp() error

SetUp enables the link device.

func (*Link) SetVfAddress

func (l *Link) SetVfAddress(vf string, address string) error

SetVfAddress changes the address for the specified vf.

func (*Link) SetVfSpoofchk

func (l *Link) SetVfSpoofchk(vf string, on bool) error

SetVfSpoofchk turns packet spoof checking on or off for the specified VF.

func (*Link) SetVfVlan

func (l *Link) SetVfVlan(vf string, vlan string) error

SetVfVlan changes the assigned VLAN for the specified vf.

type LinkInfo

type LinkInfo struct {
	Link
	OperationalState string
	SlaveKind        string
	VlanID           int
}

LinkInfo has additional information about a link.

func LinkByName added in v6.0.5

func LinkByName(name string) (LinkInfo, error)

LinkByName returns a Link from a device name.

type Macvlan

type Macvlan struct {
	Link
	Mode string
}

Macvlan represents arguments for link of type macvlan.

func (*Macvlan) Add

func (macvlan *Macvlan) Add() error

Add adds new virtual link.

type Macvtap

type Macvtap struct {
	Macvlan
}

Macvtap represents arguments for link of type macvtap.

func (*Macvtap) Add

func (macvtap *Macvtap) Add() error

Add adds new virtual link.

type Neigh

type Neigh struct {
	DevName string
	Addr    net.IP
	MAC     net.HardwareAddr
	State   NeighbourIPState
}

Neigh represents arguments for neighbour manipulation.

func (*Neigh) Show

func (n *Neigh) Show() ([]Neigh, error)

Show list neighbour entries filtered by DevName and optionally MAC address.

type NeighProxy

type NeighProxy struct {
	DevName string
	Addr    net.IP
}

NeighProxy represents arguments for neighbour proxy manipulation.

func (*NeighProxy) Add

func (n *NeighProxy) Add() error

Add a neighbour proxy entry.

func (*NeighProxy) Delete

func (n *NeighProxy) Delete() error

Delete a neighbour proxy entry.

func (*NeighProxy) Show

func (n *NeighProxy) Show() ([]NeighProxy, error)

Show list neighbour proxy entries.

type NeighbourIPState

type NeighbourIPState int

NeighbourIPState can be { NeighbourIPStatePermanent | NeighbourIPStateNoARP | NeighbourIPStateReachable | NeighbourIPStateStale | NeighbourIPStateNone | NeighbourIPStateIncomplete | NeighbourIPStateDelay | NeighbourIPStateProbe | NeighbourIPStateFailed }.

const (
	// NeighbourIPStatePermanent the neighbour entry is valid forever and can be only be removed administratively.
	NeighbourIPStatePermanent NeighbourIPState = unix.NUD_PERMANENT

	// NeighbourIPStateNoARP the neighbour entry is valid. No attempts to validate this entry will be made but it can
	// be removed when its lifetime expires.
	NeighbourIPStateNoARP NeighbourIPState = unix.NUD_NOARP

	// NeighbourIPStateReachable the neighbour entry is valid until the reachability timeout expires.
	NeighbourIPStateReachable NeighbourIPState = unix.NUD_REACHABLE

	// NeighbourIPStateStale the neighbour entry is valid but suspicious.
	NeighbourIPStateStale NeighbourIPState = unix.NUD_STALE

	// NeighbourIPStateNone this is a pseudo state used when initially creating a neighbour entry or after trying to
	// remove it before it becomes free to do so.
	NeighbourIPStateNone NeighbourIPState = unix.NUD_NONE

	// NeighbourIPStateIncomplete the neighbour entry has not (yet) been validated/resolved.
	NeighbourIPStateIncomplete NeighbourIPState = unix.NUD_INCOMPLETE

	// NeighbourIPStateDelay neighbor entry validation is currently delayed.
	NeighbourIPStateDelay NeighbourIPState = unix.NUD_DELAY

	// NeighbourIPStateProbe neighbor is being probed.
	NeighbourIPStateProbe NeighbourIPState = unix.NUD_PROBE

	// NeighbourIPStateFailed max number of probes exceeded without success, neighbor validation has ultimately failed.
	NeighbourIPStateFailed NeighbourIPState = unix.NUD_FAILED
)

type Qdisc

type Qdisc struct {
	Dev    string
	Handle string
	Parent string
}

Qdisc represents 'queueing discipline' object.

type QdiscHTB

type QdiscHTB struct {
	Qdisc
	Default uint32
}

QdiscHTB represents the hierarchy token bucket qdisc object.

func (*QdiscHTB) Add

func (q *QdiscHTB) Add() error

Add adds a htb qdisc to a device.

func (*QdiscHTB) Delete added in v6.0.5

func (q *QdiscHTB) Delete() error

Delete deletes a htb qdisc from a device.

type QdiscIngress added in v6.0.5

type QdiscIngress struct {
	Qdisc
}

QdiscIngress represents an ingress qdisc object.

func (*QdiscIngress) Add added in v6.0.5

func (q *QdiscIngress) Add() error

Add adds an ingress qdisc to a device.

func (*QdiscIngress) Delete added in v6.0.5

func (q *QdiscIngress) Delete() error

Delete deletes an ingress qdisc from a device.

type Route

type Route struct {
	DevName string
	Route   *net.IPNet
	Table   string
	Src     net.IP
	Proto   string
	Family  Family
	Via     net.IP
	VRF     string
	Scope   string
}

Route represents arguments for route manipulation.

func (*Route) Add

func (r *Route) Add() error

Add adds new route.

func (*Route) Delete

func (r *Route) Delete() error

Delete deletes routing table.

func (*Route) Flush

func (r *Route) Flush() error

Flush flushes routing tables.

func (*Route) List added in v6.0.5

func (r *Route) List() ([]Route, error)

List lists matching routes.

func (*Route) Replace

func (r *Route) Replace() error

Replace changes or adds new route. If there is already a route with the same destination, metric, tos and table then that route is updated, otherwise a new route is added.

type Tuntap

type Tuntap struct {
	Name       string
	Mode       string
	MultiQueue bool
	Master     string
}

Tuntap represents arguments for tuntap manipulation.

func (*Tuntap) Add

func (t *Tuntap) Add() error

Add adds new tuntap interface.

type U32Filter

type U32Filter struct {
	Filter
	Value   uint32
	Mask    uint32
	Actions []Action
}

U32Filter represents universal 32bit traffic control filter.

func (*U32Filter) Add

func (u32 *U32Filter) Add() error

Add adds universal 32bit traffic control filter to a node.

type VDPADev

type VDPADev struct {
	// Name of the vDPA created device. e.g. "vdpa0" (note: the iproute2 associated command would look like `vdpa dev add mgmtdev pci/<PCI_SLOT_NAME> name vdpa0 max_vqp <MAX_VQP>`).
	Name string
	// Max VQs supported by the vDPA device.
	MaxVQs uint32
	// Associated vhost-vdpa device.
	VhostVDPA *VhostVDPA
}

VDPADev represents the vDPA device information.

func AddVDPADevice

func AddVDPADevice(pciDevSlotName string, volatile map[string]string) (*VDPADev, error)

AddVDPADevice adds a new vDPA device.

type Veth

type Veth struct {
	Link
	Peer Link
}

Veth represents arguments for link of type veth.

func (*Veth) Add

func (veth *Veth) Add() error

Add adds new virtual link.

type VhostVDPA

type VhostVDPA struct {
	Name string
	Path string
}

VhostVDPA is the vhost-vdpa device information.

type VirtFuncInfo

type VirtFuncInfo struct {
	VF         int
	Address    net.HardwareAddr
	VLAN       int
	SpoofCheck bool
}

VirtFuncInfo holds information about vf.

type Vlan

type Vlan struct {
	Link
	VlanID string
	Gvrp   bool
}

Vlan represents arguments for link of type vlan.

func (*Vlan) Add

func (vlan *Vlan) Add() error

Add adds new virtual link.

type Vxlan

type Vxlan struct {
	Link
	VxlanID int
	DevName string
	Local   net.IP
	Remote  net.IP
	Group   net.IP
	DstPort int
	TTL     int
}

Vxlan represents arguments for link of type vxlan.

func (*Vxlan) Add

func (vxlan *Vxlan) Add() error

Add adds new virtual link.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL