diff options
Diffstat (limited to 'table')
-rw-r--r-- | table/destination.go | 17 | ||||
-rw-r--r-- | table/path.go | 9 |
2 files changed, 26 insertions, 0 deletions
diff --git a/table/destination.go b/table/destination.go index 58991a35..50b946e9 100644 --- a/table/destination.go +++ b/table/destination.go @@ -47,6 +47,7 @@ const ( BPR_IGP_COST BestPathReason = "IGP Cost" BPR_ROUTER_ID BestPathReason = "Router ID" BPR_OLDER BestPathReason = "Older" + BPR_NON_LLGR_STALE BestPathReason = "no LLGR Stale" ) func IpToRadixkey(b []byte, max uint8) string { @@ -479,6 +480,11 @@ func (p paths) Less(i, j int) bool { var better *Path reason := BPR_UNKNOWN + // draft-uttaro-idr-bgp-persistence-02 + if better == nil { + better = compareByLLGRStaleCommunity(path1, path2) + reason = BPR_NON_LLGR_STALE + } // Follow best path calculation algorithm steps. // compare by reachability if better == nil { @@ -545,6 +551,17 @@ func (p paths) Less(i, j int) bool { return false } +func compareByLLGRStaleCommunity(path1, path2 *Path) *Path { + p1 := path1.IsLLGRStale() + p2 := path2.IsLLGRStale() + if p1 == p2 { + return nil + } else if p1 { + return path2 + } + return path1 +} + func compareByReachableNexthop(path1, path2 *Path) *Path { // Compares given paths and selects best path based on reachable next-hop. // diff --git a/table/path.go b/table/path.go index b0f21e04..f8058730 100644 --- a/table/path.go +++ b/table/path.go @@ -348,6 +348,15 @@ func (path *Path) IsStale() bool { return path.OriginInfo().stale } +func (path *Path) IsLLGRStale() bool { + for _, c := range path.GetCommunities() { + if c == bgp.COMMUNITY_LLGR_STALE { + return true + } + } + return false +} + func (path *Path) GetSourceAs() uint32 { attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) if attr != nil { |