diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-29 22:44:30 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-29 23:34:32 +0900 |
commit | 7c341b9f79778af55a32880f359cf1a0c036be42 (patch) | |
tree | 385e9da471ba4ce28e1c179d71b0fda1df5dcbfd | |
parent | 498400adad996de4ebaea8311d72dfe38d9aff28 (diff) |
server: apply filterpath and export-policy to new best paths
dropPeerAllRoutes doesn't always produce withdrawals.
When there are alternative routes, new best paths will be advertised.
We must apply filterpath and export-policy to these routes.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | server/server.go | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/server/server.go b/server/server.go index 5de93730..2d508434 100644 --- a/server/server.go +++ b/server/server.go @@ -562,11 +562,11 @@ func filterpath(peer *Peer, path *table.Path) *table.Path { func (server *BgpServer) dropPeerAllRoutes(peer *Peer) []*SenderMsg { msgs := make([]*SenderMsg, 0) + options := &table.PolicyOptions{} for _, rf := range peer.configuredRFlist() { dsts := server.globalRib.DeletePathsByPeer(peer.fsm.peerInfo, rf) server.validatePaths(dsts, true) if peer.isRouteServerClient() { - pathList := make([]*table.Path, len(dsts)) for _, targetPeer := range server.neighborMap { if !targetPeer.isRouteServerClient() || targetPeer == peer || targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED { continue @@ -574,32 +574,31 @@ func (server *BgpServer) dropPeerAllRoutes(peer *Peer) []*SenderMsg { if _, ok := targetPeer.fsm.rfMap[rf]; !ok { continue } - - i := 0 + pathList := make([]*table.Path, 0, len(dsts)) + options.Neighbor = targetPeer.fsm.peerInfo.Address for _, dst := range dsts { - feed := dst.NewFeed(targetPeer.TableID()) - pathList[i] = feed - i++ + if path := server.policy.ApplyPolicy(targetPeer.TableID(), table.POLICY_DIRECTION_EXPORT, filterpath(targetPeer, dst.NewFeed(targetPeer.TableID())), options); path != nil { + pathList = append(pathList, path) + } } msgList := table.CreateUpdateMsgFromPaths(pathList) msgs = append(msgs, newSenderMsg(targetPeer, msgList)) targetPeer.adjRibOut.Update(pathList) } } else { - pathList := make([]*table.Path, 0, len(dsts)) + sendPathList := make([]*table.Path, 0, len(dsts)) for _, dst := range dsts { path := dst.NewFeed(table.GLOBAL_RIB_NAME) if path != nil { - pathList = append(pathList, path) + sendPathList = append(sendPathList, path) } } - if len(pathList) == 0 { + if len(sendPathList) == 0 { return msgs } - server.broadcastBests(pathList) + server.broadcastBests(sendPathList) - msgList := table.CreateUpdateMsgFromPaths(pathList) for _, targetPeer := range server.neighborMap { if targetPeer.isRouteServerClient() || targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED { continue @@ -607,7 +606,16 @@ func (server *BgpServer) dropPeerAllRoutes(peer *Peer) []*SenderMsg { if _, ok := targetPeer.fsm.rfMap[rf]; !ok { continue } + pathList := make([]*table.Path, 0, len(sendPathList)) + options.Neighbor = targetPeer.fsm.peerInfo.Address + for _, path := range sendPathList { + if path := server.policy.ApplyPolicy(table.GLOBAL_RIB_NAME, table.POLICY_DIRECTION_EXPORT, filterpath(targetPeer, path), options); path != nil { + pathList = append(pathList, path) + } + } targetPeer.adjRibOut.Update(pathList) + msgList := table.CreateUpdateMsgFromPaths(pathList) + msgs = append(msgs, newSenderMsg(targetPeer, msgList)) } } |