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 | |
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>
-rw-r--r-- | server/server.go | 42 | ||||
-rw-r--r-- | table/table_manager.go | 13 |
2 files changed, 37 insertions, 18 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) diff --git a/table/table_manager.go b/table/table_manager.go index 6ec65617..6ea2841a 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -490,10 +490,19 @@ func (adj *AdjRib) GetOutCount(rf bgp.RouteFamily) int { return len(adj.adjRibOut[rf]) } -func (adj *AdjRib) DropAll(rf bgp.RouteFamily) { +func (adj *AdjRib) DropIn(rf bgp.RouteFamily) { if _, ok := adj.adjRibIn[rf]; ok { - // replace old one adj.adjRibIn[rf] = make(map[string]*Path) + } +} + +func (adj *AdjRib) DropOut(rf bgp.RouteFamily) { + if _, ok := adj.adjRibIn[rf]; ok { adj.adjRibOut[rf] = make(map[string]*Path) } } + +func (adj *AdjRib) DropAll(rf bgp.RouteFamily) { + adj.DropIn(rf) + adj.DropOut(rf) +} |