nistate

package
v0.0.0-...-4b7dea8 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package nistate (Network Instance State) is used by zedrouter to collect state data and metrics for Network Instances and watch for state changes. The main entry point is the interface of Collector, which is expected to eventually have multiple implementations, one for every supported network stack (currently EVE only provides one implementation of network instances, built using the Linux bridge).

Index

Constants

View Source
const LogAndErrPrefix = "NI State"

LogAndErrPrefix is prepended to every log message and error returned by NI State Collector so that they are easy to filter in log file.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppVIF

type AppVIF struct {
	// App : application UUID.
	App uuid.UUID
	// NI : UUID of the network instance to which the application is connected through
	// this virtual interface.
	NI uuid.UUID
	// AppNum : a positive integer number (>0) allocated for the application by zedrouter.
	// This number is persisted and doesn't change across app config changes or node
	// reboots.
	AppNum int
	// NetAdapterName is the logical name for this interface received from the controller
	// in NetworkAdapter.Name
	NetAdapterName string
	// HostIfName : host-side name of the interface connecting application (guest)
	// with EVE OS (host). This name is generated by zedrouter.
	HostIfName string
	// GuestIfMAC : MAC address assigned to VIF on the guest side (inside the app).
	GuestIfMAC net.HardwareAddr
}

AppVIF : describes interface created to connect application with network instance. This comes from zedrouter.

type Collector

type Collector interface {
	// StartCollectingForNI : start collecting state data for the given network instance.
	// It is called by zedrouter whenever a new network instance is configured.
	StartCollectingForNI(
		niConfig types.NetworkInstanceConfig, br NIBridge, vifs []AppVIF,
		enableArpSnoop bool) error

	// UpdateCollectingForNI : update state data collecting process to reflect a change
	// in the network or app instance config.
	// It is called by zedrouter whenever a config of an existing network instance changes
	// or when VIF is (dis)connected to/from the NI.
	// Note that not every change in network instance config is supported. For example,
	// network instance type (switch / local) cannot change.
	UpdateCollectingForNI(
		niConfig types.NetworkInstanceConfig, vifs []AppVIF) error

	// StopCollectingForNI : stop collecting state data for network instance.
	// It is called by zedrouter whenever a network instance is about to be deleted.
	StopCollectingForNI(niID uuid.UUID) error

	// GetIPAssignments returns information about currently assigned IP addresses
	// to VIFs connected to a given network instance.
	GetIPAssignments(niID uuid.UUID) (VIFAddrsList, error)

	// WatchIPAssignments : watch for changes in IP assignments to VIFs across
	// all network instances enabled for state collecting.
	// Channel type is a slice of VIF address updates - this is used to publish
	// multiple updates in a bulk for efficiency.
	WatchIPAssignments() <-chan []VIFAddrsUpdate

	// GetNetworkMetrics : get statistics (interface, ACL counters) for all
	// network interfaces.
	// This should actually include not only interfaces created for network instances
	// by zedrouter, but also wireless physical ports and bridges created for wired
	// ports by NIM.
	GetNetworkMetrics() (types.NetworkMetrics, error)

	// WatchFlows : get periodic statistics for network flows established between
	// applications and remote endpoints.
	WatchFlows() <-chan types.IPFlow
}

Collector collects and publishes state data of monitored network instances (IP address assignments, network flows, interface counters, etc.). This is just an interface and the expectation is that there will be one implementation for every natively supported network stack.

type ErrUnknownNI

type ErrUnknownNI struct {
	NI uuid.UUID
}

ErrUnknownNI is returned for requests targeting network instances not known to the state collector.

func (ErrUnknownNI) Error

func (e ErrUnknownNI) Error() string

Error implements the error interface.

type LinuxCollector

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

LinuxCollector implements state data collecting for network instances configured inside the Linux network stack (using the Linux bridge).

func NewLinuxCollector

func NewLinuxCollector(log *base.LogObject) *LinuxCollector

NewLinuxCollector is a constructor for LinuxCollector.

func (*LinuxCollector) GetIPAssignments

func (lc *LinuxCollector) GetIPAssignments(niID uuid.UUID) (VIFAddrsList, error)

