diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-02-10 23:41:44 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-10 23:41:44 -0800 |
commit | 023a498e4a90982095c870c5491770bf4952fc2b (patch) | |
tree | 135c11a05d8ff106264d91f0965aa6d926ac861b /table | |
parent | b19bbd415e8d33f01bcd407baece94ea1b81c957 (diff) |
server: support graceful-restart helper-speaker behavior
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
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 { |