control

package
Version: v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPathPolicy = &pathpol.Policy{
		ACL: &pathpol.ACL{
			Entries: []*pathpol.ACLEntry{{Action: pathpol.Allow}},
		},
	}
	DefaultPerfPolicy = fingerPrintOrder{}
)

Default policies for session policies.

View Source
var (
	// ErrAlreadyRunning is the error returned when attempting to run a task twice.
	ErrAlreadyRunning = serrors.New("is running")
)

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	// RoutingUpdateChan is the channel that the routing updates will be pushed to.
	RoutingUpdateChan chan (RemoteGateways)
	// ReportingInterval is the interval between producing the reports. If there
	// are no changes, the actual interval may be longer.
	ReportingInterval time.Duration
	// ExpiryInterval means for how long will a gateway instance be reported if it
	// is not renewed.
	ExpiryInterval time.Duration
	// contains filtered or unexported fields
}

Aggregator aggregates prefix announcements and pushes the aggregated structure to the supplied channel.

func (*Aggregator) Close

func (a *Aggregator) Close()

Close stops the internal goroutines.

func (*Aggregator) Prefixes

func (a *Aggregator) Prefixes(remote addr.IA, gateway Gateway, prefixes []*net.IPNet)

Prefixes pushes new set of prefixes for a specific gateway.

func (*Aggregator) Run

func (a *Aggregator) Run() error

Run starts the aggregator. It must only be called once.

type ConfigPublisher

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

ConfigPublisher can be used to send configs to multiple clients via different means (channels, getters).

func (*ConfigPublisher) Publish

func (n *ConfigPublisher) Publish(sp SessionPolicies, rp *routing.Policy)

Publish notifies clients of the Publisher about new configurations. Nil values are allowed and mean the nil config is not published, this is to allow updates of only one config.

func (*ConfigPublisher) RoutingPolicy

func (n *ConfigPublisher) RoutingPolicy() *routing.Policy

RoutingPolicy returns the last routing policy that was published. The returned object is a deep-copy, and can be edited by the caller.

func (*ConfigPublisher) SubscribeRemoteIAs

func (n *ConfigPublisher) SubscribeRemoteIAs() <-chan []addr.IA

SubscribeRemoteIAs returns a channel on which remote IAs will be sent. The channel has capacity 0. If a reader is slow to process the subscription, it will prevent the Publisher from publishing new configurations.

Subscriptions happening prior to a Publish are guaranteed to return the new state read by the NotPublishify.

func (*ConfigPublisher) SubscribeSessionPolicies

func (n *ConfigPublisher) SubscribeSessionPolicies() <-chan SessionPolicies

SubscribeSessionPolicies returns a channel on which new session policies will be sent. The channel has capacity 0. If a reader is slow to process the subscription, it will prevent the Publisher from publishing new configurations.

Subscriptions happening prior to a Publish are guaranteed to return the new state read by the NotPublishify.

type DataplaneSession

type DataplaneSession interface {
	PktWriter
	// SetPath can be used to change the path on which packets are sent. If the path is invalid
	// or causes MTU issues, an error is returned.
	SetPath(snet.Path) error
	// Close informs the session it should shut down. It does not wait for the session to close.
	Close()
}

DataplaneSession represents a packet framer sending packets along a specific path.

type DataplaneSessionFactory

type DataplaneSessionFactory interface {
	New(sessID uint8, policyID int, remoteIA addr.IA, remoteAddr net.Addr) DataplaneSession
}

DataplaneSessionFactory is used to construct a data-plane session with a specific ID towards a remote.

type DefaultEngineFactory

type DefaultEngineFactory struct {
	// PathMonitor is used by engines to construct registrations for path discovery.
	PathMonitor PathMonitor

	// ProbeConnFactory is used by engines to construct connections for sending and receiving probe
	// packets.
	ProbeConnFactory PacketConnFactory

	// DataplaneSessionFactory is used to construct dataplane sessions.
	DataplaneSessionFactory DataplaneSessionFactory

	// Logger is used by engines to write messages about internal operation. If nil,
	// no logging messages are printed. Child engines will inherit this logger.
	Logger log.Logger

	// Metrics contains the metrics that will be modified during engine operation. If empty, no
	// metrics are reported.
	Metrics EngineMetrics
}

