ifstate

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package ifstate implements the interface state in memory structure as well as related tasks and handlers.

Interface state

The interface state is stored in the Interfaces struct it can be created by calling the NewInterfaces constructor. The state of a specific interface is stored in the Interface struct.

Revoker

The revoker is a periodic task that revokes interfaces that have timed out and renews revocations of already revoked interfaces. Create it with the NewRevoker costructor.

Handler

The handler handles interface state requests. It can be instantiated with the NewHandler constructor.

Index

Constants

View Source
const (
	// DefaultKeepaliveInterval is the default time between sending IFID
	// keepalive packets to the neighbor.
	DefaultKeepaliveInterval = time.Second
	// DefaultKeepaliveTimeout specifies the default for how long an interface
	// can receive no IFID keepalive packets until it is considered expired.
	DefaultKeepaliveTimeout = 3 * DefaultKeepaliveInterval
)

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(intfs *Interfaces) infra.Handler

NewHandler creates interface state request handler.

Types

type Collector

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

Collector implements a prometheus collector that exports the state of all interfaces.

func NewCollector

func NewCollector(intfs *Interfaces) *Collector

NewCollector creates a prometheus collector that exports the state of all interfaces.

func (*Collector) Collect

func (c *Collector) Collect(mc chan<- prometheus.Metric)

Collect is called by prometheus to get interface status

func (*Collector) Describe

func (c *Collector) Describe(dc chan<- *prometheus.Desc)

Describe is called by prometheus to get description

type Config

type Config struct {
	// KeepaliveTimeout specifies for how long an interface can receive no
	// IFID keepalive packets until it is considered expired.
	KeepaliveTimeout time.Duration
}

Config enables configuration of the interfaces.

func (*Config) InitDefaults

func (c *Config) InitDefaults()

InitDefaults initializes the config fields that are not set to the default values.

type Interface

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

Interface keeps track of the interface state.

func (*Interface) Activate

func (intf *Interface) Activate(remote common.IFIDType) State

Activate activates the interface the keep alive is received from when necessary, and sets the remote interface id. The return value indicates the previous state of the interface.

func (*Interface) Expire

func (intf *Interface) Expire() bool

Expire checks whether the interface has not been activated for a certain amount of time. If that is the case and the current state is inactive or active, the state changes to Expired. The times for last beacon origination and propagation are reset to the zero value. The return value indicates, whether the state is expired or revoked when the call returns.

func (*Interface) LastOriginate

func (intf *Interface) LastOriginate() time.Time

LastOriginate indicates the last time this interface has been originated on.

func (*Interface) LastPropagate

func (intf *Interface) LastPropagate() time.Time

LastPropagate indicates the last time this interface has been propagated on.

func (*Interface) Originate

func (intf *Interface) Originate(now time.Time)

Originate sets the time this interface has been originated on last.

func (*Interface) Propagate

func (intf *Interface) Propagate(now time.Time)

Propagate sets the time this interface has been propagated on last.

func (*Interface) Revocation

func (intf *Interface) Revocation() *path_mgmt.SignedRevInfo

Revocation returns the revocation.

func (*Interface) Revoke

func (intf *Interface) Revoke(rev *path_mgmt.SignedRevInfo) error

Revoke changes the state of the interface to revoked and updates the revocation, unless the current state is active. In that case, the interface has been activated in the meantime and should not be revoked. This is indicated through an error.

func (*Interface) State

func (intf *Interface) State() State

State returns the current state of the interface.

func (*Interface) TopoInfo

func (intf *Interface) TopoInfo() topology.IFInfo

TopoInfo returns the topology information.

type Interfaces

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

Interfaces keeps track of all interfaces of the AS.

func NewInterfaces

func NewInterfaces(ifInfomap topology.IfInfoMap, cfg Config) *Interfaces

NewInterfaces initializes the the interfaces with the provided interface info map.

func (*Interfaces) All

func (intfs *Interfaces) All() map[common.IFIDType]*Interface

All returns a copy of the map from interface id to interface.

func (*Interfaces) Get

func (intfs *Interfaces) Get(ifid common.IFIDType) *Interface

Get returns the interface for the specified id, or nil if not present.

func (*Interfaces) Reset

func (intfs *Interfaces) Reset()

Reset resets all interface states to inactive. This should be called by the beacon server if it is elected leader.

func (*Interfaces) Update

func (intfs *Interfaces) Update(ifInfomap topology.IfInfoMap)

Update updates the interface mapping. Interfaces no longer present in the topology are removed. The state of existing interfaces is preserved. New interfaces are added as inactive.

type Pusher

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

Pusher pushes interface state infos to all border routers to remove the revocations. It is called when an interface comes back up.

func (*Pusher) Push

func (p *Pusher) Push(ctx context.Context, ifid common.IFIDType)

Push removes the revocation for the given interface from all border routers.

type PusherConf

type PusherConf struct {
	TopoProvider itopo.ProviderI
	Intfs        *Interfaces
	Msgr         infra.Messenger
}

PusherConf is the configuration to create a new pusher.

func (PusherConf) New

func (cfg PusherConf) New() *Pusher

New creates a new interface state pusher.

type RevConfig

type RevConfig struct {
	RevTTL     time.Duration
	RevOverlap time.Duration
}

RevConfig configures the parameters for revocation creation.

type RevInserter

type RevInserter interface {
	InsertRevocations(ctx context.Context, revocations ...*path_mgmt.SignedRevInfo) error
}

RevInserter stores revocation into persistent storage.

type Revoker

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

Revoker issues revocations for interfaces that have timed out. Revocations for already revoked interfaces are renewed periodically.

func (*Revoker) Name

func (r *Revoker) Name() string

Name returns the tasks name.

func (*Revoker) Run

func (r *Revoker) Run(ctx context.Context)

Run issues revocations for interfaces that have timed out and renews revocations for revoked interfaces.

type RevokerConf

type RevokerConf struct {
	Intfs        *Interfaces
	Msgr         infra.Messenger
	Signer       infra.Signer
	TopoProvider itopo.ProviderI
	RevInserter  RevInserter
	RevConfig    RevConfig
}

RevokerConf is the configuration to create a new revoker.

func (RevokerConf) New

func (cfg RevokerConf) New() *Revoker

New creates a new revoker from the given arguments.

type State

type State string

State is the state of an interface.

const (
	// Inactive indicates that the interface has not been activated or
	// expired yet.
	Inactive State = "Inactive"
	// Active indicates that the interface is active.
	Active State = "Active"
	// Expired indicates that the interface is expired.
	Expired State = "Expired"
	// Revoked indicates that the interface is revoked.
	Revoked State = "Revoked"
)

Directories

Path Synopsis
Package mock_ifstate is a generated GoMock package.
Package mock_ifstate is a generated GoMock package.

Jump to

Keyboard shortcuts

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