Documentation ¶
Overview ¶
Package osl describes structures and interfaces which abstract os entities
Index ¶
- Constants
- func GC()
- func GenerateKey(containerID string) string
- func SetBasePath(path string)
- type Iface
- type IfaceOption
- func WithIPv4Address(addr *net.IPNet) IfaceOption
- func WithIPv6Address(addr *net.IPNet) IfaceOption
- func WithIsBridge(isBridge bool) IfaceOption
- func WithLinkLocalAddresses(list []*net.IPNet) IfaceOption
- func WithMACAddress(mac net.HardwareAddr) IfaceOption
- func WithMaster(name string) IfaceOption
- func WithRoutes(routes []*net.IPNet) IfaceOption
- func WithSysctls(sysctls []string) IfaceOption
- type Interface
- func (i *Interface) Address() *net.IPNet
- func (i *Interface) AddressIPv6() *net.IPNet
- func (i *Interface) Bridge() bool
- func (i *Interface) DstMaster() string
- func (i *Interface) DstName() string
- func (i *Interface) LinkLocalAddresses() []*net.IPNet
- func (i *Interface) MacAddress() net.HardwareAddr
- func (i *Interface) Remove() error
- func (i *Interface) Routes() []*net.IPNet
- func (i *Interface) SrcName() string
- func (i *Interface) Statistics() (*types.InterfaceStatistics, error)
- type Namespace
- func (n *Namespace) AddAliasIP(ifName string, ip *net.IPNet) error
- func (n *Namespace) AddInterface(ctx context.Context, srcName, dstPrefix string, options ...IfaceOption) error
- func (n *Namespace) AddNeighbor(dstIP net.IP, dstMac net.HardwareAddr, force bool, options ...NeighOption) error
- func (n *Namespace) AddStaticRoute(r *types.StaticRoute) error
- func (n *Namespace) ApplyOSTweaks(types []SandboxType)
- func (n *Namespace) DeleteNeighbor(dstIP net.IP, dstMac net.HardwareAddr) error
- func (n *Namespace) Destroy() error
- func (n *Namespace) DisableARPForVIP(srcName string) (Err error)
- func (n *Namespace) Gateway() net.IP
- func (n *Namespace) GatewayIPv6() net.IP
- func (n *Namespace) GetLoopbackIfaceName() string
- func (n *Namespace) IPv6LoEnabled() bool
- func (n *Namespace) Interfaces() []*Interface
- func (n *Namespace) InvokeFunc(f func()) error
- func (n *Namespace) Key() string
- func (n *Namespace) RefreshIPv6LoEnabled()
- func (n *Namespace) RemoveAliasIP(ifName string, ip *net.IPNet) error
- func (n *Namespace) RemoveInterface(i *Interface) error
- func (n *Namespace) RemoveStaticRoute(r *types.StaticRoute) error
- func (n *Namespace) Restore(interfaces map[Iface][]IfaceOption, routes []*types.StaticRoute, gw net.IP, ...) error
- func (n *Namespace) SetGateway(gw net.IP) error
- func (n *Namespace) SetGatewayIPv6(gwv6 net.IP) error
- func (n *Namespace) StaticRoutes() []*types.StaticRoute
- func (n *Namespace) UnsetGateway() error
- func (n *Namespace) UnsetGatewayIPv6() error
- type NeighOption
- type NeighborSearchError
- type SandboxType
Constants ¶
const ( // SandboxTypeIngress indicates that the sandbox is for the ingress SandboxTypeIngress = iota // SandboxTypeLoadBalancer indicates that the sandbox is a load balancer SandboxTypeLoadBalancer = iota )
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
GenerateKey generates a sandbox key based on the passed container id.
func SetBasePath ¶
func SetBasePath(path string)
SetBasePath sets the base url prefix for the ns path
Types ¶
type IfaceOption ¶
IfaceOption is a function option type to set interface options.
func WithIPv4Address ¶
func WithIPv4Address(addr *net.IPNet) IfaceOption
WithIPv4Address sets the IPv4 address of the interface.
func WithIPv6Address ¶
func WithIPv6Address(addr *net.IPNet) IfaceOption
WithIPv6Address sets the IPv6 address of the interface.
func WithIsBridge ¶
func WithIsBridge(isBridge bool) IfaceOption
WithIsBridge sets whether the interface is a bridge.
func WithLinkLocalAddresses ¶
func WithLinkLocalAddresses(list []*net.IPNet) IfaceOption
WithLinkLocalAddresses set the link-local IP addresses of the interface.
func WithMACAddress ¶
func WithMACAddress(mac net.HardwareAddr) IfaceOption
WithMACAddress sets the interface MAC-address.
func WithMaster ¶
func WithMaster(name string) IfaceOption
WithMaster sets the master interface (if any) for this interface. The master interface name should refer to the srcName of a previously added interface of type bridge.
func WithRoutes ¶
func WithRoutes(routes []*net.IPNet) IfaceOption
WithRoutes sets the interface routes.
func WithSysctls ¶
func WithSysctls(sysctls []string) IfaceOption
WithSysctls sets the interface sysctls.
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
Interface represents the settings and identity of a network device. It is used as a return type for Network.Link, and it is common practice for the caller to use this information when moving interface SrcName from host namespace to DstName in a different net namespace with the appropriate network settings.
func (*Interface) AddressIPv6 ¶
AddressIPv6 returns the IPv6 address for the interface.
func (*Interface) DstName ¶
DstName returns the name that will be assigned to the interface once moved inside a network namespace. When the caller passes in a DstName, it is only expected to pass a prefix. The name will be modified with an auto-generated suffix.
func (*Interface) LinkLocalAddresses ¶
LinkLocalAddresses returns the link-local IP addresses assigned to the interface.
func (*Interface) MacAddress ¶
func (i *Interface) MacAddress() net.HardwareAddr
func (*Interface) Remove ¶
Remove an interface from the sandbox by renaming to original name and moving it out of the sandbox.
func (*Interface) SrcName ¶
SrcName returns the name of the interface in the origin network namespace.
func (*Interface) Statistics ¶
func (i *Interface) Statistics() (*types.InterfaceStatistics, error)
Statistics returns the sandbox's side veth interface statistics.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace represents a network sandbox. It represents a Linux network namespace, and moves an interface into it when called on method AddInterface or sets the gateway etc. It holds a list of Interfaces, routes etc., and more can be added dynamically.
func GetSandboxForExternalKey ¶
GetSandboxForExternalKey returns sandbox object for the supplied path
func NewSandbox ¶
NewSandbox provides a new Namespace instance created in an os specific way provided a key which uniquely identifies the sandbox.
func (*Namespace) AddAliasIP ¶
AddAliasIP adds the passed IP address to the named interface
func (*Namespace) AddInterface ¶
func (n *Namespace) AddInterface(ctx context.Context, srcName, dstPrefix string, options ...IfaceOption) error
AddInterface adds an existing Interface to the sandbox. The operation will rename from the Interface SrcName to DstName as it moves, and reconfigure the interface according to the specified settings. The caller is expected to only provide a prefix for DstName. The AddInterface api will auto-generate an appropriate suffix for the DstName to disambiguate.
func (*Namespace) AddNeighbor ¶
func (n *Namespace) AddNeighbor(dstIP net.IP, dstMac net.HardwareAddr, force bool, options ...NeighOption) error
AddNeighbor adds a neighbor entry into the sandbox.
func (*Namespace) AddStaticRoute ¶
func (n *Namespace) AddStaticRoute(r *types.StaticRoute) error
AddStaticRoute adds a static route to the sandbox.
func (*Namespace) ApplyOSTweaks ¶
func (n *Namespace) ApplyOSTweaks(types []SandboxType)
ApplyOSTweaks applies operating system specific knobs on the sandbox.
func (*Namespace) DeleteNeighbor ¶
DeleteNeighbor deletes neighbor entry from the sandbox.
func (*Namespace) DisableARPForVIP ¶
DisableARPForVIP disables ARP replies and requests for VIP addresses on a particular interface.
func (*Namespace) GatewayIPv6 ¶
GatewayIPv6 returns the IPv6 gateway for the sandbox.
func (*Namespace) GetLoopbackIfaceName ¶
GetLoopbackIfaceName returns the name of the loopback interface
func (*Namespace) IPv6LoEnabled ¶
IPv6LoEnabled returns true if the loopback interface had an IPv6 address when last checked. It's always checked on the first call, and by RefreshIPv6LoEnabled. ('::1' is assigned by the kernel if IPv6 is enabled.)
func (*Namespace) Interfaces ¶
Interfaces returns the collection of Interface previously added with the AddInterface method. Note that this doesn't include network interfaces added in any other way (such as the default loopback interface which is automatically created on creation of a sandbox).
func (*Namespace) InvokeFunc ¶
InvokeFunc invoke a function in the network namespace.
func (*Namespace) RefreshIPv6LoEnabled ¶
func (n *Namespace) RefreshIPv6LoEnabled()
RefreshIPv6LoEnabled refreshes the cached result returned by IPv6LoEnabled.
func (*Namespace) RemoveAliasIP ¶
RemoveAliasIP removes the passed IP address from the named interface
func (*Namespace) RemoveInterface ¶
RemoveInterface removes an interface from the namespace by renaming to original name and moving it out of the sandbox.
func (*Namespace) RemoveStaticRoute ¶
func (n *Namespace) RemoveStaticRoute(r *types.StaticRoute) error
RemoveStaticRoute removes a static route from the sandbox.
func (*Namespace) Restore ¶
func (n *Namespace) Restore(interfaces map[Iface][]IfaceOption, routes []*types.StaticRoute, gw net.IP, gw6 net.IP) error
Restore restores the network namespace.
func (*Namespace) SetGateway ¶
SetGateway sets the default IPv4 gateway for the sandbox. It is a no-op if the given gateway is empty.
func (*Namespace) SetGatewayIPv6 ¶
SetGatewayIPv6 sets the default IPv6 gateway for the sandbox. It is a no-op if the given gateway is empty.
func (*Namespace) StaticRoutes ¶
func (n *Namespace) StaticRoutes() []*types.StaticRoute
StaticRoutes returns additional static routes for the sandbox. Note that directly connected routes are stored on the particular interface they refer to.
func (*Namespace) UnsetGateway ¶
UnsetGateway the previously set default IPv4 gateway in the sandbox. It is a no-op if no gateway was set.
func (*Namespace) UnsetGatewayIPv6 ¶
UnsetGatewayIPv6 unsets the previously set default IPv6 gateway in the sandbox. It is a no-op if no gateway was set.
type NeighOption ¶
type NeighOption func(nh *neigh)
NeighOption is a function option type to set neighbor options.
func WithFamily ¶
func WithFamily(family int) NeighOption
WithFamily sets the address-family for the neighbor entry. e.g. syscall.AF_BRIDGE.
func WithLinkName ¶
func WithLinkName(name string) NeighOption
WithLinkName sets the srcName of the link to use in the neighbor entry.
type NeighborSearchError ¶
type NeighborSearchError struct {
// contains filtered or unexported fields
}
NeighborSearchError indicates that the neighbor is already present
func (NeighborSearchError) Error ¶
func (n NeighborSearchError) Error() string
type SandboxType ¶
type SandboxType int
SandboxType specify the time of the sandbox, this can be used to apply special configs