table

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INCLUDE singleAsPathMatchMode = iota
	LEFT_MOST
	ORIGIN
	ONLY
)
View Source
const (
	ADD opType = iota
	REMOVE
	REPLACE
)
View Source
const (
	ASPATH_REGEXP_MAGIC = "(^|[,{}() ]|$)"
)
View Source
const (
	DEFAULT_LOCAL_PREF = 100
)
View Source
const (
	GLOBAL_RIB_NAME = "global"
)

Variables

View Source
var (
	SelectionOptions oc.RouteSelectionOptionsConfig
	UseMultiplePaths oc.UseMultiplePathsConfig
)
View Source
var (
	ErrInvalidRouteTarget error = errors.New("ExtendedCommunity is not RouteTarget")
	ErrNilCommunity       error = errors.New("RouteTarget could not be nil")
)
View Source
var BestPathReasonStringMap = map[BestPathReason]string{
	BPR_UNKNOWN:            "Unknown",
	BPR_DISABLED:           "Bestpath selection disabled",
	BPR_ONLY_PATH:          "Only Path",
	BPR_REACHABLE_NEXT_HOP: "Reachable Next Hop",
	BPR_HIGHEST_WEIGHT:     "Highest Weight",
	BPR_LOCAL_PREF:         "Local Pref",
	BPR_LOCAL_ORIGIN:       "Local Origin",
	BPR_ASPATH:             "AS Path",
	BPR_ORIGIN:             "Origin",
	BPR_MED:                "MED",
	BPR_ASN:                "ASN",
	BPR_IGP_COST:           "IGP Cost",
	BPR_ROUTER_ID:          "Router ID",
	BPR_OLDER:              "Older",
	BPR_NON_LLGR_STALE:     "no LLGR Stale",
	BPR_NEIGH_ADDR:         "Neighbor Address",
}
View Source
var ErrNoMedPathAttr error = errors.New("no med path attr")

Functions

func AddrPrefixOnlyCompare

func AddrPrefixOnlyCompare(a, b bgp.NLRI) int

func CanImportToVrf

func CanImportToVrf(v *Vrf, path *Path) bool

func CreateUpdateMsgFromPaths

func CreateUpdateMsgFromPaths(pathList []*Path, options ...*bgp.MarshallingOption) []*bgp.BGPMessage

func NewAPIPolicyAssignmentFromTableStruct

func NewAPIPolicyAssignmentFromTableStruct(t *PolicyAssignment) *api.PolicyAssignment

func NewAPIPolicyFromTableStruct

func NewAPIPolicyFromTableStruct(p *Policy) *api.Policy

func NewAPIRoutingPolicyFromConfigStruct

func NewAPIRoutingPolicyFromConfigStruct(c *oc.RoutingPolicy) (*api.RoutingPolicy, error)

func NewSingleAsPathMatch

func NewSingleAsPathMatch(arg string) *singleAsPathMatch

func ParseCommunity

func ParseCommunity(arg string) (uint32, error)

func ParseCommunityRegexp

func ParseCommunityRegexp(arg string) (*regexp.Regexp, error)

func ParseExtCommunity

func ParseExtCommunity(arg string) (bgp.ExtendedCommunityInterface, error)

func ParseExtCommunityRegexp

func ParseExtCommunityRegexp(arg string) (bgp.ExtendedCommunityAttrSubType, *regexp.Regexp, error)

func ParseLargeCommunityRegexp

func ParseLargeCommunityRegexp(arg string) (*regexp.Regexp, error)

func RegexpRemoveCommunities

func RegexpRemoveCommunities(path *Path, exps []*regexp.Regexp)

func RegexpRemoveExtCommunities

func RegexpRemoveExtCommunities(path *Path, exps []*regexp.Regexp, subtypes []bgp.ExtendedCommunityAttrSubType)

func RegexpRemoveLargeCommunities

func RegexpRemoveLargeCommunities(path *Path, exps []*regexp.Regexp)

func SystemMemoryAvailableMiB

func SystemMemoryAvailableMiB() uint64

func ToComparisonApi

func ToComparisonApi(c oc.AttributeComparison) api.Comparison

func ToPolicyApi

func ToPolicyApi(p *oc.PolicyDefinition) *api.Policy

func UpdatePathAggregator2ByteAs

func UpdatePathAggregator2ByteAs(msg *bgp.BGPUpdate)

func UpdatePathAggregator4ByteAs

func UpdatePathAggregator4ByteAs(msg *bgp.BGPUpdate) error

func UpdatePathAttrs2ByteAs

func UpdatePathAttrs2ByteAs(msg *bgp.BGPUpdate)

func UpdatePathAttrs4ByteAs

func UpdatePathAttrs4ByteAs(logger *slog.Logger, msg *bgp.BGPUpdate)

Types

type Action

type Action interface {
	Type() ActionType
	Apply(*Path, *PolicyOptions) (*Path, error)
	String() string
}

type ActionType

type ActionType int
const (
	ACTION_ROUTING ActionType = iota
	ACTION_COMMUNITY
	ACTION_EXT_COMMUNITY
	ACTION_MED
	ACTION_AS_PATH_PREPEND
	ACTION_NEXTHOP
	ACTION_LOCAL_PREF
	ACTION_LARGE_COMMUNITY
	ACTION_ORIGIN
)

type AdjRib

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

func NewAdjRib

func NewAdjRib(logger *slog.Logger, rfList []bgp.Family) *AdjRib

func (*AdjRib) Accepted

func (adj *AdjRib) Accepted(rfList []bgp.Family) int

func (*AdjRib) Count

func (adj *AdjRib) Count(rfList []bgp.Family) int

func (*AdjRib) Drop

func (adj *AdjRib) Drop(rfList []bgp.Family) []*Path

func (*AdjRib) DropStale

func (adj *AdjRib) DropStale(rfList []bgp.Family) []*Path

func (*AdjRib) MarkLLGRStaleOrDrop

func (adj *AdjRib) MarkLLGRStaleOrDrop(rfList []bgp.Family) []*Path

func (*AdjRib) PathList

func (adj *AdjRib) PathList(rfList []bgp.Family, accepted bool) []*Path

func (*AdjRib) Select

func (adj *AdjRib) Select(family bgp.Family, accepted bool, option ...TableSelectOption) (*Table, error)

func (*AdjRib) StaleAll

func (adj *AdjRib) StaleAll(rfList []bgp.Family) []*Path

func (*AdjRib) TableInfo

func (adj *AdjRib) TableInfo(family bgp.Family) (*TableInfo, error)

func (*AdjRib) Update

func (adj *AdjRib) Update(pathList []*Path)

func (*AdjRib) UpdateAdjRibOut

func (adj *AdjRib) UpdateAdjRibOut(pathList []*Path)

The provided pathList is expected to be the real candidate routes after policy evaluation.

For routes that are filtered by policy, there could be a mismatch between display
and actual rib sent to the peer (if softreset out was not run).
Only used to display adj-out because we do not maintain a separate adj-out table

type AfiSafiInCondition

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

func NewAfiSafiInCondition

func NewAfiSafiInCondition(afiSafInConfig []oc.AfiSafiType) (*AfiSafiInCondition, error)

func (*AfiSafiInCondition) Evaluate

func (c *AfiSafiInCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*AfiSafiInCondition) Name