DefaultEngineFactory is a template for creating control-plane routing engines.

func (*DefaultEngineFactory) New

func (f *DefaultEngineFactory) New(table RoutingTable,
	sessions []*SessionConfig, routingTableIndices map[int][]uint8) Worker

type DiagnosticsWriter

type DiagnosticsWriter interface {
	DiagnosticsWrite(io.Writer)
}

type Discoverer

type Discoverer interface {
	Gateways(ctx context.Context) ([]Gateway, error)
}

Discoverer discovers gateway instances. It must be scoped to the intended remote for the GatewayWatcher.

type Engine

type Engine struct {
	// SessionConfigs contains the configurations of sessions that are part of the context.
	SessionConfigs []*SessionConfig

	// RoutingTable contains the routing object that updates should be pushed to.
	RoutingTable RoutingTable

	// RoutingTableIndices maps routing table indices to the list of eligible
	// sessions, sorted by priority.
	RoutingTableIndices map[int][]uint8

	// PathMonitor is used to construct registrations for path discovery.
	// Run will return an error if the PathMonitor is nil.
	PathMonitor PathMonitor

	// ProbeConnFactory constructs connections to be used for sending and receiving probe packets.
	// Run will return an error if ProbeConnFactory is nil.
	ProbeConnFactory PacketConnFactory

	// DataplaneSessionFactory is used to construct dataplane sessions.
	DataplaneSessionFactory DataplaneSessionFactory

	// Logger to be passed down to worker goroutines. If nil, logging is disabled.
	Logger log.Logger

	// Metrics are the metrics which are modified during the operation of the engine.
	// If empty, no metrics are reported.
	Metrics EngineMetrics
	// contains filtered or unexported fields
}

Engine contains an entire routing context for the current control-plane configuration. It constructs channels between components, starts session goroutines, and runs the router.

func (*Engine) Close

func (e *Engine) Close() error

Close stops all internal goroutines and waits for them to finish.

func (*Engine) DiagnosticsWrite

func (e *Engine) DiagnosticsWrite(w io.Writer)

DiagnosticsWrite writes diagnostics to the writer.

func (*Engine) Run

func (e *Engine) Run() error

Run constructs the necessary channels, starts session goroutines and runs the router. It returns when the context terminates.

func (*Engine) Status

func (e *Engine) Status(w io.Writer)

Status prints the status page to the writer.

type EngineController

type EngineController struct {
	// ConfigurationUpdates is the channel on which new configurations for the Gateway sessions
	// are received. Every update will lead to a fresh instance of the forwarding engine,
	// together with a new data-plane configuration. The channel must not be nil.
	ConfigurationUpdates <-chan []*SessionConfig

	// RoutingTableSwapper permits the concurrency-safe swapping of an entire routing table in the
	// data-plane. When the session builder creates a new control-plane engine, it creates a fresh
	// routing table. Once the engine is ready, the fresh routing table is swapped in place of the
	// old one. It must not be nil.
	RoutingTableSwapper RoutingTableSwapper

	// RoutingTableFactory is used by the engine controller to create a fresh routing table.
	// It must not be nil.
	RoutingTableFactory RoutingTableFactory

	// EngineFactory is used to build new engines. It must not be nil.
	EngineFactory EngineFactory

	// SwapDelay is the interval between creating a new engine and setting it to be the active
	// engine. If 0, the new engine is immediately swapped in.
	SwapDelay time.Duration

	// Logger is used by the controller to write messages about internal operation. If nil,
	// no logging messages are printed.
	Logger log.Logger
	// contains filtered or unexported fields
}

EngineController listens to session configuration updates received from the configuration modules. There are no partial updates; once a new configuration comes in, the EngineController creates a new engine and replaces the old one.

The EngineController is expected to run for the lifetime of the application and does not support shutdown.

Add factories to this type if required for testing.

func (*EngineController) DiagnosticsWrite

func (c *EngineController) DiagnosticsWrite(w io.Writer)

DiagnosticsWrite writes diagnostics to the writer.

func (*EngineController) Run

func (c *EngineController) Run() error

Run starts listening on the channel for updates, and processing existing updates.

