diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 14 | ||||
-rw-r--r-- | server/server.go | 18 |
2 files changed, 17 insertions, 15 deletions
diff --git a/server/peer.go b/server/peer.go index 4c76248c..15c25353 100644 --- a/server/peer.go +++ b/server/peer.go @@ -233,7 +233,7 @@ func (peer *Peer) getAccepted(rfList []bgp.RouteFamily) []*table.Path { return peer.adjRibIn.PathList(rfList, true) } -func (peer *Peer) filterpath(path *table.Path, withdrawals []*table.Path) *table.Path { +func (peer *Peer) filterpath(path, old *table.Path) *table.Path { // special handling for RTC nlri // see comments in (*Destination).Calculate() if path != nil && path.GetRouteFamily() == bgp.RF_RTC_UC && !path.IsWithdraw { @@ -268,7 +268,7 @@ func (peer *Peer) filterpath(path *table.Path, withdrawals []*table.Path) *table } } - if path = filterpath(peer, path, withdrawals); path == nil { + if path = filterpath(peer, path, old); path == nil { return nil } @@ -324,7 +324,7 @@ func (peer *Peer) getBestFromLocal(rfList []bgp.RouteFamily) ([]*table.Path, []* return pathList, filtered } -func (peer *Peer) processOutgoingPaths(paths, withdrawals []*table.Path) []*table.Path { +func (peer *Peer) processOutgoingPaths(paths, olds []*table.Path) []*table.Path { if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED { return nil } @@ -338,8 +338,12 @@ func (peer *Peer) processOutgoingPaths(paths, withdrawals []*table.Path) []*tabl outgoing := make([]*table.Path, 0, len(paths)) - for _, path := range paths { - if p := peer.filterpath(path, withdrawals); p != nil { + for idx, path := range paths { + var old *table.Path + if olds != nil { + old = olds[idx] + } + if p := peer.filterpath(path, old); p != nil { outgoing = append(outgoing, p) } } diff --git a/server/server.go b/server/server.go index 263bc00c..e97fd7f6 100644 --- a/server/server.go +++ b/server/server.go @@ -269,7 +269,7 @@ func isASLoop(peer *Peer, path *table.Path) bool { return false } -func filterpath(peer *Peer, path *table.Path, withdrawals []*table.Path) *table.Path { +func filterpath(peer *Peer, path, old *table.Path) *table.Path { if path == nil { return nil } @@ -377,10 +377,8 @@ func filterpath(peer *Peer, path *table.Path, withdrawals []*table.Path) *table. // the withdrawal path. // Thing is same when peer A and we advertized prefix P (as local // route), then, we withdraws the prefix. - for _, w := range withdrawals { - if path.GetNlri().String() == w.GetNlri().String() { - return w - } + if old != nil { + return old.Clone(true) } } log.WithFields(log.Fields{ @@ -512,8 +510,8 @@ func (server *BgpServer) RSimportPaths(peer *Peer, pathList []*table.Path) []*ta func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []*table.Path { rib := server.globalRib - var alteredPathList, withdrawn []*table.Path - var best map[string][]*table.Path + var alteredPathList []*table.Path + var best, old map[string][]*table.Path if peer != nil && peer.fsm.pConf.Config.Vrf != "" { vrf := server.globalRib.Vrfs[peer.fsm.pConf.Config.Vrf] @@ -544,7 +542,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []* ids = append(ids, targetPeer.TableID()) } } - best, withdrawn, _ = rib.ProcessPaths(ids, append(pathList, moded...)) + best, old, _ = rib.ProcessPaths(ids, append(pathList, moded...)) } else { for idx, path := range pathList { path = server.policy.ApplyPolicy(table.GLOBAL_RIB_NAME, table.POLICY_DIRECTION_IMPORT, path, nil) @@ -596,7 +594,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []* } alteredPathList = pathList var multipath [][]*table.Path - best, withdrawn, multipath = rib.ProcessPaths([]string{table.GLOBAL_RIB_NAME}, pathList) + best, old, multipath = rib.ProcessPaths([]string{table.GLOBAL_RIB_NAME}, pathList) if len(best[table.GLOBAL_RIB_NAME]) == 0 { return alteredPathList } @@ -607,7 +605,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []* if (peer == nil && targetPeer.isRouteServerClient()) || (peer != nil && peer.isRouteServerClient() != targetPeer.isRouteServerClient()) { continue } - if paths := targetPeer.processOutgoingPaths(best[targetPeer.TableID()], withdrawn); len(paths) > 0 { + if paths := targetPeer.processOutgoingPaths(best[targetPeer.TableID()], old[targetPeer.TableID()]); len(paths) > 0 { sendFsmOutgoingMsg(targetPeer, paths, nil, false) } } |