routingtable

package
v0.0.3-pre8 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldPropagateUpdate

func ShouldPropagateUpdate(pfx *net.Prefix, p *route.Path, n *Neighbor) bool

ShouldPropagateUpdate performs some default checks and returns if an route update should be propagated to a neighbor

Types

type AdjRIB

type AdjRIB interface {
	ReplaceFilterChain(filter.Chain)
	Dump() []*route.Route
	Register(client RouteTableClient)
	Unregister(client RouteTableClient)
	AddPath(pfx *net.Prefix, path *route.Path) error
	RemovePath(*net.Prefix, *route.Path) bool
	RouteCount() int64
	ClientCount() uint64
}

type AdjRIBIn

type AdjRIBIn interface {
	AdjRIB
}

AdjRIBIn is the interface any AdjRIBIn must implement

type AdjRIBOut

type AdjRIBOut interface {
	AdjRIB
	AddPathInitialDump(pfx *net.Prefix, path *route.Path) error
	ReplacePath(*net.Prefix, *route.Path, *route.Path)
	RefreshRoute(*net.Prefix, []*route.Path)
	// A call to Dispose() signals that no more updates are to be expected from the RIB the client is registered to.
	Dispose()
}

AdjRIBOut is the interface any AdjRIBOut must implement

type ClientManager

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

ClientManager manages clients of routing tables (observer pattern)

func NewClientManager

func NewClientManager(master ClientManagerMaster) *ClientManager

NewClientManager creates and initializes a new client manager

func (*ClientManager) ClientCount

func (c *ClientManager) ClientCount() uint64

ClientCount gets the number of registred clients

func (*ClientManager) Clients

func (c *ClientManager) Clients() []RouteTableClient

Clients returns a list of registered clients

func (*ClientManager) GetOptions

func (c *ClientManager) GetOptions(client RouteTableClient) ClientOptions

GetOptions gets the options for a registered client

func (*ClientManager) RegisterWithOptions

func (c *ClientManager) RegisterWithOptions(client RouteTableClient, opt ClientOptions)

RegisterWithOptions registers a client with options for updates

func (*ClientManager) Unregister

func (c *ClientManager) Unregister(client RouteTableClient) bool

Unregister unregisters a client

type ClientManagerMaster

type ClientManagerMaster interface {
	UpdateNewClient(RouteTableClient) error
}

type ClientOptions

type ClientOptions struct {
	BestOnly bool
	EcmpOnly bool
	MaxPaths uint
}

ClientOptions represents options for a client

func (*ClientOptions) GetMaxPaths

func (c *ClientOptions) GetMaxPaths(ecmpPaths uint) uint

GetMaxPaths calculates the maximum amount of wanted paths given that ecmpPaths paths exist

type ContributingASNs

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

ContributingASNs contains a list of contributing ASN to a LocRIB to check ASPaths for possible routing loops.

func NewContributingASNs

func NewContributingASNs() *ContributingASNs

NewContributingASNs creates a list of contributing ASNs to a LocRIB for routing loop prevention.

func (*ContributingASNs) Add

func (c *ContributingASNs) Add(asn uint32)

Add a new ASN to the list of contributing ASNs or add the ref count of an existing one.

func (*ContributingASNs) IsContributingASN

func (c *ContributingASNs) IsContributingASN(asn uint32) bool

IsContributingASN checks if a given ASN is part of the contributing ASNs

func (*ContributingASNs) Remove

func (c *ContributingASNs) Remove(asn uint32)

Remove a ASN to the list of contributing ASNs or decrement the ref count of an existing one.

type Neighbor

type Neighbor struct {
	// Address is the IPv4 address of the neighbor as integer representation
	Address *bnet.IP

	// Local address is the local address of the BGP TCP connection
	LocalAddress *bnet.IP

	// Type is the type / protocol used for routing inforation communitation
	Type uint8

	// IBGP returns if local ASN is equal to remote ASN
	IBGP bool

	// Local ASN of session
	LocalASN uint32

	// RouteServerClient indicates if the peer is a route server client
	RouteServerClient bool

	// RouteReflectorClient indicates if the peer is a route reflector client
	RouteReflectorClient bool

	// ClusterID is our route reflectors clusterID
	ClusterID uint32
}

Neighbor represents the attributes identifying a neighbor relationship

type RIB

type RIB interface {
	AddPath(*net.Prefix, *route.Path)
	RemovePath(*net.Prefix, *route.Path)
}

type RTMockClient