func (*EngineController) Status

func (c *EngineController) Status(w io.Writer)

Status prints the status page.

type EngineFactory

type EngineFactory interface {
	New(table RoutingTable, sessions []*SessionConfig, routingTableIndices map[int][]uint8) Worker
}

EngineFactory can be used to create a control-plane engine for a set of session configurations. The engine will push updates to the routing table.

type EngineMetrics

type EngineMetrics struct {
	SessionMonitorMetrics SessionMonitorMetrics
}

EngineMetrics aggregates the metrics used by various control-plane engine components.

type Event

type Event int

Event describes a health check event.

const (
	EventDown Event = iota
	EventUp
)

The different Event values.

type Gateway

type Gateway struct {
	// Control contains the control-plane address of the remote gateway.
	Control *net.UDPAddr
	// Probe contains the probing address of the remote gateway.
	Probe *net.UDPAddr
	// Data contains the data-plane address of the remote gateway.
	Data *net.UDPAddr
	// Interfaces are the last-hop SCION interfaces that should be preferred.
	Interfaces []uint64
}

Gateway represents a remote gateway instance.

func (Gateway) Equal

func (g Gateway) Equal(other Gateway) bool

type GatewayWatcher

type GatewayWatcher struct {
	// Remote is the remote AS to watch.
	Remote addr.IA
	// Discoverer is used for remote gateway discovery. It must not be nil.
	Discoverer Discoverer
	// DiscoverInterval is the time between consecutive gateway discovery
	// attempts. If zero, this defaults to 5 seconds.
	DiscoverInterval time.Duration
	// DiscoverTimeout is the timout for an individual gateway discovery
	// attempts. If zero, this defaults to 5 seconds.
	DiscoverTimeout time.Duration
	// Template serves as the template for the PrefixWatcher tasks that are
	// spawned. For each discovered gateway, a PrefixWatcher task is started
	// based on this template.
	Template PrefixWatcherConfig
	// Metrics can be used to report information about discovered remote gateways. If not
	// initialized, no metrics will be reported.
	Metrics GatewayWatcherMetrics
	// contains filtered or unexported fields
}

GatewayWatcher watches gateways in a specific remote AS.

Per discovered gateway, the watcher starts a PrefixWatcher that periodically polls the IP prefixes served by that gateway. The PrefixWatcher tasks are dynamically added and removed depending on the gateway discovery responses. The delta in the list of gateways is assumed to be empty, if a discovery attempt fails.

When the GatewayWatcher is stopped, all spawaned PrefixWatcher tasks are stopped as well.

func (*GatewayWatcher) Run

func (w *GatewayWatcher) Run(ctx context.Context) error

Run watches the remote for gateways. This method blocks until the context expires, or an irrecoverable error is encountered.

type GatewayWatcherFactory

type GatewayWatcherFactory interface {
	New(addr.IA, GatewayWatcherMetrics) Runner
}

type GatewayWatcherMetrics

type GatewayWatcherMetrics struct {
	// Remotes is the number of remote gateways discovered in the remote AS.
	Remotes metrics.Gauge
}

GatewayWatcherMetrics contains the metrics the GatewayWatcher reports.

type LegacySessionPolicyAdapter

type LegacySessionPolicyAdapter struct{}

LegacySessionPolicyAdapter parses the legacy gateway JSON configuration and adapts it into the session policies format.

func (LegacySessionPolicyAdapter) Parse

Parse parses the raw JSON into a SessionPolicies struct.

type PacketConnFactory

type PacketConnFactory interface {
	New() (net.PacketConn, error)
}

PacketConnFactory is used to construct net.PacketConn objects for control-plane communication.

type PathMonitor

type PathMonitor interface {
	Register(ia addr.IA, policies *policies.Policies, policyID int) PathMonitorRegistration
}

PathMonitor is used to construct registrations for path discovery.

type PathMonitorRegistration

type PathMonitorRegistration interface {
	Get() pathhealth.Selection
	Close()
}

PathMonitorRegistration provides access to the paths.

type PktWriter

type PktWriter interface {
	Write([]byte)
}

PktWriter is the interface exposed by a data-plane session for forwarding packets.

type PrefixConsumer