GetIPAssignments returns information about currently assigned IP addresses to VIFs connected to a given network instance.

func (*LinuxCollector) GetNetworkMetrics

func (lc *LinuxCollector) GetNetworkMetrics() (types.NetworkMetrics, error)

GetNetworkMetrics : get statistics (interface, ACL counters) for all network interfaces. This actually includes not only interfaces created for network instances by zedrouter, but also wireless physical ports and bridges created for wired ports by NIM.

func (*LinuxCollector) StartCollectingForNI

func (lc *LinuxCollector) StartCollectingForNI(
	niConfig types.NetworkInstanceConfig, br NIBridge, vifs []AppVIF, enableARPSnoop bool) error

StartCollectingForNI : start collecting state data for the given network instance. It is called by zedrouter whenever a new network instance is configured.

func (*LinuxCollector) StopCollectingForNI

func (lc *LinuxCollector) StopCollectingForNI(niID uuid.UUID) error

StopCollectingForNI : stop collecting state data for network instance. It is called by zedrouter whenever a network instance is about to be deleted.

func (*LinuxCollector) UpdateCollectingForNI

func (lc *LinuxCollector) UpdateCollectingForNI(
	niConfig types.NetworkInstanceConfig, vifs []AppVIF) error

UpdateCollectingForNI : update state data collecting process to reflect a change in the network instance config. It is called by zedrouter whenever a config of an existing network instance changes or when VIF is (dis)connected to/from the NI. Note that not every change in network instance config is supported. For example, network instance type (switch / local) cannot change.

func (*LinuxCollector) WatchFlows

func (lc *LinuxCollector) WatchFlows() <-chan types.IPFlow

WatchFlows : get periodic statistics for network flows established between applications and remote endpoints.

func (*LinuxCollector) WatchIPAssignments

func (lc *LinuxCollector) WatchIPAssignments() <-chan []VIFAddrsUpdate

WatchIPAssignments : watch for changes in IP assignments to VIFs across all network instances enabled for state collecting.

type NIBridge

type NIBridge struct {
	// NI : UUID of the network instance.
	NI uuid.UUID
	// BrNum : a positive integer number (>0) allocated for the bridge by zedrouter.
	// This number is persisted and doesn't change across app config changes or node
	// reboots.
	BrNum int
	// BrIfName : name of the bridge interface inside the network stack.
	BrIfName string
	// BrIfMAC : MAC address assigned to the bridge.
	// MAC address is generated by zedrouter from BrNum.
	BrIfMAC net.HardwareAddr
}

NIBridge : describes bridge created for a network instance. This comes from zedrouter.

type VIFAddrs

type VIFAddrs struct {
	types.AssignedAddrs
	VIF AppVIF
}

VIFAddrs lists IP addresses assigned to a VIF on the guest side (inside the app). This is provided to zedrouter by Collector.

func (VIFAddrs) HasIP

func (vif VIFAddrs) HasIP(ip net.IP) bool

HasIP returns true if the given IP address is assigned to this VIF.

type VIFAddrsList

type VIFAddrsList []VIFAddrs

VIFAddrsList : list of VIFs with addresses assigned to them.

func (VIFAddrsList) LookupByAdapterName

func (vifs VIFAddrsList) LookupByAdapterName(
	appID uuid.UUID, adapterName string) *VIFAddrs

LookupByAdapterName : Lookup VIF by the Application UUID and VIF adapter name.

func (VIFAddrsList) LookupByGuestMAC

func (vifs VIFAddrsList) LookupByGuestMAC(mac net.HardwareAddr) *VIFAddrs

LookupByGuestMAC : Lookup VIF by the MAC address of the guest interface.

func (VIFAddrsList) LookupByIP

func (vifs VIFAddrsList) LookupByIP(ip net.IP) *VIFAddrs

LookupByIP : Lookup VIF by the IP address assigned to the guest interface. Returns first match.

type VIFAddrsUpdate

type VIFAddrsUpdate struct {
	Prev VIFAddrs
	New  VIFAddrs
}

VIFAddrsUpdate describes a change in the address assignment for a single VIF. Prev.VIF and New.VIF are always the same. This is provided to zedrouter by Collector.

Jump to

Keyboard shortcuts

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