netops

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NS

type NS struct {
	Name string
	Path string
	// contains filtered or unexported fields
}

NS represents a network namespace

func GetNS

func GetNS() (*NS, error)

GetNS returns an NS of the current network namespace

func NewNSFromPath

func NewNSFromPath(nsPath string) (*NS, error)

NewNSFromPath returns an NS specified by a namespace path

func NewNamedNS

func NewNamedNS(name string) (ns *NS, err error)

NewNamedNS returns an NS of the current network namespace

func (*NS) AddrAdd

func (ns *NS) AddrAdd(linkName string, addr *net.IPNet) error

AddrAdd adds an IP address to a link

func (*NS) Clone

func (ns *NS) Clone() (*NS, error)

Clone returns a copy of a network namespace. A returned network namespace need to be closed separately.

func (*NS) Close

func (ns *NS) Close() error

Close closes an NS

func (*NS) Delete

func (ns *NS) Delete() error

Delete deletes a named NS

func (*NS) DetectPodIP

func (ns *NS) DetectPodIP() (net.IP, string, error)

DetectPodIP returns IP and link of the default route device

func (*NS) FD

func (ns *NS) FD() int

FD returns a file descriptor of the network namespace

func (*NS) GetAvailableTableID

func (ns *NS) GetAvailableTableID(iif string, priority, min, max int) (int, error)

GetAvailableTableID returns a table ID that is not currently used

func (*NS) GetHardwareAddr

func (ns *NS) GetHardwareAddr(linkName string) (string, error)

func (*NS) GetIP

func (ns *NS) GetIP(linkName string) ([]net.IP, error)

GetIP returns a list of IP addresses assigned to a link

func (*NS) GetIPNet

func (ns *NS) GetIPNet(linkName string) ([]*net.IPNet, error)

GetIPNet returns a list of IPNets assigned to a link

func (*NS) GetMTU

func (ns *NS) GetMTU(linkName string) (int, error)

GetMTU returns MTU size of a link

func (*NS) GetRoutes

func (ns *NS) GetRoutes() ([]*Route, error)

GetRoutes gets a list of routes on the main table

func (*NS) LinkAdd

func (ns *NS) LinkAdd(linkName string, link netlink.Link) error

LinkAdd creates a new link with an attribute specified by link

func (*NS) LinkByName

func (ns *NS) LinkByName(name string) (netlink.Link, error)

func (*NS) LinkDel

func (ns *NS) LinkDel(linkName string) error

LinkDel deletes a link

func (ns *NS) LinkList() ([]netlink.Link, error)

func (*NS) LinkNameByAddr

func (ns *NS) LinkNameByAddr(ip net.IP) (string, error)

func (*NS) LinkSetMaster

func (ns *NS) LinkSetMaster(linkName, masterName string) error

LinkSetMaster sets a master device of a link

func (*NS) LinkSetNS

func (ns *NS) LinkSetNS(linkName string, targetNS *NS) error

LinkSetNS changes network namespace of a link

func (*NS) LinkSetName

func (ns *NS) LinkSetName(linkName, newName string) error

LinkSetName changes name of a link

func (*NS) LinkSetUp

func (ns *NS) LinkSetUp(linkName string) error

LinkSetUp makes the link status up

func (*NS) LocalRouteDel

func (ns *NS) LocalRouteDel(table int, dest *net.IPNet, dev string) error

LocalRouteDel deletes a route of the local local

func (*NS) RedirectAdd

func (ns *NS) RedirectAdd(src, dst string) error

RedirectAdd adds a tc ingress qdisc and redirect filter that redirects all traffic from src to dst

func (*NS) RedirectDel

func (ns *NS) RedirectDel(src string) error

RedirectDel deletes a tc ingress qdisc and redirect filters on src

func (*NS) RouteAdd

func (ns *NS) RouteAdd(table int, dest *net.IPNet, gw net.IP, dev string) error

RouteAdd adds a new route

func (ns *NS) RouteAddOnlink(table int, dest *net.IPNet, gw net.IP, dev string) error

func (*NS) RouteDel

func (ns *NS) RouteDel(table int, dest *net.IPNet, gw net.IP, dev string) error

RouteDel deletes routes

func (*NS) RuleAdd

func (ns *NS) RuleAdd(src *net.IPNet, iif string, priority int, table int) error

RuleAdd adds a new rule in the routing policy database

func (*NS) RuleDel

func (ns *NS) RuleDel(src *net.IPNet, iif string, priority int, table int) error

RuleDel deletes a rule in the routing policy database

func (*NS) RuleList

func (ns *NS) RuleList(src *net.IPNet, iif string, priority int, table int) ([]netlink.Rule, error)

RuleList gets a list of rules in the routing policy database

func (*NS) Run

func (ns *NS) Run(fn func() error) (err error)

Run calls a function in a network namespace

func (*NS) SetHardwareAddr

func (ns *NS) SetHardwareAddr(linkName, hwAddr string) error

func (*NS) SetMTU

func (ns *NS) SetMTU(linkName string, mtu int) error

SetMTU sets MTU size of a link

func (*NS) SysctlGet

func (ns *NS) SysctlGet(key string) (string, error)

SysctlGet returns a kernel parameter value specified by key

func (*NS) SysctlSet

func (ns *NS) SysctlSet(key string, val string) error

SysctlSet returns a kernel parameter value specified by key

func (*NS) VethAdd

func (ns *NS) VethAdd(name string, peerNS *NS, peerName string) error

VethAdd adds a veth pair

func (*NS) VethAddPrefix

func (ns *NS) VethAddPrefix(vethPrefix string, peerNS *NS, peerName string) (string, error)

VethAddPrefix adds a veth pair. One endpoint is create at ns, and its name begins with vethPrefix. The other endpoint is created at peerNS and its name is peerName.

type Route

type Route struct {
	Dst *net.IPNet
	GW  net.IP
	Dev string
}

Jump to

Keyboard shortcuts

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