type PrefixConsumer interface {
	Prefixes(remote addr.IA, gateway Gateway, prefixes []*net.IPNet)
}

PrefixConsumer consumes the prefixes fetched by the PrefixWatcher.

type PrefixFetcher

type PrefixFetcher interface {
	Prefixes(ctx context.Context, gateway *net.UDPAddr) ([]*net.IPNet, error)
}

PrefixFetcher fetches the IP prefixes from a remote gateway.

type PrefixWatcherConfig

type PrefixWatcherConfig struct {
	// Consumer consume the fetched prefixes. Its methods are called
	// synchroniously and should return swiftly.
	Consumer PrefixConsumer
	// PrefixFetcher is used to fetch IP prefixes from the remote gateway.
	Fetcher PrefixFetcher
	// PollInterval is the time between consecutive poll attempts. If zero, this
	// defaults to 5 seconds.
	PollInterval time.Duration
	// PollTimeout is the timout for an individual poll attempts. If zero, this
	// defaults to 5 seconds.
	PollTimeout time.Duration
}

PrefixWatcherConfig configures a prefix watcher that watches IP prefixes advertised by a remote gateway. The discovered IP prefixes are advertised to the prefix consumer. The watcher is stateless and does not keep track of previously discovered IP prefixes.

type PrefixesFilter

type PrefixesFilter struct {
	// LocalIA is that IA this filter is running in. It is used as from value in
	// the routing policy check.
	LocalIA addr.IA
	// Consumer is the component that consumes prefixes that are not filtered
	// out.
	Consumer PrefixConsumer
	// PolicyProvider is the provider of routing policies, must not be nil.
	PolicyProvider RoutingPolicyProvider
	// Metrics can be used to report information about accepted and rejected IP prefixes. If not
	// initialized, no metrics will be reported.
	Metrics PrefixesFilterMetrics
}

PrefixesFilter is a prefix consumer that only forwards calls that are accepted by the current routing policy.

func (PrefixesFilter) Prefixes

func (f PrefixesFilter) Prefixes(remote addr.IA, gateway Gateway, prefixes []*net.IPNet)

Prefixes consumes the prefixes, if they are accepted by the policy they are forwarded to the registered consumer.

type PrefixesFilterMetrics

type PrefixesFilterMetrics struct {
	PrefixesAccepted metrics.Gauge
	PrefixesRejected metrics.Gauge
}

type RemoteGateway

type RemoteGateway struct {
	// Gateway contains the gateway specific information.
	Gateway Gateway
	// Prefixes is the list of prefixes served by this gateway.
	Prefixes []*net.IPNet
}

RemoteGateway is an entry for a single remote gateway.

type RemoteGateways

type RemoteGateways struct {
	Gateways map[addr.IA][]RemoteGateway
}

RemoteGateways defines the current discovered routing state.

type RemoteMonitor

type RemoteMonitor struct {
	// GatewayWatcherFactory is used to create remote gateway watchers.
	GatewayWatcherFactory GatewayWatcherFactory
	// IAs is a channel that is notified with the full set of IAs to watch.
	IAs <-chan []addr.IA
	// Logger is the logger to use. If set to nil, no logging will be done.
	Logger log.Logger
	// RemotesMonitored is the number of remote gateways discovered. If nil, no metric is reported.
	RemotesMonitored metrics.Gauge
	// contains filtered or unexported fields
}

RemoteMinitor watches for currently monitored remote ASes and creates GatewayWatchers accordingly. For all new IAs that weren't seen before new GatewayWatcher is created. For all IAs that were seen before but are not present in an update the corresponding GatewayWatcher is stopped.

func (*RemoteMonitor) Close

func (rm *RemoteMonitor) Close() error

func (*RemoteMonitor) Run

func (rm *RemoteMonitor) Run() error

type RouteExporter

type RouteExporter interface {
	// AddNetwork will export network to another routing backend. Duplicates are a no-op.
	AddNetwork(network net.IPNet)
	// DeleteNetwork will delete a network from another routing backend. If the network
	// doesn't exist, the deletion is a silent no-op. Only a network that is an exact
	// match (network address + subnet mask) is removed.
	DeleteNetwork(network net.IPNet)
}

