linuxitems

package
v0.0.0-...-a6598b8 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VIFTypename : typename for VIF.
	VIFTypename = "VIF"
	// IPRuleTypename : typename for Linux IP rules.
	IPRuleTypename = "IPRule"
	// BridgeTypename : typename for Linux bridges.
	BridgeTypename = "Bridge"
	// BridgePortTypename : typename for network interface added into a Linux bridge.
	BridgePortTypename = "BridgePort"
	// DummyIfTypename : typename for Linux dummy interface.
	DummyIfTypename = "DummyInterface"
	// VLANBridgeTypename : typename for (Linux bridge) enabled for VLANs.
	VLANBridgeTypename = "VLANBridge"
	// VLANPortTypename : typename for bridged port with configured VLAN(s).
	VLANPortTypename = "VLANPort"
	// SysctlTypename : typename for kernel config applied via sysctl.
	SysctlTypename = "Sysctl"
)

Variables

This section is empty.

Functions

func RegisterItems

func RegisterItems(log *base.LogObject, registry *reconciler.DefaultRegistry,
	monitor netmonitor.NetworkMonitor) error

RegisterItems : register all configurators implemented by this package.

Types

type AccessPort

type AccessPort struct {
	VID uint16
}

AccessPort : port carries untagged traffic from a single VLAN.

type Bridge

type Bridge struct {
	// IfName : name of the bridge interface inside the network stack.
	IfName string
	// CreatedByNIM : true if this bridge was created by NIM to extend the bridge domain
	// of an uplink interface. Such bridge is then directly used for L2 network instances.
	CreatedByNIM bool
	// MACAddress : MAC address allocated for (or already assigned by NIM to) the bridge.
	MACAddress net.HardwareAddr
	// IPAddresses : a set of IP addresses allocated for the bridge itself (L3 NI),
	// or already assigned by the DHCP client (NIM-created bridge, L2 NI).
	IPAddresses []*net.IPNet
}

Bridge : Linux bridge.

func (Bridge) Dependencies

func (b Bridge) Dependencies() (deps []dg.Dependency)

Dependencies returns reservations of IPs that bridge should have assigned.

func (Bridge) Equal

func (b Bridge) Equal(other dg.Item) bool

Equal compares two Bridge instances.

func (Bridge) External

func (b Bridge) External() bool

External returns true if it was created by NIM and not be zedrouter.

func (Bridge) GetAssignedIPs

func (b Bridge) GetAssignedIPs() []*net.IPNet

GetAssignedIPs returns IP addresses assigned to the bridge interface. The function is needed for the definition of dependencies for dnsmasq and HTTP server.

func (Bridge) Label

func (b Bridge) Label() string

Label is not provided.

func (Bridge) Name

func (b Bridge) Name() string

Name returns the physical interface name.

func (Bridge) String

func (b Bridge) String() string

String describes Bridge.

func (Bridge) Type

func (b Bridge) Type() string

Type of the item.

type BridgeConfigurator

type BridgeConfigurator struct {
	Log *base.LogObject
}

BridgeConfigurator implements Configurator interface (libs/reconciler) for Linux bridge.

func (*BridgeConfigurator) Create

func (c *BridgeConfigurator) Create(ctx context.Context, item dg.Item) error

Create adds new Linux bridge.

func (*BridgeConfigurator) Delete

