route

package
v0.0.3-pre13 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: Apache-2.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

View Source
const (

	// StaticPathType indicators a path is a static path
	StaticPathType

	// BGPPathType indicates a path is a BGP path
	BGPPathType

	// OSPFPathType indicates a path is an OSPF path
	OSPFPathType

	// ISISPathType indicates a path is an ISIS path
	ISISPathType

	// FIBPathType indicates a path is a FIB path
	FIBPathType
)
View Source
const (
	ProtoBio = 45 // bio
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BGPPath

type BGPPath struct {
	BGPPathA          *BGPPathA
	ASPath            *types.ASPath
	ClusterList       *types.ClusterList
	Communities       *types.Communities
	LargeCommunities  *types.LargeCommunities
	UnknownAttributes []types.UnknownPathAttribute
	PathIdentifier    uint32
	ASPathLen         uint16
}

BGPPath represents a set of BGP path attributes

func BGPPathFromProtoBGPPath

func BGPPathFromProtoBGPPath(pb *api.BGPPath, dedup bool) *BGPPath

BGPPathFromProtoBGPPath converts a proto BGPPath to BGPPath

func (*BGPPath) ClusterListString

func (b *BGPPath) ClusterListString() string

ClusterListString returns the formated ClusterList

func (*BGPPath) CommunitiesString

func (b *BGPPath) CommunitiesString() string

CommunitiesString returns the formated communities

func (*BGPPath) Compare

func (b *BGPPath) Compare(c *BGPPath) bool

Compare checks if paths are the same

func (*BGPPath) ComputeHash

func (b *BGPPath) ComputeHash() string

ComputeHash computes an hash over all attributes of the path

func (*BGPPath) ComputeHashWithPathID

func (b *BGPPath) ComputeHashWithPathID() string

ComputeHash computes an hash over all attributes of the path

func (*BGPPath) Copy

func (b *BGPPath) Copy() *BGPPath

Copy creates a deep copy of a BGPPath

func (*BGPPath) Dedup

func (b *BGPPath) Dedup() *BGPPath

func (*BGPPath) ECMP

func (b *BGPPath) ECMP(c *BGPPath) bool

ECMP determines if routes b and c are euqal in terms of ECMP

func (*BGPPath) Equal

func (b *BGPPath) Equal(c *BGPPath) bool

Equal checks if paths are equal

func (*BGPPath) LargeCommunitiesString

func (b *BGPPath) LargeCommunitiesString() string

LargeCommunitiesString returns the formated communities

func (*BGPPath) Length

func (b *BGPPath) Length() uint16

Length get's the length of serialized path

func (*BGPPath) Prepend

func (b *BGPPath) Prepend(asn uint32, times uint16)

Prepend the given BGPPath with the given ASN given times

func (*BGPPath) Print

func (b *BGPPath) Print() string

Print all known information about a route in human readable form

func (*BGPPath) Select

func (b *BGPPath) Select(c *BGPPath) int8

Select returns negative if b < c, 0 if paths are equal, positive if b > c

func (*BGPPath) String

func (b *BGPPath) String() string

Print all known information about a route in logfile friendly format

func (*BGPPath) ToProto

func (b *BGPPath) ToProto() *api.BGPPath

ToProto converts BGPPath to proto BGPPath

type BGPPathA

type BGPPathA struct {
	NextHop         *bnet.IP
	Source          *bnet.IP
	LocalPref       uint32
	MED             uint32
	BGPIdentifier   uint32
	OriginatorID    uint32
	Aggregator      *types.Aggregator
	EBGP            bool
	AtomicAggregate bool
	Origin          uint8
}

BGPPathA represents cachable BGP path attributes

func NewBGPPathA

func NewBGPPathA() *BGPPathA

NewBGPPathA creates a new BGPPathA

func (*BGPPathA) Dedup

func (b *BGPPathA) Dedup() *BGPPathA

type BGPPathCounter

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

BGPPathCounter couples a counter to a particular path

type BGPPathManager

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

BGPPathManager is a component used to deduplicate BGP Path objects

func NewBGPPathManager

func NewBGPPathManager() *BGPPathManager

NewBGPPathManager creates a new BGP Path Manager

func (*BGPPathManager) AddPath

func (m *BGPPathManager) AddPath(p BGPPath) *BGPPath

AddPath adds a path to the cache if it doesn't exist. If it exist a pointer to the cached object is returned.

func (*BGPPathManager) RemovePath

func (m *BGPPathManager) RemovePath(p BGPPath)

RemovePath notifies us that there is one user less for path p

type FIBPath

type FIBPath struct {
	Src      *bnet.IP
	NextHop  *bnet.IP // GW
	Priority int
	Protocol int
	Type     int
	Table    int
	Kernel   bool // True if the route is already installed in the kernel
}

FIBPath represents a path learned via Netlink of a route

func NewNlPathFromBgpPath

func NewNlPathFromBgpPath(p *BGPPath) *FIBPath

NewNlPathFromBgpPath creates a new FIBPath object from a BGPPath object

func (*FIBPath) Copy

func (s *FIBPath) Copy() *FIBPath

Copy duplicates the current object

func (*FIBPath) ECMP

func (s *FIBPath) ECMP(t *FIBPath) bool

ECMP determines if path s and t are equal in terms of ECMP

func (*FIBPath) Print

func (s *FIBPath) Print() string

Print all known information about a route in human readable form

func (*FIBPath) Select

func (s *FIBPath) Select(t *FIBPath) int8

Select compares s with t and returns negative if s < t, 0 if paths are equal, positive if s > t

func (*FIBPath) String

func (s *FIBPath) String() string

Print all known information about a route in logfile friendly format

type Path

type Path struct {
	Type       uint8
	PostPolicy bool // PostPolicy fields is a hack used in BMP to differentiate between pre/post policy routes (L flag of the per peer header)
	StaticPath *StaticPath
	BGPPath    *BGPPath
	FIBPath    *FIBPath
}

Path represents a network path

func PathsDiff

func PathsDiff(a, b []*Path) []*Path

PathsDiff gets the list of elements contained by a but not b

func (*Path) Compare

func (p *Path) Compare(q *Path) bool

Compare checks if paths p and q are the same

func (*Path) Copy

func (p *Path) Copy() *Path

Copy a route

func (*Path) ECMP

func (p *Path) ECMP(q *Path) bool

ECMP checks if path p and q are equal enough to be considered for ECMP usage

func (*Path) Equal

func (p *Path) Equal(q *Path) bool

Equal checks if paths p and q are equal

func (*Path) NextHop

func (p *Path) NextHop() *bnet.IP

NextHop returns the next hop IP Address

func (*Path) Print

func (p *Path) Print() string

Print all known information about a route in human readable form

func (*Path) Select

func (p *Path) Select(q *Path) int8

Select returns negative if p < q, 0 if paths are equal, positive if p > q

func (*Path) String

func (p *Path) String() string

Print all known information about a route in logfile friendly format

func (*Path) ToProto

func (p *Path) ToProto() *api.Path

ToProto converts path to proto path

type Route

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

Route links a prefix to paths

func NewRoute

func NewRoute(pfx *net.Prefix, p *Path) *Route

NewRoute generates a new route with path p

func NewRouteAddPath

func NewRouteAddPath(pfx *net.Prefix, p []*Path) *Route

NewRouteAddPath generates a new route with paths p

func RouteFromProtoRoute

func RouteFromProtoRoute(ar *api.Route, dedup bool) *Route

RouteFromProtoRoute converts a proto Route to a Route

func (*Route) AddPath

func (r *Route) AddPath(p *Path)

AddPath adds path p to route r

func (*Route) Addr

func (r *Route) Addr() *net.IP

Addr gets a routes address

func (*Route) BestPath

func (r *Route) BestPath() *Path

BestPath returns the current best path. nil if non exists

func (*Route) Copy

func (r *Route) Copy() *Route

Copy returns a copy of route r

func (*Route) ECMPPathCount

func (r *Route) ECMPPathCount() uint

ECMPPathCount returns the count of ecmp paths for route r

func (*Route) ECMPPaths

func (r *Route) ECMPPaths() []*Path

ECMPPaths returns a copy of the list of paths associated with route r

func (*Route) Equal

func (r *Route) Equal(other *Route) bool

Equal compares if two routes are the same

func (*Route) GetBGPOriginatingAS

func (r *Route) GetBGPOriginatingAS() *uint32

func (*Route) IsBGPOriginatedBy

func (r *Route) IsBGPOriginatedBy(asn uint32) bool

func (*Route) PathSelection

func (r *Route) PathSelection()

PathSelection recalculates the best path + active paths

func (*Route) Paths

func (r *Route) Paths() []*Path

Paths returns a copy of the list of paths associated with route r

func (*Route) Pfxlen

func (r *Route) Pfxlen() uint8

Pfxlen gets a routes prefix length

func (*Route) Prefix

func (r *Route) Prefix() *net.Prefix

Prefix gets the prefix of route `r`

func (*Route) Print

func (r *Route) Print() string

Print returns a printable representation of route `r`

func (*Route) RemovePath

func (r *Route) RemovePath(p *Path) int

RemovePath removes path `p` from route `r`. Returns length of path list after removing path `p`

func (*Route) ReplacePath

func (r *Route) ReplacePath(old *Path, new *Path) error

ReplacePath replace path old with new

func (*Route) ToProto

func (r *Route) ToProto() *api.Route

ToProto converts route to proto route

type StaticPath

type StaticPath struct {
	NextHop *bnet.IP
}

StaticPath represents a static path of a route

func StaticPathFromProtoStaticPath

func StaticPathFromProtoStaticPath(pb *api.StaticPath, dedup bool) *StaticPath

StaticPathFromProtoStaticPath converts a proto StaticPath to StaticPath

func (*StaticPath) Compare

func (s *StaticPath) Compare(t *StaticPath) bool

Compare checks if paths a and t are the same

func (*StaticPath) Copy

func (s *StaticPath) Copy() *StaticPath

func (*StaticPath) ECMP

func (s *StaticPath) ECMP(t *StaticPath) bool

ECMP determines if path s and t are equal in terms of ECMP

func (*StaticPath) Equal

func (s *StaticPath) Equal(t *StaticPath) bool

Equal returns true if s and t are euqal

func (*StaticPath) Select

func (s *StaticPath) Select(t *StaticPath) int8

Select returns negative if s < t, 0 if paths are equal, positive if s > t

func (*StaticPath) ToProto

func (s *StaticPath) ToProto() *api.StaticPath

ToProto converts StaticPath to proto static path

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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