RouteExporter is the interface for announcing prefixes to other routing backends.

type Router

type Router struct {
	// RoutingTable is the dataplane routing table.
	RoutingTable RoutingTableWriter
	// RoutingTableIndices maps a routing table index to a priority-ordered list
	// of session ids.
	RoutingTableIndices map[int][]uint8
	// DataplaneSessions are the dataplane sessions.
	DataplaneSessions map[uint8]PktWriter
	// Events is the channel that session events are read from. Note that
	// session IDs sent in this channel must be associated with a session in the
	// session groups.
	Events <-chan SessionEvent
	// Logger is the logger to use. If nil no logs are written.
	Logger log.Logger
	// contains filtered or unexported fields
}

Router contains is a session-health-aware routing table builder that manages the data-plane routing table.

func (*Router) Close

func (r *Router) Close() error

Close stops all internal goroutines.

func (*Router) DiagnosticsWrite

func (r *Router) DiagnosticsWrite(w io.Writer)

DiagnosticsWrite writes diagnostics for the router to the writer.

func (*Router) Run

func (r *Router) Run() error

Run informs the router to start reading events from its event channel and push updates to the data-plane router. It returns when the router terminates.

type RoutingChain

type RoutingChain struct {
	// RemoteIA is the remote ISD-AS to which this routing chain routes, it is
	// set for informational purposes.
	RemoteIA addr.IA
	// The list of prefixes, the order is not relevant.
	Prefixes []*net.IPNet
	// TrafficMatchers defines the traffic matchers in this routing chain. The
	// matchers are evaluated in order within the chain.
	TrafficMatchers []TrafficMatcher
}

RoutingChain defines a chain in the routing table. It links a list of prefixes and a traffic class chain, defined via the TrafficMatchers list.

type RoutingPolicyProvider

type RoutingPolicyProvider interface {
	RoutingPolicy() *routing.Policy
}

RoutingPolicyProvider provides the current active routing policy.

type RoutingTable

type RoutingTable interface {
	RoutingTableReader
	RoutingTableWriter
}

RoutingTable is the dataplane routing table as seen from the control plane.

type RoutingTableFactory

type RoutingTableFactory interface {
	// New should create a routing table based on the routing chains. The
	// implementation must implement a 2 level based routing: 1. it must do a
	// longest prefix match over all prefixes, 2. for the selected prefix it
	// must evaluate the corresponding traffic matcher list, the first match
	// must be selected.
	New([]*RoutingChain) (RoutingTable, error)
}

RoutingTableFactory is used by the engine controller to create a fresh routing table.

type RoutingTableReader

type RoutingTableReader interface {
	RouteIPv4(pkt layers.IPv4) PktWriter
	RouteIPv6(pkt layers.IPv6) PktWriter
}

RoutingTableReader contains the read operations of a data-plane routing table.

type RoutingTableSwapper

type RoutingTableSwapper interface {
	SetRoutingTable(RoutingTable)
}

RoutingTableSwapper is a concurrency-safe setter for a routing table's entire state.

type RoutingTableWriter

type RoutingTableWriter interface {
	// AddRoute sets the session for the routing table index. It replaces an
	// existing session if there is already one for this index. The method
	// returns an error if the index is not known. If session is nil the method
	// returns an error.
	AddRoute(index int, session PktWriter) error
	// DelRoute removes any session for the given index. If there is no
	// session for the given index it is a no-op. The method returns an
	// error if the index is not known.
	DelRoute(index int) error
}

RoutingTableWriter contains the write operations of a data-plane routing table.

type Runner

type Runner interface {
	// Run is blocking  and can be concelled via the context.
	Run(context.Context) error
}

Runner represents a runnable task.

type Session

