diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-05-28 15:22:02 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-05-28 22:53:38 +0900 |
commit | ff09df9841485e6dec5ac228d6c1a55c1f2e5245 (patch) | |
tree | 486db15c6c702137e88d95d74b79a2c6f50975e8 | |
parent | a75bcf3e9ee18e4e61f4852cae34d54df5cef868 (diff) |
table: fix accepted number in adj-in rib
fix accepted number in adj-in rib when it has an as-looped path.
adding another member to Path struct is pain. Should be fixed later.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | server/peer.go | 13 | ||||
-rw-r--r-- | table/adj.go | 20 | ||||
-rw-r--r-- | table/path.go | 9 |
3 files changed, 33 insertions, 9 deletions
diff --git a/server/peer.go b/server/peer.go index 1ae83afd..e3981024 100644 --- a/server/peer.go +++ b/server/peer.go @@ -426,12 +426,6 @@ func (peer *Peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bg }).Debug("received update") peer.fsm.pConf.Timers.State.UpdateRecvTime = time.Now().Unix() if len(e.PathList) > 0 { - peer.adjRibIn.Update(e.PathList) - for _, af := range peer.fsm.pConf.AfiSafis { - if msg := peer.doPrefixLimit(af.State.Family, &af.PrefixLimit.Config); msg != nil { - return nil, nil, msg - } - } paths := make([]*table.Path, 0, len(e.PathList)) eor := []bgp.RouteFamily{} for _, path := range e.PathList { @@ -451,11 +445,18 @@ func (peer *Peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bg // route should be excluded from the Phase 2 decision function. if aspath := path.GetAsPath(); aspath != nil { if hasOwnASLoop(peer.fsm.peerInfo.LocalAS, int(peer.fsm.pConf.AsPathOptions.Config.AllowOwnAs), aspath) { + path.SetAsLooped(true) continue } } paths = append(paths, path) } + peer.adjRibIn.Update(e.PathList) + for _, af := range peer.fsm.pConf.AfiSafis { + if msg := peer.doPrefixLimit(af.State.Family, &af.PrefixLimit.Config); msg != nil { + return nil, nil, msg + } + } return paths, eor, nil } return nil, nil, nil diff --git a/table/adj.go b/table/adj.go index 54e0a324..9e4ce528 100644 --- a/table/adj.go +++ b/table/adj.go @@ -49,12 +49,21 @@ func (adj *AdjRib) Update(pathList []*Path) { if path.IsWithdraw { if found { delete(adj.table[rf], key) - adj.accepted[rf]-- + if !old.IsAsLooped() { + adj.accepted[rf]-- + } } } else { if found { + if old.IsAsLooped() && !path.IsAsLooped() { + adj.accepted[rf]++ + } else if !old.IsAsLooped() && path.IsAsLooped() { + adj.accepted[rf]-- + } } else { - adj.accepted[rf]++ + if !path.IsAsLooped() { + adj.accepted[rf]++ + } } if found && old.Equal(path) { path.setTimestamp(old.GetTimestamp()) @@ -74,6 +83,9 @@ func (adj *AdjRib) PathList(rfList []bgp.RouteFamily, accepted bool) []*Path { pathList := make([]*Path, 0, adj.Count(rfList)) for _, rf := range rfList { for _, rr := range adj.table[rf] { + if accepted && rr.IsAsLooped() { + continue + } pathList = append(pathList, rr) } } @@ -116,7 +128,9 @@ func (adj *AdjRib) DropStale(rfList []bgp.RouteFamily) []*Path { for _, p := range table { if p.IsStale() { delete(table, p.getPrefix()) - adj.accepted[rf]-- + if !p.IsAsLooped() { + adj.accepted[rf]-- + } pathList = append(pathList, p.Clone(true)) } } diff --git a/table/path.go b/table/path.go index 3e4fbff3..62f277d4 100644 --- a/table/path.go +++ b/table/path.go @@ -144,6 +144,7 @@ type Path struct { dels []bgp.BGPAttrType // For BGP Nexthop Tracking, this field shows if nexthop is invalidated by IGP. IsNexthopInvalid bool + aslooped bool } func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool) *Path { @@ -394,6 +395,14 @@ func (path *Path) IsStale() bool { return path.OriginInfo().stale } +func (path *Path) IsAsLooped() bool { + return path.aslooped +} + +func (path *Path) SetAsLooped(y bool) { + path.aslooped = y +} + func (path *Path) IsLLGRStale() bool { for _, c := range path.GetCommunities() { if c == bgp.COMMUNITY_LLGR_STALE { |