func (c *AfiSafiInCondition) Name() string

func (*AfiSafiInCondition) Set

func (c *AfiSafiInCondition) Set() DefinedSet

func (*AfiSafiInCondition) String

func (c *AfiSafiInCondition) String() string

func (*AfiSafiInCondition) Type

type AsPathCondition

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

func NewAsPathCondition

func NewAsPathCondition(c oc.MatchAsPathSet) (*AsPathCondition, error)

func (*AsPathCondition) Evaluate

func (c *AsPathCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*AsPathCondition) Name

func (c *AsPathCondition) Name() string

func (*AsPathCondition) Option

func (c *AsPathCondition) Option() MatchOption

func (*AsPathCondition) Set

func (c *AsPathCondition) Set() DefinedSet

func (*AsPathCondition) Type

func (c *AsPathCondition) Type() ConditionType

type AsPathLengthCondition

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

func NewAsPathLengthCondition

func NewAsPathLengthCondition(c oc.AsPathLength) (*AsPathLengthCondition, error)

func (*AsPathLengthCondition) Evaluate

func (c *AsPathLengthCondition) Evaluate(path *Path, _ *PolicyOptions) bool

compare AS_PATH length in the message's AS_PATH attribute with the one in condition.

func (*AsPathLengthCondition) Name

func (c *AsPathLengthCondition) Name() string

func (*AsPathLengthCondition) Set

func (*AsPathLengthCondition) String

func (c *AsPathLengthCondition) String() string

func (*AsPathLengthCondition) Type

type AsPathPrependAction

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

func NewAsPathPrependAction

func NewAsPathPrependAction(action oc.SetAsPathPrepend) (*AsPathPrependAction, error)

NewAsPathPrependAction creates AsPathPrependAction object. If ASN cannot be parsed, nil will be returned.

func (*AsPathPrependAction) Apply

func (a *AsPathPrependAction) Apply(path *Path, option *PolicyOptions) (*Path, error)

func (*AsPathPrependAction) MarshalJSON

func (a *AsPathPrependAction) MarshalJSON() ([]byte, error)

func (*AsPathPrependAction) String

func (a *AsPathPrependAction) String() string

func (*AsPathPrependAction) ToConfig

func (a *AsPathPrependAction) ToConfig() *oc.SetAsPathPrepend

func (*AsPathPrependAction) Type

func (a *AsPathPrependAction) Type() ActionType

type AsPathSet

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

func NewAsPathSet

func NewAsPathSet(c oc.AsPathSet) (*AsPathSet, error)

func (*AsPathSet) Append

func (lhs *AsPathSet) Append(arg DefinedSet) error

func (*AsPathSet) List

func (s *AsPathSet) List() []string

func (*AsPathSet) MarshalJSON

func (s *AsPathSet) MarshalJSON() ([]byte, error)

func (*AsPathSet) Name

func (s *AsPathSet) Name() string

func (*AsPathSet) Remove

func (lhs *AsPathSet) Remove(arg DefinedSet) error

func (*AsPathSet) Replace

func (lhs *AsPathSet) Replace(arg DefinedSet) error

func (*AsPathSet) String

func (s *AsPathSet) String() string

func (*AsPathSet) ToConfig

func (s *AsPathSet) ToConfig() *oc.AsPathSet

func (*AsPathSet) Type

func (s *AsPathSet) Type() DefinedType

type Assignment

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

type AttributeComparison

type AttributeComparison int
const (
	// "== comparison"
	ATTRIBUTE_EQ AttributeComparison = iota
	// ">= comparison"
	ATTRIBUTE_GE
	// "<= comparison"
	ATTRIBUTE_LE
)

func (AttributeComparison) String

func (c AttributeComparison) String() string

type BestPathReason

type BestPathReason uint8
const (
	BPR_UNKNOWN BestPathReason = iota
	BPR_DISABLED
	BPR_ONLY_PATH
	BPR_REACHABLE_NEXT_HOP
	BPR_HIGHEST_WEIGHT
	BPR_LOCAL_PREF
	BPR_LOCAL_ORIGIN
	BPR_ASPATH
	BPR_ORIGIN
	BPR_MED
	BPR_ASN
	BPR_IGP_COST
	BPR_ROUTER_ID
	BPR_OLDER
	BPR_NON_LLGR_STALE
	BPR_NEIGH_ADDR
)

func (*BestPathReason) String

func (r *BestPathReason) String() string

type Bitmap

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

func NewBitmap

func NewBitmap(size int) *Bitmap

func (*Bitmap) Expand

func (b *Bitmap) Expand()

func (*Bitmap) FindandSetZeroBit

func (b *Bitmap) FindandSetZeroBit() (uint, error)

func (*Bitmap) Flag

func (b *Bitmap) Flag(i uint)

func (*Bitmap) GetFlag

func (b *Bitmap) GetFlag(i uint) bool

func (*Bitmap) Unflag

func (b *Bitmap) Unflag(i uint)

type CommunityAction

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

func NewCommunityAction

func NewCommunityAction(c oc.SetCommunity) (*CommunityAction, error)

func (*CommunityAction) Apply

func (a *CommunityAction) Apply(path *Path, _ *PolicyOptions) (*Path, error)

func (*CommunityAction) MarshalJSON

func (a *CommunityAction) MarshalJSON() ([]byte, error)

func (*CommunityAction) String

func (a *CommunityAction) String() string

func (*CommunityAction) ToConfig

func (a *CommunityAction) ToConfig() *oc.SetCommunity

func (*CommunityAction) Type

func (a *CommunityAction) Type() ActionType

type CommunityCondition

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

func NewCommunityCondition

func NewCommunityCondition(c oc.MatchCommunitySet) (*CommunityCondition, error)

func (*CommunityCondition) Evaluate

func (c *CommunityCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*CommunityCondition) Name

func (c *CommunityCondition) Name() string

func (*CommunityCondition) Option

func (c *CommunityCondition) Option() MatchOption

func (*CommunityCondition) Set

func (c *CommunityCondition) Set() DefinedSet

func (*CommunityCondition) Type

type CommunityCountCondition

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

func NewCommunityCountCondition

func NewCommunityCountCondition(c oc.CommunityCount) (*CommunityCountCondition, error)

func (*CommunityCountCondition) Evaluate

func (c *CommunityCountCondition) Evaluate(path *Path, _ *PolicyOptions) bool

Evaluate compares the number of communities in the message's community attributes with the one in condition.

func (*CommunityCountCondition) Name

func (c *CommunityCountCondition) Name() string

func (*CommunityCountCondition) Set

func (*CommunityCountCondition) String

func (c *CommunityCountCondition) String() string

func (*CommunityCountCondition) Type

type CommunitySet

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

func NewCommunitySet

func NewCommunitySet(c oc.CommunitySet) (*CommunitySet, error)

func (*CommunitySet) Append

func (lhs *CommunitySet) Append(arg DefinedSet) error

func (*CommunitySet) List

func (s *CommunitySet) List() []string

func (*CommunitySet) MarshalJSON

func (s *CommunitySet) MarshalJSON() ([]byte, error)

func (*CommunitySet) Name

func (s *CommunitySet) Name() string

func (*CommunitySet) Remove

func (lhs *CommunitySet) Remove(arg DefinedSet) error