func (c *BridgeConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes Linux bridge.

func (*BridgeConfigurator) Modify

func (c *BridgeConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify is not implemented.

func (*BridgeConfigurator) NeedsRecreate

func (c *BridgeConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate always returns true - Modify is not implemented.

type BridgePort

type BridgePort struct {
	// BridgeIfName : interface name of the bridge.
	BridgeIfName string
	// Variant : port should be one of the supported variants.
	Variant BridgePortVariant
}

BridgePort : network interface added into a Linux bridge.

func (BridgePort) Dependencies

func (p BridgePort) Dependencies() (deps []dg.Dependency)

Dependencies returns the bridge and the port as the dependencies.

func (BridgePort) Equal

func (p BridgePort) Equal(other dg.Item) bool

Equal compares two BridgePort instances.

func (BridgePort) External

func (p BridgePort) External() bool

External returns false.

func (BridgePort) Label

func (p BridgePort) Label() string

Label for VLANPort.

func (BridgePort) Name

func (p BridgePort) Name() string

Name returns the interface name of the bridged port

func (BridgePort) String

func (p BridgePort) String() string

String describes BridgePort.

func (BridgePort) Type

func (p BridgePort) Type() string

Type of the item.

type BridgePortConfigurator

type BridgePortConfigurator struct {
	Log            *base.LogObject
	NetworkMonitor netmonitor.NetworkMonitor
}

BridgePortConfigurator implements Configurator interface (libs/reconciler) for Linux bridge port.

func (*BridgePortConfigurator) Create

func (c *BridgePortConfigurator) Create(ctx context.Context, item dg.Item) error

Create attaches port to a bridge.

func (*BridgePortConfigurator) Delete

func (c *BridgePortConfigurator) Delete(ctx context.Context, item dg.Item) (err error)

Delete detaches port from the bridge.

func (*BridgePortConfigurator) Modify

func (c *BridgePortConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify is not implemented.

func (*BridgePortConfigurator) NeedsRecreate

func (c *BridgePortConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate returns true - Modify is not implemented.

type BridgePortVariant

type BridgePortVariant struct {
	// UplinkIfName : bridged uplink interface.
	UplinkIfName string
	// VIFIfName : bridged VIF.
	VIFIfName string
}

BridgePortVariant is like union, only one option should have non-zero value.

type ContainerApp

type ContainerApp struct {
	ID uuid.UUID
	// NetNsName : name of a file under /var/run/netns/ dir, referencing network
	// namespace of the (container) app.
	NetNsName string
}

ContainerApp : container application separated from the host only using Linux namespaces.

type DummyIf

type DummyIf struct {
	// IfName : name of the DummyIf interface inside the network stack.
	IfName string
	// ARPOff : enable to suppress ARP on the dummy interface.
	ARPOff bool
}

DummyIf : Linux dummy interface.

func (DummyIf) Dependencies

func (d DummyIf) Dependencies() (deps []dg.Dependency)

Dependencies returns no dependencies.

func (DummyIf) Equal

func (d DummyIf) Equal(other dg.Item) bool

Equal compares two DummyIf instances.

func (DummyIf) External

func (d DummyIf) External() bool

External returns false.

func (DummyIf) Label

func (d DummyIf) Label() string

Label is not provided.

func (DummyIf) Name

func (d DummyIf) Name() string

Name returns the physical interface name.

func (DummyIf) String

func (d DummyIf) String() string

String describes DummyIf.

func (DummyIf) Type

func (d DummyIf) Type() string

Type of the item.

type DummyIfConfigurator

type DummyIfConfigurator struct {
	Log *base.LogObject
}

DummyIfConfigurator implements Configurator interface (libs/reconciler) for Linux dummy interface.

func (*DummyIfConfigurator) Create

func (c *DummyIfConfigurator) Create(ctx context.Context, item dg.Item) error

Create adds new Linux dummy interface.

func (*DummyIfConfigurator) Delete

func (c *DummyIfConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes Linux dummy interface.

func (*DummyIfConfigurator) Modify

func (c *DummyIfConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify is not implemented.

func (*DummyIfConfigurator) NeedsRecreate

func (c *DummyIfConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate always returns true - Modify is not implemented.

type IPRule

type IPRule struct {
	Priority int
	Table    int
	Mark     int
	Mask     int
	Src      *net.IPNet
	Dst      *net.IPNet
}

IPRule : Linux IP rule.

func (IPRule) Dependencies

func (r IPRule) Dependencies() (deps []dg.Dependency)

Dependencies returns no dependencies (table does not have to exist).

func (IPRule) Equal

func (r IPRule) Equal(other dg.Item) bool

Equal compares two IPRule instances.

func (IPRule) External

func (r IPRule) External() bool

External returns false.

func (IPRule) Label

func (r IPRule) Label() string

Label is more human-readable than name. Label resembles the output of "ip rule list".

func (IPRule) Name

func (r IPRule) Name() string

Name combines all attributes to construct a unique identifier for IP rule.

func (IPRule) String

func (r IPRule) String() string

String describes IPRule in detail.

func (IPRule) Type

func (r IPRule) Type() string

Type of the item.

type IPRuleConfigurator

type IPRuleConfigurator struct {
	Log *base.LogObject
}

IPRuleConfigurator implements Configurator interface (libs/reconciler) for Linux IP rule.

func (*IPRuleConfigurator) Create

func (c *IPRuleConfigurator) Create(ctx context.Context, item dg.Item) error

Create adds IP rule.

func (*IPRuleConfigurator) Delete

func (c *IPRuleConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes IP rule.

func (*IPRuleConfigurator) Modify

func (c *IPRuleConfigurator) Modify(_ context.Context, _, _ dg.Item) (err error)

Modify is not implemented.

func (*IPRuleConfigurator) NeedsRecreate

func (c *IPRuleConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate returns true - Modify is not implemented.

type IPSet

type IPSet struct {
	// SetName : name of the IPSet.
	// See "SETNAME" in https://ipset.netfilter.org/ipset.man.html.
	SetName string
	// TypeName : type of the IPSet.
	// See "TYPENAME" in https://ipset.netfilter.org/ipset.man.html.
	// See "SET TYPES" on that website for the summary of available types.
	TypeName string
	// AddrFamily should be either AF_INET or AF_INET6.
	AddrFamily int
	// Entries : set of entries added to the IPSet.
	// Entry syntax depends on the type, for example "192.168.1.1,udp:53"
	// would be valid for typename "hash:ip,port".
	Entries []string
}

IPSet : Linux ipset (https://ipset.netfilter.org/index.html).

func (IPSet) Dependencies

func (s IPSet) Dependencies() (deps []dg.Dependency)

Dependencies returns no dependencies.

func (IPSet) Equal

func (s IPSet) Equal(other dg.Item) bool

Equal compares two IPSet instances.

func (IPSet) External

func (s IPSet) External() bool

External returns false.

func (IPSet) Label

func (s IPSet) Label() string

Label is not provided.

func (IPSet) Name

func (s IPSet) Name() string

Name returns the IPSet name.

func (IPSet) String

func (s IPSet) String() string

String describes IPSet.

func (IPSet) Type

func (s IPSet) Type() string

Type of the item.

type IPSetConfigurator

type IPSetConfigurator struct {
	Log *base.LogObject
}

IPSetConfigurator implements Configurator interface (libs/reconciler) for Linux ipset (from netfilter).

func (*IPSetConfigurator) Create

func (c *IPSetConfigurator) Create(ctx context.Context, item dg.Item) error

Create adds new ipset.

func (*IPSetConfigurator) Delete

func (c *IPSetConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes ipset.

func (*IPSetConfigurator) Modify

func (c *IPSetConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify is not implemented. Note that zedrouter does not need to ever modify Entries - they are either static or dynamically managed by dnsmasq, i.e. outside zedrouter.

func (*IPSetConfigurator) NeedsRecreate

func (c *IPSetConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate always returns true - Modify is not implemented.

type Route

type Route struct {
	// Non-zero Route.LinkIndex should match OutputIf.
	// If Route.LinkIndex is zero, RouteConfigurator will find the output interface
	// index.
	netlink.Route
	// OutputIf : output interface for the routed traffic.
	// Leave undefined if the destination is unreachable.
	OutputIf genericitems.NetworkIf
	// GwViaLinkRoute is set to true if gateway is not included in the output interface
	// subnet and therefore depends on a link route (RT_SCOPE_LINK) for reachability.
	GwViaLinkRoute bool
	// ForApp is defined if route is configured inside app network namespace.
	ForApp ContainerApp
}

Route : Network route.

func (Route) Dependencies

func (r Route) Dependencies() (deps []dg.Dependency)

Dependencies of a network route are:

  • the "via" interface must exist and be UP
  • the "via" interface must have an IP address assigned from the subnet of the route gateway.
  • if route has src IP, this IP must be assigned to the "via" interface

func (Route) Equal

func (r Route) Equal(other dg.Item) bool

Equal compares two Route instances.

func (Route) External

func (r Route) External() bool

External returns false.

func (Route) Label

func (r Route) Label() string

Label is more human-readable than name.

func (Route) Name

func (r Route) Name() string

Name combines the app UUID, output interface name, route table ID and the destination address to construct a unique route identifier.

func (Route) String

func (r Route) String() string

String describes Route in detail.

func (Route) Type

func (r Route) Type() string

Type of the item.

type RouteConfigurator

type RouteConfigurator struct {
	Log            *base.LogObject
	NetworkMonitor netmonitor.NetworkMonitor
}

RouteConfigurator implements Configurator interface (libs/reconciler) for network routes.

func (*RouteConfigurator) Create

func (c *RouteConfigurator) Create(ctx context.Context, item dg.Item) error

Create adds network route.

func (*RouteConfigurator) Delete

func (c *RouteConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes network route.

func (*RouteConfigurator) Modify

func (c *RouteConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify is not implemented.

func (*RouteConfigurator) NeedsRecreate

func (c *RouteConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate returns true - Modify is not implemented.

type Sysctl

type Sysctl struct {
	// ForApp : if defined, apply these kernel parameters for a (container) app
	// (and not for the host).
	ForApp ContainerApp
	// NetIf : network interface for which parameters are applied.
	NetIf genericitems.NetworkIf
	// EnableDAD : enable duplicate address detection (IPv6).
	EnableDAD bool
	// EnableARPNotify : generate gratuitous arp requests when device is brought up
	// or hardware address changes
	EnableARPNotify bool
}

Sysctl : item representing kernel parameters set for a network interface using sysctl.

func (Sysctl) Dependencies

func (s Sysctl) Dependencies() (deps []dg.Dependency)

Dependencies returns the target interface as the only dependency.

func (Sysctl) Equal

func (s Sysctl) Equal(other dg.Item) bool

Equal compares sysctl settings.

func (Sysctl) External

func (s Sysctl) External() bool

External returns false.

func (Sysctl) Label

func (s Sysctl) Label() string

Label is not defined.

func (Sysctl) Name

func (s Sysctl) Name() string

Name of the item instance.

func (Sysctl) String

func (s Sysctl) String() string

String prints sysctl settings.

func (Sysctl) Type

func (s Sysctl) Type() string

Type of the item.

type SysctlConfigurator

type SysctlConfigurator struct {
	Log *base.LogObject
}

SysctlConfigurator implements Configurator for sysctl settings.

func (*SysctlConfigurator) Create

func (c *SysctlConfigurator) Create(ctx context.Context, item dg.Item) error

Create applies sysctl settings.

func (*SysctlConfigurator) Delete

func (c *SysctlConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete sets default sysctl settings.

func (*SysctlConfigurator) Modify

func (c *SysctlConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) error

Modify updates sysctl settings.

func (*SysctlConfigurator) NeedsRecreate

func (c *SysctlConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate returns false - Modify is able to apply any change.

type TrunkPort

type TrunkPort struct {
	AllVIDs bool // Allow all valid VIDs: <2,4093>
	VIDs    []uint16
}

TrunkPort : port carries tagged traffic from multiple VLANs.

type VIF

type VIF struct {
	// HostIfName : name of the interface inside the network stack on the host side.
	HostIfName string
	// NetAdapterName is the logical name for this interface received from the controller
	// in NetworkAdapter.Name.
	// Unique in the scope of the application.
	NetAdapterName string
	// Variant : VIF should be one of the supported variants.
	Variant VIFVariant
}

VIF : virtual interface connecting an application to a network instance. It can be either an external item created by the hypervisor, or an internal item configured by zedrouter.

func (VIF) Dependencies

func (v VIF) Dependencies() (deps []dg.Dependency)

Dependencies returns no dependencies.

func (VIF) Equal

func (v VIF) Equal(other dg.Item) bool

Equal compares two VIF instances.

func (VIF) External

func (v VIF) External() bool

External returns true if VIF is created by the hypervisor.

func (VIF) GetAssignedIPs

func (v VIF) GetAssignedIPs() []*net.IPNet

GetAssignedIPs returns IP addresses assigned (by zedrouter) to the VIF interface.

func (VIF) Label

func (v VIF) Label() string

Label returns the logical label from NetworkAdapter.

func (VIF) Name

func (v VIF) Name() string

Name returns the physical interface name on the host side.

func (VIF) String

func (v VIF) String() string

String describes VIF.

func (VIF) Type

func (v VIF) Type() string

Type of the item.

type VIFConfigurator

type VIFConfigurator struct {
	Log *base.LogObject
}

VIFConfigurator implements Configurator interface for Veth VIF.

func (*VIFConfigurator) Create

func (c *VIFConfigurator) Create(ctx context.Context, item dg.Item) error

Create adds new veth.

func (*VIFConfigurator) Delete

func (c *VIFConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes veth. Should be enough to just remove one side.

func (*VIFConfigurator) Modify

func (c *VIFConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify allows to change assigned IP addresses.

func (*VIFConfigurator) NeedsRecreate

func (c *VIFConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate returns true when anything other that Veth IPs change.

type VIFReference

type VIFReference struct {
	ItemName string
	IfName   string
}

VIFReference : VIF used as the output interface for route.

type VIFVariant

type VIFVariant struct {
	// Enable if VIF is created by an external process (e.g. hypervisor).
	External bool
	// Veth configured by zedrouter between the host and the app (container).
	Veth Veth
}

VIFVariant is like union, only one option should have non-zero value.

type VLANBridge

type VLANBridge struct {
	// BridgeIfName : interface name of the bridge.
	BridgeIfName string
	// EnableVLANFiltering : drop packet if it belongs to a VLAN which is not enabled
	// on the input bridge port (using VLANPort config item).
	EnableVLANFiltering bool
}

VLANBridge : VLAN configuration for a Linux bridge.

func (VLANBridge) Dependencies

func (v VLANBridge) Dependencies() (deps []dg.Dependency)

Dependencies returns the bridge as the only dependency.

func (VLANBridge) Equal

func (v VLANBridge) Equal(other dg.Item) bool

Equal compares two VLANBridge instances.

func (VLANBridge) External

func (v VLANBridge) External() bool

External returns false.

func (VLANBridge) Label

func (v VLANBridge) Label() string

Label for VLANBridge.

func (VLANBridge) Name

func (v VLANBridge) Name() string

Name returns the interface name of the bridge.

func (VLANBridge) String

func (v VLANBridge) String() string

String describes VLANBridge.

func (VLANBridge) Type

func (v VLANBridge) Type() string

Type of the item.

type VLANBridgeConfigurator

type VLANBridgeConfigurator struct {
	Log            *base.LogObject
	NetworkMonitor netmonitor.NetworkMonitor
}

VLANBridgeConfigurator implements Configurator interface (libs/reconciler) for VLAN configuration applied to a Linux bridge.

func (*VLANBridgeConfigurator) Create

func (c *VLANBridgeConfigurator) Create(ctx context.Context, item dg.Item) error

Create applies VLAN configuration to a bridge.

func (*VLANBridgeConfigurator) Delete

func (c *VLANBridgeConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes VLAN configuration from a bridge.

func (*VLANBridgeConfigurator) Modify

func (c *VLANBridgeConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify is not implemented.

func (*VLANBridgeConfigurator) NeedsRecreate

func (c *VLANBridgeConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate returns true - Modify is not implemented.

type VLANConfig

type VLANConfig struct {
	AccessPort *AccessPort
	TrunkPort  *TrunkPort
}

VLANConfig : VLAN configuration to apply on the bridge port. Port is either configured as a trunk or as an access port (use this struct as union).

type VLANPort

type VLANPort struct {
	// BridgeIfName : interface name of the bridge.
	BridgeIfName string
	// PortIfName : interface name of the bridge port.
	PortIfName string
	// VLANConfig : VLAN configuration to apply on the bridged interface.
	VLANConfig VLANConfig
}

VLANPort : VLAN configuration for a Linux bridge port.

func (VLANPort) Dependencies

func (v VLANPort) Dependencies() (deps []dg.Dependency)

Dependencies returns the (VLAN-enabled) bridge and the port as the dependencies.

func (VLANPort) Equal

func (v VLANPort) Equal(other dg.Item) bool

Equal compares two VLANPort instances.

func (VLANPort) External

func (v VLANPort) External() bool

External returns false.

func (VLANPort) Label

func (v VLANPort) Label() string

Label for VLANPort.

func (VLANPort) Name

func (v VLANPort) Name() string

Name returns the interface name of the bridged port (there can be at most one instance of VLANPort associated with a given bridged port).

func (VLANPort) String

func (v VLANPort) String() string

String describes VLANPort.

func (VLANPort) Type

func (v VLANPort) Type() string

Type of the item.

type VLANPortConfigurator

type VLANPortConfigurator struct {
	Log            *base.LogObject
	NetworkMonitor netmonitor.NetworkMonitor
}

VLANPortConfigurator implements Configurator interface (libs/reconciler) for VLAN configuration applied to a Linux bridge port.

func (*VLANPortConfigurator) Create

func (c *VLANPortConfigurator) Create(ctx context.Context, item dg.Item) error

Create applies VLAN configuration to a bridge port.

func (*VLANPortConfigurator) Delete

func (c *VLANPortConfigurator) Delete(ctx context.Context, item dg.Item) error

Delete removes VLAN configuration from a bridge port.

func (*VLANPortConfigurator) Modify

func (c *VLANPortConfigurator) Modify(ctx context.Context, oldItem, newItem dg.Item) (err error)

Modify is not implemented.

func (*VLANPortConfigurator) NeedsRecreate

func (c *VLANPortConfigurator) NeedsRecreate(oldItem, newItem dg.Item) (recreate bool)

NeedsRecreate returns true - Modify is not implemented.

type Veth

type Veth struct {
	ForApp ContainerApp
	// AppIfName : name of the interface inside the network stack on the app side.
	AppIfName string
	// AppIfMAC : MAC address assigned to the Veth interface on the app side.
	AppIfMAC net.HardwareAddr
	// AppIPs : IP addresses assigned to Veth on the app side.
	AppIPs []*net.IPNet
}

Veth : virtual ethernet pair created between the host and the (container) app network namespace.

Jump to

Keyboard shortcuts

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