type RTMockClient struct {
	FakeRouteCount int64
	// contains filtered or unexported fields
}

func NewRTMockClient

func NewRTMockClient() *RTMockClient

func (*RTMockClient) AddPath

func (m *RTMockClient) AddPath(pfx *net.Prefix, p *route.Path) error

func (*RTMockClient) AddPathInitialDump

func (m *RTMockClient) AddPathInitialDump(pfx *net.Prefix, p *route.Path) error

func (*RTMockClient) ClientCount

func (m *RTMockClient) ClientCount() uint64

func (*RTMockClient) Dispose

func (m *RTMockClient) Dispose()

func (*RTMockClient) Dump

func (m *RTMockClient) Dump() []*route.Route

Dump is here to fulfill an interface

func (*RTMockClient) RefreshRoute

func (m *RTMockClient) RefreshRoute(*net.Prefix, []*route.Path)

func (*RTMockClient) Register

func (m *RTMockClient) Register(RouteTableClient)

func (*RTMockClient) RegisterWithOptions

func (m *RTMockClient) RegisterWithOptions(RouteTableClient, ClientOptions)

func (*RTMockClient) RemovePath

func (m *RTMockClient) RemovePath(pfx *net.Prefix, p *route.Path) bool

RemovePath removes the path for prefix `pfx`

func (*RTMockClient) Removed

func (m *RTMockClient) Removed() []*RemovePathParams

func (*RTMockClient) ReplaceFilterChain

func (m *RTMockClient) ReplaceFilterChain(filter.Chain)

func (*RTMockClient) ReplacePath

func (m *RTMockClient) ReplacePath(*net.Prefix, *route.Path, *route.Path)

func (*RTMockClient) RouteCount

func (m *RTMockClient) RouteCount() int64

func (*RTMockClient) Unregister

func (m *RTMockClient) Unregister(RouteTableClient)

func (*RTMockClient) UpdateNewClient

func (m *RTMockClient) UpdateNewClient(client RouteTableClient) error

type RemovePathParams

type RemovePathParams struct {
	Pfx  *net.Prefix
	Path *route.Path
}

type RouteTableClient

type RouteTableClient interface {
	AddPath(pfx *net.Prefix, path *route.Path) error
	AddPathInitialDump(pfx *net.Prefix, path *route.Path) error
	RemovePath(*net.Prefix, *route.Path) bool
	ReplacePath(*net.Prefix, *route.Path, *route.Path)
	RefreshRoute(*net.Prefix, []*route.Path)
	// A call to Dispose() signals that no more updates are to be expected from the RIB the client is registered to.
	Dispose()
}

RouteTableClient is the interface that every route table client must implement

type RoutingTable

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

RoutingTable is a binary trie that stores prefixes and their paths

func NewRoutingTable

func NewRoutingTable() *RoutingTable

NewRoutingTable creates a new routing table

func (*RoutingTable) AddPath

func (rt *RoutingTable) AddPath(pfx *net.Prefix, p *route.Path) error

AddPath adds a path to the routing table

func (*RoutingTable) Dump

func (rt *RoutingTable) Dump() []*route.Route

Dump dumps all routes in table rt into a slice

func (*RoutingTable) Get

func (rt *RoutingTable) Get(pfx *net.Prefix) *route.Route

Get gets the route for pfx from the LPM

func (*RoutingTable) GetLonger

func (rt *RoutingTable) GetLonger(pfx *net.Prefix) (res []*route.Route)

GetLonger gets prefix pfx and all it's more specifics from the LPM

func (*RoutingTable) GetRouteCount

func (rt *RoutingTable) GetRouteCount() int64

GetRouteCount gets the amount of stored routes

func (*RoutingTable) LPM

func (rt *RoutingTable) LPM(pfx *net.Prefix) (res []*route.Route)

LPM performs a longest prefix match for pfx on lpm

func (*RoutingTable) RemovePath

func (rt *RoutingTable) RemovePath(pfx *net.Prefix, p *route.Path)

RemovePath removes a path from the trie

func (*RoutingTable) RemovePfx

func (rt *RoutingTable) RemovePfx(pfx *net.Prefix) []*route.Path

RemovePfx removes all paths for prefix `pfx`

func (*RoutingTable) ReplacePath

func (rt *RoutingTable) ReplacePath(pfx *net.Prefix, p *route.Path) []*route.Path

ReplacePath replaces all paths for prefix `pfx` with path `p`

Directories

Path Synopsis
vrf

Jump to

Keyboard shortcuts

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