func (*CommunitySet) Replace

func (lhs *CommunitySet) Replace(arg DefinedSet) error

func (*CommunitySet) String

func (s *CommunitySet) String() string

func (*CommunitySet) ToConfig

func (s *CommunitySet) ToConfig() *oc.CommunitySet

func (*CommunitySet) Type

func (s *CommunitySet) Type() DefinedType

type Condition

type Condition interface {
	Name() string
	Type() ConditionType
	Evaluate(*Path, *PolicyOptions) bool
	Set() DefinedSet
}

type ConditionType

type ConditionType int
const (
	CONDITION_PREFIX ConditionType = iota
	CONDITION_NEIGHBOR
	CONDITION_AS_PATH
	CONDITION_COMMUNITY
	CONDITION_EXT_COMMUNITY
	CONDITION_AS_PATH_LENGTH
	CONDITION_RPKI
	CONDITION_ROUTE_TYPE
	CONDITION_LARGE_COMMUNITY
	CONDITION_NEXT_HOP
	CONDITION_AFI_SAFI_IN
	CONDITION_COMMUNITY_COUNT
	CONDITION_ORIGIN
	CONDITION_LOCAL_PREF_EQ
	CONDITION_MED_EQ
)

type DefinedSet

type DefinedSet interface {
	Type() DefinedType
	Name() string
	Append(DefinedSet) error
	Remove(DefinedSet) error
	Replace(DefinedSet) error
	String() string
	List() []string
}

type DefinedSetList

type DefinedSetList []DefinedSet

func (DefinedSetList) Len

func (l DefinedSetList) Len() int

func (DefinedSetList) Less

func (l DefinedSetList) Less(i, j int) bool

func (DefinedSetList) Swap

func (l DefinedSetList) Swap(i, j int)

type DefinedSetMap

type DefinedSetMap map[DefinedType]map[string]DefinedSet

type DefinedType

type DefinedType int
const (
	DEFINED_TYPE_PREFIX DefinedType = iota
	DEFINED_TYPE_NEIGHBOR
	DEFINED_TYPE_TAG
	DEFINED_TYPE_AS_PATH
	DEFINED_TYPE_COMMUNITY
	DEFINED_TYPE_EXT_COMMUNITY
	DEFINED_TYPE_LARGE_COMMUNITY
	DEFINED_TYPE_NEXT_HOP
)

type Destination

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

func NewDestination

func NewDestination(nlri bgp.NLRI, mapSize int, known ...*Path) *Destination

func (*Destination) Calculate

func (dest *Destination) Calculate(logger *slog.Logger, newPath *Path) *Update

Calculates best-path among known paths for this destination.

Modifies destination's state related to stored paths. Removes withdrawn paths from known paths. Also, adds new paths to known paths.

func (*Destination) GetAllKnownPathList

func (dd *Destination) GetAllKnownPathList() []*Path

func (*Destination) GetBestPath

func (dd *Destination) GetBestPath(id string, as uint32) *Path

func (*Destination) GetKnownPathList

func (dd *Destination) GetKnownPathList(id string, as uint32) []*Path

func (*Destination) GetMultiBestPath

func (dd *Destination) GetMultiBestPath(id string) []*Path

func (*Destination) GetNlri

func (dd *Destination) GetNlri() bgp.NLRI

func (*Destination) MarshalJSON

func (d *Destination) MarshalJSON() ([]byte, error)

func (*Destination) Select

func (d *Destination) Select(option ...DestinationSelectOption) *Destination

func (*Destination) String

func (dest *Destination) String() string

type DestinationSelectOption

type DestinationSelectOption struct {
	ID  string
	AS  uint32
	VRF *Vrf

	Best      bool
	MultiPath bool
	// contains filtered or unexported fields
}

type Destinations

type Destinations map[addrPrefixKey][]*Destination

func (Destinations) Get

func (d Destinations) Get(nlri bgp.NLRI) *Destination

func (Destinations) InsertUpdate

func (d Destinations) InsertUpdate(dest *Destination) (collision bool)

func (Destinations) Remove

func (d Destinations) Remove(nlri bgp.NLRI)

type EVPNMacNLRIs

type EVPNMacNLRIs map[macKey]map[*Destination]struct{}

func (EVPNMacNLRIs) Get

func (EVPNMacNLRIs) Insert

func (EVPNMacNLRIs) Remove

type ExtCommunityAction

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

func NewExtCommunityAction

func NewExtCommunityAction(c oc.SetExtCommunity) (*ExtCommunityAction, error)

func (*ExtCommunityAction) Apply

func (a *ExtCommunityAction) Apply(path *Path, _ *PolicyOptions) (*Path, error)

func (*ExtCommunityAction) MarshalJSON

func (a *ExtCommunityAction) MarshalJSON() ([]byte, error)

func (*ExtCommunityAction) String

func (a *ExtCommunityAction) String() string

func (*ExtCommunityAction) ToConfig

func (a *ExtCommunityAction) ToConfig() *oc.SetExtCommunity

func (*ExtCommunityAction) Type

func (a *ExtCommunityAction) Type() ActionType

type ExtCommunityCondition

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

func (*ExtCommunityCondition) Evaluate

func (c *ExtCommunityCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*ExtCommunityCondition) Name

func (c *ExtCommunityCondition) Name() string

func (*ExtCommunityCondition) Option

func (c *ExtCommunityCondition) Option() MatchOption

func (*ExtCommunityCondition) Set

func (*ExtCommunityCondition) Type

type ExtCommunitySet

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

func NewExtCommunitySet

func NewExtCommunitySet(c oc.ExtCommunitySet) (*ExtCommunitySet, error)

func (*ExtCommunitySet) Append

func (s *ExtCommunitySet) Append(arg DefinedSet) error

func (*ExtCommunitySet) List

func (s *ExtCommunitySet) List() []string

func (*ExtCommunitySet) MarshalJSON

func (s *ExtCommunitySet) MarshalJSON() ([]byte, error)

func (*ExtCommunitySet) Name

func (s *ExtCommunitySet) Name() string

func (*ExtCommunitySet) Remove

func (lhs *ExtCommunitySet) Remove(arg DefinedSet) error

func (*ExtCommunitySet) Replace

func (lhs *ExtCommunitySet) Replace(arg DefinedSet) error

func (*ExtCommunitySet) String

func (s *ExtCommunitySet) String() string

func (*ExtCommunitySet) ToConfig

func (s *ExtCommunitySet) ToConfig() *oc.ExtCommunitySet

func (*ExtCommunitySet) Type

func (s *ExtCommunitySet) Type() DefinedType

type FilteredType

type FilteredType uint8
const (
	NotFiltered FilteredType = 1 << iota
	PolicyFiltered
	SendMaxFiltered
)

type LargeCommunityAction

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

func NewLargeCommunityAction

func NewLargeCommunityAction(c oc.SetLargeCommunity) (*LargeCommunityAction, error)

func (*LargeCommunityAction) Apply

func (a *LargeCommunityAction) Apply(path *Path, _ *PolicyOptions) (*Path, error)

func (*LargeCommunityAction) MarshalJSON

func (a *LargeCommunityAction) MarshalJSON() ([]byte, error)

func (*LargeCommunityAction) String

func (a *LargeCommunityAction) String() string

