diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-07 22:09:41 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-07 22:09:41 +0900 |
commit | 8669c4ecea81038d2a09dcd6121ad488528f04b9 (patch) | |
tree | 25ae5490ceec71dddcfdf23d042176147ebdc691 | |
parent | 72c2e8ba39239a0b497aff554c4b5b2e8d5c94b2 (diff) |
server: need to send withdrawn for filtered routes after softreset
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | server/peer.go | 6 | ||||
-rw-r--r-- | server/server.go | 26 |
2 files changed, 21 insertions, 11 deletions
diff --git a/server/peer.go b/server/peer.go index 7029553a..a370b1af 100644 --- a/server/peer.go +++ b/server/peer.go @@ -423,8 +423,9 @@ func (peer *Peer) GetDefaultPolicy(d PolicyDirection) policy.RouteType { return policy.ROUTE_TYPE_REJECT } -func (peer *Peer) ApplyPolicy(d PolicyDirection, paths []*table.Path) []*table.Path { +func (peer *Peer) ApplyPolicy(d PolicyDirection, paths []*table.Path) ([]*table.Path, []*table.Path) { newpaths := make([]*table.Path, 0, len(paths)) + filteredPaths := make([]*table.Path, 0) for _, path := range paths { result := policy.ROUTE_TYPE_NONE newpath := path @@ -447,6 +448,7 @@ func (peer *Peer) ApplyPolicy(d PolicyDirection, paths []*table.Path) []*table.P } case policy.ROUTE_TYPE_REJECT: path.Filtered = true + filteredPaths = append(filteredPaths, path) log.WithFields(log.Fields{ "Topic": "Peer", "Key": peer.conf.NeighborConfig.NeighborAddress, @@ -455,7 +457,7 @@ func (peer *Peer) ApplyPolicy(d PolicyDirection, paths []*table.Path) []*table.P }).Debug("reject") } } - return newpaths + return newpaths, filteredPaths } func (peer *Peer) DropAll(rf bgp.RouteFamily) { diff --git a/server/server.go b/server/server.go index 70363995..f41066a9 100644 --- a/server/server.go +++ b/server/server.go @@ -383,7 +383,7 @@ func (server *BgpServer) Serve() { pathList = append(pathList, p.adjRib.GetInPathList(rf)...) } } - pathList = peer.ApplyPolicy(POLICY_DIRECTION_IMPORT, pathList) + pathList, _ = peer.ApplyPolicy(POLICY_DIRECTION_IMPORT, pathList) if len(pathList) > 0 { rib.ProcessPaths(pathList) } @@ -666,18 +666,19 @@ func (server *BgpServer) broadcastPeerState(peer *Peer) { func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []*SenderMsg { msgs := make([]*SenderMsg, 0) if peer != nil && peer.isRouteServerClient() { - pathList = peer.ApplyPolicy(POLICY_DIRECTION_IN, pathList) + pathList, _ = peer.ApplyPolicy(POLICY_DIRECTION_IN, pathList) for _, rib := range server.localRibMap { targetPeer := server.neighborMap[rib.OwnerName()] neighborAddress := peer.conf.NeighborConfig.NeighborAddress.String() if rib.OwnerName() == GLOBAL_RIB_NAME || rib.OwnerName() == neighborAddress { continue } - sendPathList, _ := rib.ProcessPaths(targetPeer.ApplyPolicy(POLICY_DIRECTION_IMPORT, pathList)) + sendPathList, _ := targetPeer.ApplyPolicy(POLICY_DIRECTION_IMPORT, pathList) + sendPathList, _ = rib.ProcessPaths(sendPathList) if targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED || len(sendPathList) == 0 { continue } - sendPathList = targetPeer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(targetPeer, sendPathList)) + sendPathList, _ = targetPeer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(targetPeer, sendPathList)) if len(sendPathList) == 0 { continue } @@ -756,7 +757,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan * } server.broadcastMsgs = append(server.broadcastMsgs, m) } - pathList := server.getBestFromLocal(peer) + pathList, _ := server.getBestFromLocal(peer) if len(pathList) > 0 { peer.adjRib.UpdateOut(pathList) msgs = append(msgs, newSenderMsg(peer, table.CreateUpdateMsgFromPaths(pathList))) @@ -1256,11 +1257,12 @@ func sendMultipleResponses(grpcReq *GrpcRequest, results []*GrpcResponse) { } } -func (server *BgpServer) getBestFromLocal(peer *Peer) []*table.Path { +func (server *BgpServer) getBestFromLocal(peer *Peer) ([]*table.Path, []*table.Path) { pathList := make([]*table.Path, 0) + filtered := make([]*table.Path, 0) if peer.isRouteServerClient() { rib := server.localRibMap[peer.conf.NeighborConfig.NeighborAddress.String()] - pathList = peer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(rib))) + pathList, filtered = peer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(rib))) } else { rib := server.localRibMap[GLOBAL_RIB_NAME] l, _ := peer.fsm.LocalHostPort() @@ -1270,7 +1272,7 @@ func (server *BgpServer) getBestFromLocal(peer *Peer) []*table.Path { pathList = append(pathList, path) } } - return pathList + return pathList, filtered } func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { @@ -1481,11 +1483,17 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { for _, rf := range peer.configuredRFlist() { peer.adjRib.DropOut(rf) } - pathList := server.getBestFromLocal(peer) + pathList, filtered := server.getBestFromLocal(peer) if len(pathList) > 0 { peer.adjRib.UpdateOut(pathList) msgs = []*SenderMsg{newSenderMsg(peer, table.CreateUpdateMsgFromPaths(pathList))} } + if len(filtered) > 0 { + for _, p := range filtered { + p.IsWithdraw = true + } + msgs = append(msgs, newSenderMsg(peer, table.CreateUpdateMsgFromPaths(filtered))) + } grpcReq.ResponseCh <- &GrpcResponse{} close(grpcReq.ResponseCh) |