From 2dbca9e29a6813f2df53261ffaa59b9439c13fdd Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 10 Apr 2018 22:24:41 +0900 Subject: use sorted single master table for route server setup https://github.com/osrg/gobgp/issues/1249 The IN policy was removed. The modification by the IMPORT policy are visible to all route server peers. This saves some dozens bytes memory per a path. Signed-off-by: FUJITA Tomonori --- server/peer.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'server/peer.go') diff --git a/server/peer.go b/server/peer.go index 96cb4170..4be180a5 100644 --- a/server/peer.go +++ b/server/peer.go @@ -340,7 +340,7 @@ func (peer *Peer) filterpath(path, old *table.Path) *table.Path { // (*Destination) GetChanges(). dst := peer.localRib.GetDestination(path) path = nil - for _, p := range dst.GetKnownPathList(peer.TableID()) { + for _, p := range dst.GetKnownPathList(peer.TableID(), peer.AS()) { // Just take care not to send back. if peer.ID() != p.GetSource().Address.String() { path = p @@ -453,9 +453,9 @@ func (peer *Peer) getBestFromLocal(rfList []bgp.RouteFamily) ([]*table.Path, []* for _, family := range peer.toGlobalFamilies(rfList) { pl := func() []*table.Path { if peer.isAddPathSendEnabled(family) { - return peer.localRib.GetPathList(peer.TableID(), []bgp.RouteFamily{family}) + return peer.localRib.GetPathList(peer.TableID(), peer.AS(), []bgp.RouteFamily{family}) } - return peer.localRib.GetBestPathList(peer.TableID(), []bgp.RouteFamily{family}) + return peer.localRib.GetBestPathList(peer.TableID(), peer.AS(), []bgp.RouteFamily{family}) }() for _, path := range pl { if p := peer.filterpath(path, nil); p != nil { @@ -616,11 +616,16 @@ func (peer *Peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bg eor = append(eor, family) continue } - if path.Filtered(peer.ID()) != table.POLICY_DIRECTION_IN { - paths = append(paths, path) - } else { - paths = append(paths, path.Clone(true)) + // RFC4271 9.1.2 Phase 2: Route Selection + // + // If the AS_PATH attribute of a BGP route contains an AS loop, the BGP + // 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) { + continue + } } + paths = append(paths, path) } return paths, eor, nil } -- cgit v1.2.3