func (*LargeCommunityAction) ToConfig

func (a *LargeCommunityAction) ToConfig() *oc.SetLargeCommunity

func (*LargeCommunityAction) Type

func (a *LargeCommunityAction) Type() ActionType

type LargeCommunityCondition

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

func (*LargeCommunityCondition) Evaluate

func (c *LargeCommunityCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*LargeCommunityCondition) Name

func (c *LargeCommunityCondition) Name() string

func (*LargeCommunityCondition) Option

func (*LargeCommunityCondition) Set

func (*LargeCommunityCondition) Type

type LargeCommunitySet

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

func NewLargeCommunitySet

func NewLargeCommunitySet(c oc.LargeCommunitySet) (*LargeCommunitySet, error)

func (*LargeCommunitySet) Append

func (lhs *LargeCommunitySet) Append(arg DefinedSet) error

func (*LargeCommunitySet) List

func (s *LargeCommunitySet) List() []string

func (*LargeCommunitySet) MarshalJSON

func (s *LargeCommunitySet) MarshalJSON() ([]byte, error)

func (*LargeCommunitySet) Name

func (s *LargeCommunitySet) Name() string

func (*LargeCommunitySet) Remove

func (lhs *LargeCommunitySet) Remove(arg DefinedSet) error

func (*LargeCommunitySet) Replace

func (lhs *LargeCommunitySet) Replace(arg DefinedSet) error

func (*LargeCommunitySet) String

func (s *LargeCommunitySet) String() string

func (*LargeCommunitySet) ToConfig

func (s *LargeCommunitySet) ToConfig() *oc.LargeCommunitySet

func (*LargeCommunitySet) Type

func (s *LargeCommunitySet) Type() DefinedType

type LocalPrefAction

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

func NewLocalPrefAction

func NewLocalPrefAction(value uint32) (*LocalPrefAction, error)

func (*LocalPrefAction) Apply

func (a *LocalPrefAction) Apply(path *Path, _ *PolicyOptions) (*Path, error)

func (*LocalPrefAction) MarshalJSON

func (a *LocalPrefAction) MarshalJSON() ([]byte, error)

func (*LocalPrefAction) String

func (a *LocalPrefAction) String() string

func (*LocalPrefAction) ToConfig

func (a *LocalPrefAction) ToConfig() uint32

func (*LocalPrefAction) Type

func (a *LocalPrefAction) Type() ActionType

type LocalPreqEqCondition

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

func NewLocalPrefEqCondition

func NewLocalPrefEqCondition(value uint32) (*LocalPreqEqCondition, error)

func (*LocalPreqEqCondition) Evaluate

func (c *LocalPreqEqCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*LocalPreqEqCondition) Name

func (c *LocalPreqEqCondition) Name() string

func (*LocalPreqEqCondition) Set

func (*LocalPreqEqCondition) String

func (c *LocalPreqEqCondition) String() string

func (*LocalPreqEqCondition) Type

type MatchOption

type MatchOption int
const (
	MATCH_OPTION_ANY MatchOption = iota
	MATCH_OPTION_ALL
	MATCH_OPTION_INVERT
)

func NewMatchOption

func NewMatchOption(c any) (MatchOption, error)

func (MatchOption) ConvertToMatchSetOptionsRestrictedType

func (o MatchOption) ConvertToMatchSetOptionsRestrictedType() oc.MatchSetOptionsRestrictedType

func (MatchOption) String

func (o MatchOption) String() string

func (MatchOption) ToApi

func (o MatchOption) ToApi() api.MatchSet_Type

type MedAction

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

func NewMedAction

func NewMedAction(c oc.BgpSetMedType) (*MedAction, error)

func NewMedActionFromApiStruct

func NewMedActionFromApiStruct(action MedActionType, value int64) *MedAction

func (*MedAction) Apply

func (a *MedAction) Apply(path *Path, _ *PolicyOptions) (*Path, error)

func (*MedAction) MarshalJSON

func (a *MedAction) MarshalJSON() ([]byte, error)

func (*MedAction) String

func (a *MedAction) String() string

func (*MedAction) ToConfig

func (a *MedAction) ToConfig() oc.BgpSetMedType

func (*MedAction) Type

func (a *MedAction) Type() ActionType

type MedActionType

type MedActionType int
const (
	MED_ACTION_UNSPECIFIED MedActionType = iota
	MED_ACTION_MOD
	MED_ACTION_REPLACE
)

type MedEqCondition

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

func NewMedEqCondition

func NewMedEqCondition(value uint32) (*MedEqCondition, error)

func (*MedEqCondition) Evaluate

func (c *MedEqCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*MedEqCondition) Name

func (c *MedEqCondition) Name() string

func (*MedEqCondition) Set

func (c *MedEqCondition) Set() DefinedSet

func (*MedEqCondition) String

func (c *MedEqCondition) String() string

func (*MedEqCondition) Type

func (c *MedEqCondition) Type() ConditionType

type NeighborCondition

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

func NewNeighborCondition

func NewNeighborCondition(c oc.MatchNeighborSet) (*NeighborCondition, error)

func (*NeighborCondition) Evaluate

func (c *NeighborCondition) Evaluate(path *Path, options *PolicyOptions) bool

compare neighbor ipaddress of this condition and source address of path and, subsequent comparisons are skipped if that matches the conditions. If NeighborList's length is zero, return true.

func (*NeighborCondition) Name

func (c *NeighborCondition) Name() string

func (*NeighborCondition) Option

func (c *NeighborCondition) Option() MatchOption

func (*NeighborCondition) Set

func (c *NeighborCondition) Set() DefinedSet

func (*NeighborCondition) Type

func (c *NeighborCondition) Type() ConditionType

type NeighborSet

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

func NewNeighborSet

func NewNeighborSet(c oc.NeighborSet) (*NeighborSet, error)

func NewNeighborSetFromApiStruct

func NewNeighborSetFromApiStruct(name string, list []net.IPNet) (*NeighborSet, error)

func (*NeighborSet) Append

func (lhs *NeighborSet) Append(arg DefinedSet) error

func (*NeighborSet) List

func (s *NeighborSet) List() []string

func (*NeighborSet) MarshalJSON

func (s *NeighborSet) MarshalJSON() ([]byte, error)

func (*NeighborSet) Name

func (s *NeighborSet) Name() string

func (*NeighborSet) Remove

func (lhs *NeighborSet) Remove(arg DefinedSet) error

func (*NeighborSet) Replace

func (lhs *NeighborSet) Replace(arg DefinedSet) error

func (*NeighborSet) String

func (s *NeighborSet) String() string

func (*NeighborSet) ToConfig

func (s *NeighborSet) ToConfig() *oc.NeighborSet

func (*NeighborSet) Type

func (s *NeighborSet) Type() DefinedType

type NextHopCondition

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

func NewNextHopCondition

func NewNextHopCondition(c []string) (*NextHopCondition, error)

func (*NextHopCondition) Evaluate

func (c *NextHopCondition) Evaluate(path *Path, options *PolicyOptions) bool

compare next-hop ipaddress of this condition and source address of path and, subsequent comparisons are skipped if that matches the conditions. If NextHopSet's length is zero, return true.

func (*NextHopCondition) Name

func (c *NextHopCondition) Name() string