type Session struct {
	// ID is the ID of the session. It's used for debugging and the status page.
	ID uint8
	// RemoteIA is the remote RemoteIA.
	RemoteIA addr.IA

	// Events is used by the Session to announce changes in health (i.e., remote gateway unreachable
	// or reachable). A Session starts in a Down state (for which no event is sent), and should
	// announce it is up when it is healthy.
	//
	// Run will return an error if Events is nil.
	Events chan<- SessionEvent

	// SessionMonitorEvents is the channel on each events from the session monitor arrive.
	// Close this channel to shut down the Session.
	//
	// Run will return an error if SessionMonitorEvents is nil.
	SessionMonitorEvents <-chan SessionEvent

	// PathMonitorRegistration is used to access paths from the path monitor.
	//
	// Run will return an error if Paths is nil.
	PathMonitorRegistration PathMonitorRegistration

	// PathMonitorPollInterval sets how often the path should be read from the path monitor.
	// If 0, the path monitor is only queried when the session monitor reports a state
	// change to up.
	PathMonitorPollInterval time.Duration

	// DataplaneSession points to the data-plane session managed by this control-plane session.
	//
	// Run will return an error if DataplaneSession is nil.
	DataplaneSession DataplaneSession

	// Logger is the logger to use. If nil no logs are written.
	Logger log.Logger
	// contains filtered or unexported fields
}

Session represents a point-to-point association with a remote gateway that is subject to a path policy.

Once the session is started, up and down events are read from the session monitor and forwarded on the events channel.

If the reader of the events channel is slow, Session internals might block to avoid the event being lost.

func (*Session) Run

func (s *Session) Run() error

Run starts the health checking for the remote gateway. It returns when the session terminates.

type SessionConfig

type SessionConfig struct {
	// ID is the 1-byte session identifier that will be used to identify packets
	// on the wire.
	ID uint8
	// PolicyID is the ID of the SessionPolicy that lead to the creation of the SessionConfig.
	PolicyID int
	// IA is the ISD-AS number of the remote AS.
	IA addr.IA
	// TrafficMatcher contains the conditions the IP traffic must satisfy to use
	// this session.
	TrafficMatcher pktcls.Cond
	// PerfPolicy specifies which paths should be preferred (e.g., the path with
	// the lowest latency). If unset, paths with the lowest latency are
	// preferred.
	PerfPolicy policies.PerfPolicy
	// PathPolicy specifies the path properties that paths used for this session
	// must satisfy.
	PathPolicy policies.PathPolicy
	// Gateway describes a discovered remote gateway instance.
	Gateway Gateway
	// Prefixes contains the network prefixes that are reachable through this
	// session.
	Prefixes []*net.IPNet
}

SessionConfig contains the data that describes a control-plane session.

type SessionConfigurator

type SessionConfigurator struct {
	// SessionPolicies is the channel from which traffic policy updates are read.
	SessionPolicies <-chan SessionPolicies
	// RoutingUpdates is the channel from which routing update information is
	// read.
	RoutingUpdates <-chan RemoteGateways
	// SessionConfigurations is the channel where new configurations are
	// published.
	SessionConfigurations chan<- []*SessionConfig
	// Logger is used to log informations during processing. If it is nil
	// nothing is logged.
	Logger log.Logger
	// contains filtered or unexported fields
}

SessionConfigurator builds session configurations from the static traffic policy and the dynamic information from the discovery service.

func (*SessionConfigurator) Close

func (sc *SessionConfigurator) Close() error

Close stops the session configurator.

func (*SessionConfigurator) DiagnosticsWrite

func (sc *SessionConfigurator) DiagnosticsWrite(w io.Writer)

DiagnosticsWrite writes diagnostics to the writer.

func (*SessionConfigurator) Run

func (sc *SessionConfigurator) Run() error

Run informs the session configurator to start reading from its input channels and push updates on the configuration channel. It returns when the configurator terminates.

type SessionEvent

type SessionEvent struct {
	// SessionID contains the ID of the session announcing the event.
	SessionID uint8
	// Event signals whether the Session went up or down.
	Event Event
}

SessionEvent is used by the session to inform other components of changes to health.

type SessionMonitor

