diff options
Diffstat (limited to 'table')
-rw-r--r-- | table/adj.go | 28 | ||||
-rw-r--r-- | table/path.go | 10 |
2 files changed, 38 insertions, 0 deletions
diff --git a/table/adj.go b/table/adj.go index 77660fab..411f74f0 100644 --- a/table/adj.go +++ b/table/adj.go @@ -133,3 +133,31 @@ func (adj *AdjRib) Drop(rfList []bgp.RouteFamily) { } } } + +func (adj *AdjRib) DropStale(rfList []bgp.RouteFamily) []*Path { + pathList := make([]*Path, 0, adj.Count(rfList)) + for _, rf := range rfList { + if table, ok := adj.table[rf]; ok { + for _, p := range table { + if p.IsStale() { + delete(table, p.getPrefix()) + if p.Filtered(adj.id) == POLICY_DIRECTION_NONE { + adj.accepted[rf]-- + } + pathList = append(pathList, p.Clone(true)) + } + } + } + } + return pathList +} + +func (adj *AdjRib) StaleAll(rfList []bgp.RouteFamily) { + for _, rf := range rfList { + if table, ok := adj.table[rf]; ok { + for _, p := range table { + p.MarkStale(true) + } + } + } +} diff --git a/table/path.go b/table/path.go index bb3eb7a3..87ba4212 100644 --- a/table/path.go +++ b/table/path.go @@ -55,6 +55,7 @@ type originInfo struct { key string uuid []byte eor bool + stale bool } type Path struct { @@ -237,6 +238,7 @@ func (path *Path) ToApiStruct(id string) *api.Path { Family: family, SourceAsn: path.OriginInfo().source.AS, SourceId: path.OriginInfo().source.ID.String(), + Stale: path.IsStale(), } } @@ -308,6 +310,14 @@ func (path *Path) GetSource() *PeerInfo { return path.OriginInfo().source } +func (path *Path) MarkStale(s bool) { + path.OriginInfo().stale = s +} + +func (path *Path) IsStale() bool { + return path.OriginInfo().stale +} + func (path *Path) GetSourceAs() uint32 { attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) if attr != nil { |