func (*NextHopCondition) Set

func (c *NextHopCondition) Set() DefinedSet

func (*NextHopCondition) String

func (c *NextHopCondition) String() string

func (*NextHopCondition) Type

func (c *NextHopCondition) Type() ConditionType

type NextHopSet

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

func NewNextHopSet

func NewNextHopSet(c []string) (*NextHopSet, error)

func NewNextHopSetFromApiStruct

func NewNextHopSetFromApiStruct(name string, list []netip.Prefix) (*NextHopSet, error)

func (*NextHopSet) Append

func (lhs *NextHopSet) Append(arg DefinedSet) error

func (*NextHopSet) List

func (s *NextHopSet) List() []string

func (*NextHopSet) MarshalJSON

func (s *NextHopSet) MarshalJSON() ([]byte, error)

func (*NextHopSet) Name

func (s *NextHopSet) Name() string

func (*NextHopSet) Remove

func (lhs *NextHopSet) Remove(arg DefinedSet) error

func (*NextHopSet) Replace

func (lhs *NextHopSet) Replace(arg DefinedSet) error

func (*NextHopSet) String

func (s *NextHopSet) String() string

func (*NextHopSet) ToConfig

func (s *NextHopSet) ToConfig() []string

func (*NextHopSet) Type

func (s *NextHopSet) Type() DefinedType

type NexthopAction

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

func NewNexthopAction

func NewNexthopAction(c oc.BgpNextHopType) (*NexthopAction, error)

func (*NexthopAction) Apply

func (a *NexthopAction) Apply(path *Path, options *PolicyOptions) (*Path, error)

func (*NexthopAction) MarshalJSON

func (a *NexthopAction) MarshalJSON() ([]byte, error)

func (*NexthopAction) String

func (a *NexthopAction) String() string

func (*NexthopAction) ToConfig

func (a *NexthopAction) ToConfig() oc.BgpNextHopType

func (*NexthopAction) Type

func (a *NexthopAction) Type() ActionType

type OriginAction

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

func NewOriginAction

func NewOriginAction(value oc.BgpOriginAttrType) (*OriginAction, error)

func (*OriginAction) Apply

func (a *OriginAction) Apply(path *Path, _ *PolicyOptions) (*Path, error)

func (*OriginAction) MarshalJSON

func (a *OriginAction) MarshalJSON() ([]byte, error)

func (*OriginAction) String

func (a *OriginAction) String() string

func (*OriginAction) ToConfig

func (a *OriginAction) ToConfig() oc.BgpOriginAttrType

func (*OriginAction) Type

func (a *OriginAction) Type() ActionType

type OriginCondition

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

func NewOriginCondition

func NewOriginCondition(origin oc.BgpOriginAttrType) (*OriginCondition, error)

func (*OriginCondition) Evaluate

func (c *OriginCondition) Evaluate(path *Path, _ *PolicyOptions) bool

compare if origin matches the one in the condition.

func (*OriginCondition) Name

func (c *OriginCondition) Name() string

func (*OriginCondition) Set

func (c *OriginCondition) Set() DefinedSet

func (*OriginCondition) Type

func (c *OriginCondition) Type() ConditionType

type Path

type Path struct {

	// For BGP Nexthop Tracking, this field shows if nexthop is invalidated by IGP.
	IsNexthopInvalid bool
	IsWithdraw       bool
	// contains filtered or unexported fields
}

func NewEOR

func NewEOR(family bgp.Family) *Path

func NewPath

func NewPath(family bgp.Family, source *PeerInfo, pathnlri bgp.PathNLRI, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool) *Path

func ProcessMessage

func ProcessMessage(m *bgp.BGPMessage, peerInfo *PeerInfo, timestamp time.Time, treatAsWithdraw bool) []*Path

func UpdatePathAttrs

func UpdatePathAttrs(logger *slog.Logger, global *oc.Global, peer *oc.Neighbor, info *PeerInfo, original *Path) *Path

func (*Path) Clone

func (path *Path) Clone(isWithdraw bool) *Path

create new PathAttributes

func (*Path) Compare

func (lhs *Path) Compare(rhs *Path) int

Return > 0 if lhs is preferred over the rhs Return 0 if they are equal Return < 0 if rhs is preferred over the lhs

func (*Path) Equal

func (lhs *Path) Equal(rhs *Path) bool

func (*Path) EqualBySourceAndPathID

func (lhs *Path) EqualBySourceAndPathID(rhs *Path) bool

func (*Path) GetAsList

func (path *Path) GetAsList() []uint32

func (*Path) GetAsPath

func (path *Path) GetAsPath() *bgp.PathAttributeAsPath

func (*Path) GetAsPathLen

func (path *Path) GetAsPathLen() int

GetAsPathLen returns the number of AS_PATH

func (*Path) GetAsSeqList

func (path *Path) GetAsSeqList() []uint32

func (*Path) GetAsString

func (path *Path) GetAsString() string

func (*Path) GetClusterList

func (path *Path) GetClusterList() []netip.Addr

func (*Path) GetCommunities

func (path *Path) GetCommunities() []uint32

func (*Path) GetDestLocalKey

func (path *Path) GetDestLocalKey() PathDestLocalKey

GetDestLocalKey identifies the path destination in the local BGP server.

func (*Path) GetExtCommunities

func (path *Path) GetExtCommunities() []bgp.ExtendedCommunityInterface

func (*Path) GetFamily

func (path *Path) GetFamily() bgp.Family

func (*Path) GetHash

func (p *Path) GetHash() uint64

GetHash returns the hash value of the path attributes.

func (*Path) GetLabelString

func (path *Path) GetLabelString() string

func (*Path) GetLargeCommunities

func (path *Path) GetLargeCommunities() []*bgp.LargeCommunity

func (*Path) GetLocalKey

func (path *Path) GetLocalKey() PathLocalKey

GetLocalKey identifies the path in the local BGP server.

func (*Path) GetLocalPref

func (path *Path) GetLocalPref() (uint32, error)

func (*Path) GetMed

func (path *Path) GetMed() (uint32, error)

func (*Path) GetNexthop

func (path *Path) GetNexthop() netip.Addr

func (*Path) GetNlri

func (path *Path) GetNlri() bgp.NLRI

func (*Path) GetOrigin

func (path *Path) GetOrigin() (uint8, error)

func (*Path) GetOriginatorID

func (path *Path) GetOriginatorID() netip.Addr

func (*Path) GetPathAttrs

func (path *Path) GetPathAttrs() []bgp.PathAttributeInterface

func (*Path) GetPrefix

func (path *Path) GetPrefix() string

func (*Path) GetRouteTargets

func (path *Path) GetRouteTargets() []bgp.ExtendedCommunityInterface

func (*Path) GetSource

func (path *Path) GetSource() *PeerInfo

func (*Path) GetSourceAs

func (path *Path) GetSourceAs() uint32

func (*Path) GetTimestamp

func (path *Path) GetTimestamp() time.Time

func (*Path) HasNoLLGR

func (path *Path) HasNoLLGR() bool

func (*Path) IsDropped

func (path *Path) IsDropped() bool

func (*Path) IsEOR

func (path *Path) IsEOR() bool

func (*Path) IsFromExternal

func (path *Path) IsFromExternal() bool

func (*Path) IsIBGP

