diff options
-rw-r--r-- | server/peer.go | 10 | ||||
-rw-r--r-- | server/server.go | 21 |
2 files changed, 12 insertions, 19 deletions
diff --git a/server/peer.go b/server/peer.go index 4432af9b..b5a62b88 100644 --- a/server/peer.go +++ b/server/peer.go @@ -125,6 +125,16 @@ func (peer *Peer) getAccepted(rfList []bgp.RouteFamily) []*table.Path { return pathList } +func (peer *Peer) getBestFromLocal() ([]*table.Path, []*table.Path) { + pathList, filtered := peer.ApplyPolicy(table.POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(peer.localRib))) + if peer.isRouteServerClient() == false { + for _, path := range pathList { + path.UpdatePathAttrs(&peer.gConf, &peer.conf) + } + } + return pathList, filtered +} + func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*bgp.BGPMessage) { bgpMsgList := []*bgp.BGPMessage{} pathList := []*table.Path{} 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))) |