routemgr

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDeviceName = "tun0"
	IATunDevicePrefix = "s."
)

Variables

This section is empty.

Functions

func FixedTunnelName

func FixedTunnelName(name string) func(addr.IA) string

FixedTunnelName returns a device naming function that uses name for every IA.

Types

type Dummy

type Dummy struct {
}

Dummy is a route management backend that does nothing. It is useful to use instead of nil pointer. It saves the user the pain of checking whether interface is nil which happens to be non-trivial in Go.

func (*Dummy) AddRoute

func (d *Dummy) AddRoute(route control.Route)

func (*Dummy) Close

func (d *Dummy) Close()

func (*Dummy) DeleteRoute

func (d *Dummy) DeleteRoute(route control.Route)

func (*Dummy) NewConsumer

func (d *Dummy) NewConsumer() control.Consumer

func (*Dummy) NewPublisher

func (d *Dummy) NewPublisher() control.Publisher

func (*Dummy) Updates

func (d *Dummy) Updates() <-chan control.RouteUpdate

type Linux

type Linux struct {
	// DeviceManager is used to export routes to external routing tables (e.g., Linux).
	DeviceManager control.DeviceManager
	// contains filtered or unexported fields
}

Linux is a one-way exporter of routes to Linux kernel.

func (*Linux) Close

func (l *Linux) Close()

func (*Linux) Diagnostics

func (l *Linux) Diagnostics() control.Diagnostics

func (*Linux) NewPublisher

func (l *Linux) NewPublisher() control.Publisher

func (*Linux) Run

func (l *Linux) Run(ctx context.Context)

type MultiDeviceManager

type MultiDeviceManager struct {
	// DeviceOpener is used to create new resources for handles returned by Get.
	DeviceOpener control.DeviceOpener
	// contains filtered or unexported fields
}

MultiDeviceManager opens one device for each ISD-AS.

func (*MultiDeviceManager) Get

Get returns a handle to the device for the ISD-AS. If no device exists, one will be created. If a device already exists, a handle to the existing device is returned. The caller must Close the handle to guarantee that resources will be cleaned up.

Devices are created with a name composed of the default tunnel device prefix and an unpadded base32 representation of the ISD-AS.

func (*MultiDeviceManager) Size

func (m *MultiDeviceManager) Size() int

Size returns the number of existing devices.

type RouteConsumer

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

func (*RouteConsumer) Close

func (c *RouteConsumer) Close()

Close closes the consumer. This will also close the update channel.

func (*RouteConsumer) Updates

func (c *RouteConsumer) Updates() <-chan control.RouteUpdate

Updates returns a channel for route updates. When the database is closed this channel will be closed as well.

type RouteDB

type RouteDB struct {
	// RouteExpiration specifies how long it takes for an unreferenced route to
	// expire. Zero means expire immediately. Default 0.
	RouteExpiration time.Duration
	// CleanupInterval specifies how often should the cleanup be done.
	// Default 1 second. Set this to a small value in tests to make them run faster.
	CleanupInterval time.Duration
	// Metrics are metrics related to this route database.
	Metrics RouteDBMetrics
	// contains filtered or unexported fields
}

RouteDB is a one-way channel between route publisher(s) and route consumer(s). Routes in the database are reference counted. When the last reference is deleted, the route will remain in the database for some time before in expires.

func (*RouteDB) Close

func (db *RouteDB) Close()

Close shuts down worker goroutines. It also closes update channels for all associated consumers.

func (*RouteDB) Diagnostics

func (db *RouteDB) Diagnostics() control.Diagnostics

Diagnostics takes a diagnostic snapshot of the RouteDB.

func (*RouteDB) NewConsumer

func (db *RouteDB) NewConsumer() control.Consumer

NewConsumer creates a new consumer that can be used to get route updates from the database. Calling the function after Close results in undefined behavior.

func (*RouteDB) NewPublisher

func (db *RouteDB) NewPublisher() control.Publisher

NewPublisher creates a new publisher that can be used to insert routes to the database. Calling the function after Close results in undefined behavior.

func (*RouteDB) Run

func (db *RouteDB) Run()

type RouteDBMetrics

type RouteDBMetrics struct {
	// Unresponsive is increased if published routes cannot be sent to the consumer.
	// (Consumer is slow/stuck and doesn't read routes from the channel.)
	Unresponsive metrics.Counter
}

type RoutePublisher

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

func (*RoutePublisher) AddRoute

func (p *RoutePublisher) AddRoute(route control.Route)

AddRoute adds a route to the database. Inserting the same route multiple times is OK. The routes are reference counted. Calling the function after Close results in undefined behavior.

func (*RoutePublisher) Close

func (p *RoutePublisher) Close()

Close closes the publisher, deleting all the routes that have been added through it.

func (*RoutePublisher) DeleteRoute

func (p *RoutePublisher) DeleteRoute(route control.Route)

DeleteRoute removes a route from the database. If the route in question hasn't been added via this publisher the function will panic. Calling the function after Close results in undefined behavior.

type SingleDeviceManager

type SingleDeviceManager struct {
	// DeviceOpener is the object used to create new handles.
	DeviceOpener control.DeviceOpener
	// contains filtered or unexported fields
}

SingleDeviceManager opens a single device for all ISD-ASes.

func (*SingleDeviceManager) Get

Get returns a handle to the device for the ISD-AS. If no device exists, one will be created. If a device already exists, a handle to the existing device is returned. The caller must Close the handle to guarantee that resources will be cleaned up.

Jump to

Keyboard shortcuts

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