func (path *Path) IsIBGP() bool

func (*Path) IsLLGRStale

func (path *Path) IsLLGRStale() bool

func (*Path) IsLocal

func (path *Path) IsLocal() bool

func (*Path) IsRejected

func (path *Path) IsRejected() bool

func (*Path) IsStale

func (path *Path) IsStale() bool

func (*Path) LocalID

func (p *Path) LocalID() uint32

func (*Path) MarkStale

func (path *Path) MarkStale(s bool)

func (*Path) MarshalJSON

func (path *Path) MarshalJSON() ([]byte, error)

func (*Path) NoImplicitWithdraw

func (path *Path) NoImplicitWithdraw() bool

func (*Path) OriginInfo

func (path *Path) OriginInfo() *originInfo

func (*Path) PrependAsn

func (path *Path) PrependAsn(asn uint32, repeat uint8, confed bool)

PrependAsn prepends AS number. This function updates the AS_PATH attribute as follows. (If the peer is in the confederation member AS,

replace AS_SEQUENCE in the following sentence with AS_CONFED_SEQUENCE.)
1) if the first path segment of the AS_PATH is of type
   AS_SEQUENCE, the local system prepends the specified AS num as
   the last element of the sequence (put it in the left-most
   position with respect to the position of  octets in the
   protocol message) the specified number of times.
   If the act of prepending will cause an overflow in the AS_PATH
   segment (i.e.,  more than 255 ASes),
   it SHOULD prepend a new segment of type AS_SEQUENCE
   and prepend its own AS number to this new segment.

2) if the first path segment of the AS_PATH is of other than type
   AS_SEQUENCE, the local system prepends a new path segment of type
   AS_SEQUENCE to the AS_PATH, including the specified AS number in
   that segment.

3) if the AS_PATH is empty, the local system creates a path
   segment of type AS_SEQUENCE, places the specified AS number
   into that segment, and places that segment into the AS_PATH.

func (*Path) RemoteID

func (p *Path) RemoteID() uint32

func (*Path) RemoveCommunities

func (path *Path) RemoveCommunities(communities []uint32) int

RemoveCommunities removes specific communities. If the length of communities is 0, it does nothing. If all communities are removed, it removes Communities path attribute itself.

func (*Path) RemoveLocalPref

func (path *Path) RemoveLocalPref()

func (*Path) RemovePrivateAS

func (path *Path) RemovePrivateAS(localAS uint32, option oc.RemovePrivateAsOption)

func (*Path) ReplaceAS

func (path *Path) ReplaceAS(localAS, peerAS uint32) *Path

func (*Path) SetCommunities

func (path *Path) SetCommunities(communities []uint32, doReplace bool)

SetCommunities adds or replaces communities with new ones. If the length of communities is 0 and doReplace is true, it clears communities.

func (*Path) SetDropped

func (path *Path) SetDropped(y bool)

func (*Path) SetExtCommunities

func (path *Path) SetExtCommunities(exts []bgp.ExtendedCommunityInterface, doReplace bool)

func (*Path) SetHash

func (p *Path) SetHash(v uint64)

func (*Path) SetIsFromExternal

func (path *Path) SetIsFromExternal(y bool)

func (*Path) SetLargeCommunities

func (path *Path) SetLargeCommunities(cs []*bgp.LargeCommunity, doReplace bool)

func (*Path) SetMed

func (path *Path) SetMed(med int64, doReplace bool) error

SetMed replace, add or subtraction med with new ones.

func (*Path) SetNexthop

func (path *Path) SetNexthop(nexthop netip.Addr)

func (*Path) SetRejected

func (path *Path) SetRejected(y bool)

func (*Path) SetSource

func (p *Path) SetSource(peerInfo *PeerInfo)

func (*Path) String

func (path *Path) String() string

return Path's string representation

func (*Path) ToGlobal

func (p *Path) ToGlobal(vrf *Vrf) *Path

func (*Path) ToLocal

func (p *Path) ToLocal() *Path

type PathAttrs

type PathAttrs []bgp.PathAttributeInterface

func (PathAttrs) Len

func (a PathAttrs) Len() int

func (PathAttrs) Less

func (a PathAttrs) Less(i, j int) bool

func (PathAttrs) Swap

func (a PathAttrs) Swap(i, j int)

type PathDestLocalKey

type PathDestLocalKey struct {
	Family bgp.Family
	Prefix string
}

func NewPathDestLocalKey

func NewPathDestLocalKey(f bgp.Family, destPrefix string) *PathDestLocalKey

type PathLocalKey

type PathLocalKey struct {
	PathDestLocalKey
	Id uint32
}

type PeerInfo

type PeerInfo struct {
	AS                      uint32
	LocalAS                 uint32
	ID                      netip.Addr
	LocalID                 netip.Addr
	Address                 netip.Addr
	LocalAddress            netip.Addr
	RouteReflectorClusterID netip.Addr
	RouteReflectorClient    bool
	MultihopTtl             uint8
	Confederation           bool
}

func NewPeerInfo

func NewPeerInfo(g *oc.Global, p *oc.Neighbor, AS, localAS uint32, ID, localID netip.Addr, addr, localAddr netip.Addr) *PeerInfo

func (*PeerInfo) Equal

func (lhs *PeerInfo) Equal(rhs *PeerInfo) bool

func (*PeerInfo) String

func (i *PeerInfo) String() string

type Policies

type Policies []*Policy

func (Policies) Len

func (p Policies) Len() int

func (Policies) Less

func (p Policies) Less(i, j int) bool

func (Policies) Swap

func (p Policies) Swap(i, j int)

type Policy

type Policy struct {
	Name       string
	Statements []*Statement
}

func NewPolicy

func NewPolicy(c oc.PolicyDefinition) (*Policy, error)

func (*Policy) Add

func (lhs *Policy) Add(rhs *Policy) error

func (*Policy) Apply

func (p *Policy) Apply(logger *slog.Logger, path *Path, options *PolicyOptions) (RouteType, *Path)

Compare path with a policy's condition in stored order in the policy. If a condition match, then this function stops evaluation and subsequent conditions are skipped.

func (*Policy) FillUp

func (p *Policy) FillUp(m map[string]*Statement) error

func (*Policy) MarshalJSON

func (p *Policy) MarshalJSON() ([]byte, error)

func (*Policy) Remove

func (lhs *Policy) Remove(rhs *Policy) error

func (*Policy) Replace

func (lhs *Policy) Replace(rhs *Policy) error

func (*Policy) ToConfig

func (p *Policy) ToConfig() *oc.PolicyDefinition

type PolicyAssignment

type PolicyAssignment struct {
	Name     string
	Type     PolicyDirection
	Policies []*Policy
	Default  RouteType
}

type PolicyDirection

type PolicyDirection int
const (
	POLICY_DIRECTION_NONE PolicyDirection = iota
	POLICY_DIRECTION_IMPORT
	POLICY_DIRECTION_EXPORT
)

func (PolicyDirection) String

func (d PolicyDirection) String() string

type PolicyOptions

type PolicyOptions struct {
	Info       *PeerInfo
	OldNextHop netip.Addr
	Validate   func(*Path) *Validation
}

type Prefix

type Prefix struct {
	Prefix             *net.IPNet
	AddressFamily      bgp.Family
	MasklengthRangeMax uint8
	MasklengthRangeMin uint8
}

