diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-21 09:10:39 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-10-21 09:10:39 +0900 |
commit | ec8c83d950c25a6b6d8b75655f9c48907dc9afd8 (patch) | |
tree | 4a5cc9c0c8a8265af51290423ebe545928b2c2d3 /server/server.go | |
parent | 6be902345412117bf098e6d115c27ec49085432c (diff) |
server: make getBestFromLocal peer's method
Will be used to handle ROUTE_REFRESH.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/server/server.go b/server/server.go index 1cec47b8..391dc40c 100644 --- a/server/server.go +++ b/server/server.go @@ -737,7 +737,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan * } server.broadcastMsgs = append(server.broadcastMsgs, m) } - pathList, _ := server.getBestFromLocal(peer) + pathList, _ := peer.getBestFromLocal() if len(pathList) > 0 { peer.adjRib.UpdateOut(pathList) msgs = append(msgs, newSenderMsg(peer, table.CreateUpdateMsgFromPaths(pathList))) @@ -1268,23 +1268,6 @@ func sendMultipleResponses(grpcReq *GrpcRequest, results []*GrpcResponse) { } } -func (server *BgpServer) getBestFromLocal(peer *Peer) ([]*table.Path, []*table.Path) { - var pathList []*table.Path - var filtered []*table.Path - if peer.isRouteServerClient() { - pathList, filtered = peer.ApplyPolicy(table.POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(peer.localRib))) - } else { - rib := server.globalRib - bests := rib.ApplyPolicy(table.POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(rib))) - pathList = make([]*table.Path, 0, len(bests)) - for _, path := range bests { - path.UpdatePathAttrs(&server.bgpConfig.Global, &peer.conf) - pathList = append(pathList, path) - } - } - return pathList, filtered -} - func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { var msgs []*SenderMsg @@ -1514,7 +1497,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { peer.adjRib.DropOut(rf) } - pathList, filtered := server.getBestFromLocal(peer) + pathList, filtered := peer.getBestFromLocal() if len(pathList) > 0 { peer.adjRib.UpdateOut(pathList) msgs = append(msgs, newSenderMsg(peer, table.CreateUpdateMsgFromPaths(pathList))) |