diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-07 08:50:55 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-07 08:50:55 +0900 |
commit | 72c2e8ba39239a0b497aff554c4b5b2e8d5c94b2 (patch) | |
tree | 4c4a59aee57bb04a2e89c34d8dd96f5f7a65361f /server | |
parent | 4b0830a5fe7ba20d9bb100b2bd03a944d634b447 (diff) |
server: fix soft reset out
soft reset out needs to use routes in the local table instead of the
adj-in. The export policy will be applied correctly.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/server/server.go b/server/server.go index 2900f55b..70363995 100644 --- a/server/server.go +++ b/server/server.go @@ -756,19 +756,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan * } server.broadcastMsgs = append(server.broadcastMsgs, m) } - pathList := 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))) - } else { - rib := server.localRibMap[GLOBAL_RIB_NAME] - l, _ := peer.fsm.LocalHostPort() - peer.conf.Transport.TransportConfig.LocalAddress = net.ParseIP(l) - for _, path := range filterpath(peer, peer.getBests(rib)) { - path.UpdatePathAttrs(&server.bgpConfig.Global, &peer.conf) - pathList = append(pathList, path) - } - } + pathList := server.getBestFromLocal(peer) if len(pathList) > 0 { peer.adjRib.UpdateOut(pathList) msgs = append(msgs, newSenderMsg(peer, table.CreateUpdateMsgFromPaths(pathList))) @@ -1268,6 +1256,23 @@ func sendMultipleResponses(grpcReq *GrpcRequest, results []*GrpcResponse) { } } +func (server *BgpServer) getBestFromLocal(peer *Peer) []*table.Path { + pathList := 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))) + } else { + rib := server.localRibMap[GLOBAL_RIB_NAME] + l, _ := peer.fsm.LocalHostPort() + peer.conf.Transport.TransportConfig.LocalAddress = net.ParseIP(l) + for _, path := range filterpath(peer, peer.getBests(rib)) { + path.UpdatePathAttrs(&server.bgpConfig.Global, &peer.conf) + pathList = append(pathList, path) + } + } + return pathList +} + func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { var msgs []*SenderMsg @@ -1473,9 +1478,14 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { if grpcReq.RequestType == REQ_NEIGHBOR_SOFT_RESET_OUT { logOp(peer, "Neighbor soft reset out") } - pathList := peer.adjRib.GetOutPathList(grpcReq.RouteFamily) - msgList := table.CreateUpdateMsgFromPaths(pathList) - msgs = []*SenderMsg{newSenderMsg(peer, msgList)} + for _, rf := range peer.configuredRFlist() { + peer.adjRib.DropOut(rf) + } + pathList := server.getBestFromLocal(peer) + if len(pathList) > 0 { + peer.adjRib.UpdateOut(pathList) + msgs = []*SenderMsg{newSenderMsg(peer, table.CreateUpdateMsgFromPaths(pathList))} + } grpcReq.ResponseCh <- &GrpcResponse{} close(grpcReq.ResponseCh) |