func NewPrefix

func NewPrefix(c oc.Prefix) (*Prefix, error)

func (*Prefix) Equal

func (lhs *Prefix) Equal(rhs *Prefix) bool

func (*Prefix) Match

func (p *Prefix) Match(path *Path) bool

func (*Prefix) PrefixString

func (p *Prefix) PrefixString() string

type PrefixCondition

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

func NewPrefixCondition

func NewPrefixCondition(c oc.MatchPrefixSet) (*PrefixCondition, error)

func (*PrefixCondition) Evaluate

func (c *PrefixCondition) Evaluate(path *Path, _ *PolicyOptions) bool

compare prefixes in this condition and nlri of path and subsequent comparison is skipped if that matches the conditions. If PrefixList's length is zero, return true.

func (*PrefixCondition) Name

func (c *PrefixCondition) Name() string

func (*PrefixCondition) Option

func (c *PrefixCondition) Option() MatchOption

func (*PrefixCondition) Set

func (c *PrefixCondition) Set() DefinedSet

func (*PrefixCondition) Type

func (c *PrefixCondition) Type() ConditionType

type PrefixSet

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

func NewPrefixSet

func NewPrefixSet(c oc.PrefixSet) (*PrefixSet, error)

func NewPrefixSetFromApiStruct

func NewPrefixSetFromApiStruct(name string, prefixes []*Prefix) (*PrefixSet, error)

func (*PrefixSet) Append

func (lhs *PrefixSet) Append(arg DefinedSet) error

func (*PrefixSet) List

func (s *PrefixSet) List() []string

func (*PrefixSet) MarshalJSON

func (s *PrefixSet) MarshalJSON() ([]byte, error)

func (*PrefixSet) Name

func (s *PrefixSet) Name() string

func (*PrefixSet) Remove

func (lhs *PrefixSet) Remove(arg DefinedSet) error

func (*PrefixSet) Replace

func (lhs *PrefixSet) Replace(arg DefinedSet) error

func (*PrefixSet) String

func (s *PrefixSet) String() string

func (*PrefixSet) ToConfig

func (s *PrefixSet) ToConfig() *oc.PrefixSet

func (*PrefixSet) Type

func (s *PrefixSet) Type() DefinedType

type ROA

type ROA struct {
	Family  int
	Network *net.IPNet
	MaxLen  uint8
	AS      uint32
	Src     string
}

func NewROA

func NewROA(family int, prefixByte []byte, prefixLen uint8, maxLen uint8, as uint32, src string) *ROA

func (*ROA) Equal

func (r *ROA) Equal(roa *ROA) bool

type ROATable

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

func NewROATable

func NewROATable(logger *slog.Logger) *ROATable

func (*ROATable) Add

func (rt *ROATable) Add(roa *ROA)

func (*ROATable) Delete

func (rt *ROATable) Delete(roa *ROA)

func (*ROATable) DeleteAll

func (rt *ROATable) DeleteAll(network string)

func (*ROATable) Info

func (rt *ROATable) Info(family bgp.Family) (map[string]uint32, map[string]uint32)

func (*ROATable) List

func (rt *ROATable) List(family bgp.Family) ([]*ROA, error)

func (*ROATable) Validate

func (rt *ROATable) Validate(path *Path) *Validation

type RouteType

type RouteType int
const (
	ROUTE_TYPE_NONE RouteType = iota
	ROUTE_TYPE_ACCEPT
	ROUTE_TYPE_REJECT
)

func (RouteType) String

func (t RouteType) String() string

type RouteTypeCondition

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

func NewRouteTypeCondition

func NewRouteTypeCondition(c oc.RouteType) (*RouteTypeCondition, error)

func (*RouteTypeCondition) Evaluate

func (c *RouteTypeCondition) Evaluate(path *Path, _ *PolicyOptions) bool

func (*RouteTypeCondition) Name

func (c *RouteTypeCondition) Name() string

func (*RouteTypeCondition) Set

func (c *RouteTypeCondition) Set() DefinedSet

func (*RouteTypeCondition) String

func (c *RouteTypeCondition) String() string

func (*RouteTypeCondition) Type

type RoutingAction

type RoutingAction struct {
	AcceptRoute bool
}

func NewRoutingAction

func NewRoutingAction(c oc.RouteDisposition) (*RoutingAction, error)

func (*RoutingAction) Apply

func (a *RoutingAction) Apply(path *Path, _ *PolicyOptions) (*Path, error)

func (*RoutingAction) String

func (a *RoutingAction) String() string

func (*RoutingAction) Type

func (a *RoutingAction) Type() ActionType

type RoutingPolicy

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

func NewRoutingPolicy

func NewRoutingPolicy(logger *slog.Logger) *RoutingPolicy

func (*RoutingPolicy) AddDefinedSet

func (r *RoutingPolicy) AddDefinedSet(s DefinedSet, replace bool) error

func (*RoutingPolicy) AddPolicy

func (r *RoutingPolicy) AddPolicy(x *Policy, refer bool) (err error)

func (*RoutingPolicy) AddPolicyAssignment

func (r *RoutingPolicy) AddPolicyAssignment(id string, dir PolicyDirection, policies []*oc.PolicyDefinition, def RouteType) (err error)

func (*RoutingPolicy) AddStatement

func (r *RoutingPolicy) AddStatement(st *Statement) (err error)

func (*RoutingPolicy) ApplyPolicy

func (r *RoutingPolicy) ApplyPolicy(id string, dir PolicyDirection, before *Path, options *PolicyOptions) *Path

func (*RoutingPolicy) DeleteDefinedSet

func (r *RoutingPolicy) DeleteDefinedSet(a DefinedSet, all bool) (err error)

func (*RoutingPolicy) DeletePolicy

func (r *RoutingPolicy) DeletePolicy(x *Policy, all, preserve bool, activeId []string) (err error)

func (*RoutingPolicy) DeletePolicyAssignment

func (r *RoutingPolicy) DeletePolicyAssignment(id string, dir PolicyDirection, policies []*oc.PolicyDefinition, all bool) (err error)

func (*RoutingPolicy) DeleteStatement

func (r *RoutingPolicy) DeleteStatement(st *Statement, all bool) (err error)

func (*RoutingPolicy) GetDefinedSet

func (r *RoutingPolicy) GetDefinedSet(typ DefinedType, name string) (*oc.DefinedSets, error)

func (*RoutingPolicy) GetPolicy

func (r *RoutingPolicy) GetPolicy(name string) []*oc.PolicyDefinition

func (*RoutingPolicy) GetPolicyAssignment

func (r *RoutingPolicy) GetPolicyAssignment(id string, dir PolicyDirection) (RouteType, []*Policy, error)

func (*RoutingPolicy) GetStatement

func (r *RoutingPolicy) GetStatement(name string) []*oc.Statement

func (*RoutingPolicy) Initialize

func (r *RoutingPolicy) Initialize() error

func (*RoutingPolicy) Reset

func (r *RoutingPolicy) Reset(rp *oc.RoutingPolicy, ap map[string]oc.ApplyPolicy) error

func (*RoutingPolicy) SetPeerPolicy

func (r *RoutingPolicy) SetPeerPolicy(peerId string, c oc.ApplyPolicy) error