type SessionMonitor struct {
	// ID is the ID of the session. It's used in the probe packet and for
	// diagnostics.
	ID uint8
	// RemoteIA is the remote RemoteIA the gateway to monitor is in.
	RemoteIA addr.IA
	// ProbeAddr is the probe address of the remote gateway instance.
	ProbeAddr *net.UDPAddr
	// Events is the channel where the monitor events are published to. Note
	// that an event is only published on change. The SessionMonitor will
	// close the events channel when it shuts down.
	Events chan<- SessionEvent
	// Paths is used to access paths from the path monitor.
	Paths PathMonitorRegistration
	// ProbeConn is the connection that is used to send and receive probe
	// packets.
	ProbeConn net.PacketConn
	// ProbeInterval is the interval at which the remote is probed. Can be left
	// zero and a default value will be used.
	ProbeInterval time.Duration
	// HealthExpiration is the duration after the last successful probe after
	// which a remote is considered unhealthy.
	HealthExpiration time.Duration
	// Metrics are the metrics which are modified during the operation of the
	// monitor. If empty no metrics are reported.
	Metrics SessionMonitorMetrics
	// Logger is the logger to use. If nil no logs are written.
	Logger log.Logger
	// contains filtered or unexported fields
}

SessionMonitor monitors a session with a remote gateway instance.

func (*SessionMonitor) Close

func (m *SessionMonitor) Close() error

Close stops the session monitor.

func (*SessionMonitor) Run

func (m *SessionMonitor) Run() error

Run runs the session monitor. It blocks until Close is called..

type SessionMonitorMetrics

type SessionMonitorMetrics struct {
	// Probes is the number of sent probes.
	Probes metrics.Counter
	// ProbeReplies is the number of probe replies received.
	ProbeReplies metrics.Counter
}

SessionMonitorMetrics contains the metrics for the session monitor.

type SessionPolicies

type SessionPolicies []SessionPolicy

SessionPolicies is a list of session policies.

func LoadSessionPolicies

func LoadSessionPolicies(file string, parser SessionPolicyParser) (SessionPolicies, error)

LoadSessionPolicies loads the session policies from the given file, and parses it with the given parser.

func (SessionPolicies) Copy

Copy creates a deep copy of the session policies.

func (SessionPolicies) RemoteIAs

func (p SessionPolicies) RemoteIAs() []addr.IA

RemoteIAs returns all IAs that are in the session policies.

type SessionPolicy

type SessionPolicy struct {
	// IA is the ISD-AS number of the remote AS.
	IA addr.IA
	// ID identifies a session policy to a remote AS, i.e., the tuple (IA, ID) is unique.
	ID int
	// TrafficMatcher contains the conditions the IP traffic must satisfy to use
	// this session.
	TrafficMatcher pktcls.Cond
	// PerfPolicy specifies which paths should be preferred (e.g., the path with
	// the lowest latency). If unset, paths with the lowest latency are
	// preferred.
	PerfPolicy policies.PerfPolicy
	// PathPolicy specifies the path properties that paths used for this session
	// must satisfy.
	PathPolicy policies.PathPolicy
	// PathCount  defines the number of paths that can be simultaneously used
	// within a session.
	PathCount int
	// Prefixes contains the network prefixes that are reachable through this
	// session.
	Prefixes []*net.IPNet
}

SessionPolicy specifies the policy for a session towards a remote AS. The policy for a session consists of a - remote IA, identifying the remote this policy is for, - policy id, together with the remote IA uniquely identifying the policy, - traffic class, defined by a traffic matcher, - a path class defined by a path policy, - a performance policy, - a path count, - a remote IA, - a set of prefixes.

func (SessionPolicy) Copy

func (sp SessionPolicy) Copy() SessionPolicy

Copy creates a deep copy.

type SessionPolicyParser

type SessionPolicyParser interface {
	Parse([]byte) (SessionPolicies, error)
}

SessionPolicyParser parses a raw session policy.

type TrafficMatcher

type TrafficMatcher struct {
	ID      int
	Matcher pktcls.Cond
}

TrafficMatcher is a traffic matcher with an ID.

type Worker

type Worker interface {
	// Run starts the worker's task and blocks until the worker has finished or it has been
	// shut down via Close.
	Run() error
	// Close stops a running worker. If called before the worker has started, the worker
	// will skip its task. In this case, both Run and Close will return nil.
	Close() error
}

Worker is a generic interface for goroutines used by the control-plane.

Directories

Path Synopsis
mock_grpc
Package mock_grpc is a generated GoMock package.
Package mock_grpc is a generated GoMock package.
Package mock_control is a generated GoMock package.
Package mock_control is a generated GoMock package.

Jump to

Keyboard shortcuts

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