func (*RoutingPolicy) SetPolicyAssignment

func (r *RoutingPolicy) SetPolicyAssignment(id string, dir PolicyDirection, policies []*oc.PolicyDefinition, def RouteType) (err error)

type RpkiValidationCondition

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

func (*RpkiValidationCondition) Evaluate

func (c *RpkiValidationCondition) Evaluate(path *Path, options *PolicyOptions) bool

func (*RpkiValidationCondition) Name

func (c *RpkiValidationCondition) Name() string

func (*RpkiValidationCondition) Set

func (*RpkiValidationCondition) String

func (c *RpkiValidationCondition) String() string

func (*RpkiValidationCondition) Type

type RpkiValidationReasonType

type RpkiValidationReasonType string
const (
	RPKI_VALIDATION_REASON_TYPE_NONE   RpkiValidationReasonType = "none"
	RPKI_VALIDATION_REASON_TYPE_AS     RpkiValidationReasonType = "as"
	RPKI_VALIDATION_REASON_TYPE_LENGTH RpkiValidationReasonType = "length"
)

func (RpkiValidationReasonType) ToInt

func (v RpkiValidationReasonType) ToInt() int

type Statement

type Statement struct {
	Name        string
	Conditions  []Condition
	RouteAction Action
	ModActions  []Action
}

func NewStatement

func NewStatement(c oc.Statement) (*Statement, error)

func (*Statement) Add

func (lhs *Statement) Add(rhs *Statement) error

func (*Statement) Apply

func (s *Statement) Apply(logger *slog.Logger, path *Path, options *PolicyOptions) (RouteType, *Path)

func (*Statement) Evaluate

func (s *Statement) Evaluate(p *Path, options *PolicyOptions) bool

evaluate each condition in the statement according to MatchSetOptions

func (*Statement) MarshalJSON

func (s *Statement) MarshalJSON() ([]byte, error)

func (*Statement) Remove

func (lhs *Statement) Remove(rhs *Statement) error

func (*Statement) Replace

func (lhs *Statement) Replace(rhs *Statement) error

func (*Statement) ToConfig

func (s *Statement) ToConfig() *oc.Statement

type Table

type Table struct {
	Family bgp.Family
	// contains filtered or unexported fields
}

func NewTable

func NewTable(logger *slog.Logger, rf bgp.Family, dsts ...*Destination) *Table

func (*Table) Bests

func (t *Table) Bests(id string, as uint32) []*Path

func (*Table) GetDestination

func (t *Table) GetDestination(nlri bgp.NLRI) *Destination

func (*Table) GetDestinations

func (t *Table) GetDestinations() []*Destination

func (*Table) GetEvpnDestinationsWithRouteType

func (t *Table) GetEvpnDestinationsWithRouteType(typ string) ([]*Destination, error)

func (*Table) GetFamily

func (t *Table) GetFamily() bgp.Family

func (*Table) GetKnownPathList

func (t *Table) GetKnownPathList(id string, as uint32) []*Path

func (*Table) GetKnownPathListWithMac

func (t *Table) GetKnownPathListWithMac(id string, as uint32, rt bgp.ExtendedCommunityInterface, mac net.HardwareAddr, onlyBest bool) []*Path

func (*Table) GetLongerPrefixDestinations

func (t *Table) GetLongerPrefixDestinations(key string) ([]*Destination, error)

func (*Table) GetMUPDestinationsWithRouteType

func (t *Table) GetMUPDestinationsWithRouteType(p string) ([]*Destination, error)

func (*Table) Info

func (t *Table) Info(option ...TableInfoOptions) *TableInfo

func (*Table) MultiBests

func (t *Table) MultiBests(id string) [][]*Path

func (*Table) Select

func (t *Table) Select(option ...TableSelectOption) (*Table, error)

type TableInfo

type TableInfo struct {
	NumDestination int
	NumPath        int
	NumAccepted    int
	NumCollision   int
}

type TableInfoOptions

type TableInfoOptions struct {
	ID  string
	AS  uint32
	VRF *Vrf
}

type TableManager

type TableManager struct {
	Tables map[bgp.Family]*Table
	Vrfs   map[string]*Vrf
	// contains filtered or unexported fields
}

func NewTableManager

func NewTableManager(logger *slog.Logger, rfList []bgp.Family) *TableManager

func (*TableManager) AddVrf

func (manager *TableManager) AddVrf(name string, id uint32, rd bgp.RouteDistinguisherInterface, importRt, exportRt []bgp.ExtendedCommunityInterface, info *PeerInfo) ([]*Path, error)

func (*TableManager) DeleteVrf

func (manager *TableManager) DeleteVrf(name string) ([]*Path, error)

func (*TableManager) GetBestMultiPathList

func (manager *TableManager) GetBestMultiPathList(id string, rfList []bgp.Family) [][]*Path

func (*TableManager) GetBestPathList

func (manager *TableManager) GetBestPathList(id string, as uint32, rfList []bgp.Family) []*Path

func (*TableManager) GetDestination

func (manager *TableManager) GetDestination(path *Path) *Destination

func (*TableManager) GetPathList

func (manager *TableManager) GetPathList(id string, as uint32, rfList []bgp.Family) []*Path

func (*TableManager) GetPathListWithMac

func (manager *TableManager) GetPathListWithMac(id string, as uint32, rfList []bgp.Family, rt bgp.ExtendedCommunityInterface, mac net.HardwareAddr) []*Path

func (*TableManager) GetPathListWithNexthop

func (manager *TableManager) GetPathListWithNexthop(id string, rfList []bgp.Family, nexthop netip.Addr) []*Path

func (*TableManager) GetPathListWithSource

func (manager *TableManager) GetPathListWithSource(id string, rfList []bgp.Family, source *PeerInfo) []*Path

func (*TableManager) GetRFlist

func (manager *TableManager) GetRFlist() []bgp.Family

func (*TableManager) Update

func (manager *TableManager) Update(newPath *Path) []*Update

type TableSelectOption

type TableSelectOption struct {
	ID             string
	AS             uint32
	LookupPrefixes []*apiutil.LookupPrefix
	VRF            *Vrf

	Best      bool
	MultiPath bool
	// contains filtered or unexported fields
}

type Update

type Update struct {
	KnownPathList    []*Path
	OldKnownPathList []*Path
}

func (*Update) GetChanges

func (u *Update) GetChanges(id string, as uint32, peerDown bool) (*Path, *Path, []*Path)

func (*Update) GetWithdrawnPath

func (u *Update) GetWithdrawnPath() []*Path

type Validation

type Validation struct {
	Status          oc.RpkiValidationResultType
	Reason          RpkiValidationReasonType
	Matched         []*ROA
	UnmatchedAs     []*ROA
	UnmatchedLength []*ROA
}

type Vrf

type Vrf struct {
	Name      string
	Id        uint32
	Rd        bgp.RouteDistinguisherInterface
	ImportRt  routeTargetMap
	ExportRt  []bgp.ExtendedCommunityInterface
	MplsLabel uint32
}

func (*Vrf) Clone

func (v *Vrf) Clone() *Vrf

func (*Vrf) ToGlobalPath

func (v *Vrf) ToGlobalPath(path *Path) error

Jump to

Keyboard shortcuts

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