diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 10 | ||||
-rw-r--r-- | server/server.go | 12 |
2 files changed, 11 insertions, 11 deletions
diff --git a/server/peer.go b/server/peer.go index 1649b2c2..e1f5964f 100644 --- a/server/peer.go +++ b/server/peer.go @@ -172,10 +172,8 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*b break } table.UpdatePathAttrs4ByteAs(body) - originalPaths := table.ProcessMessage(m, peer.peerInfo) - peer.adjRib.UpdateIn(originalPaths) - // apply distribute filter before propagate - pathList = applyPolicies(peer, nil, POLICY_DIRECTION_DISTRIBUTE, originalPaths) + pathList = table.ProcessMessage(m, peer.peerInfo) + peer.adjRib.UpdateIn(pathList) } return pathList, update, bgpMsgList } @@ -302,7 +300,7 @@ func (peer *Peer) ToApiStruct() *api.Peer { } } -func (peer *Peer) setPolicy(policyMap map[string]*policy.Policy) { +func (peer *Peer) setDistributePolicy(policyMap map[string]*policy.Policy) { // configure distribute policy policyConfig := peer.config.ApplyPolicy distPolicies := make([]*policy.Policy, 0) @@ -322,7 +320,7 @@ func (peer *Peer) setPolicy(policyMap map[string]*policy.Policy) { } -func (peer *Peer) applyPolicies(original table.Path) (bool, table.Path) { +func (peer *Peer) applyDistributePolicies(original table.Path) (bool, table.Path) { policies := peer.distPolicies var d Direction = POLICY_DIRECTION_DISTRIBUTE diff --git a/server/server.go b/server/server.go index e6f41c47..b2d5a293 100644 --- a/server/server.go +++ b/server/server.go @@ -209,7 +209,7 @@ func (server *BgpServer) Serve() { server.addLocalRib(loc) loc.setPolicy(peer, server.policyMap) // set distribute policy - peer.setPolicy(server.policyMap) + peer.setDistributePolicy(server.policyMap) pathList := make([]*table.Path, 0) for _, p := range server.neighborMap { @@ -403,7 +403,7 @@ func applyPolicies(peer *Peer, loc *LocalRib, d Direction, pathList []*table.Pat if !path.IsWithdraw { var applied bool = false if d == POLICY_DIRECTION_DISTRIBUTE { - applied, path = peer.applyPolicies(path) + applied, path = peer.applyDistributePolicies(path) } else { applied, path = loc.applyPolicies(d, path) } @@ -482,12 +482,14 @@ func (server *BgpServer) propagateUpdate(neighborAddress string, RouteServerClie msgs := make([]*SenderMsg, 0) if RouteServerClient { + p := server.neighborMap[neighborAddress] + newPathList := applyPolicies(p, nil, POLICY_DIRECTION_DISTRIBUTE, pathList) for _, loc := range server.localRibMap { targetPeer := server.neighborMap[loc.OwnerName()] if loc.isGlobal() || loc.OwnerName() == neighborAddress { continue } - sendPathList, _ := loc.rib.ProcessPaths(applyPolicies(targetPeer, loc, POLICY_DIRECTION_IMPORT, dropSameAsPath(targetPeer.config.PeerAs, filterpath(targetPeer, pathList)))) + sendPathList, _ := loc.rib.ProcessPaths(applyPolicies(targetPeer, loc, POLICY_DIRECTION_IMPORT, dropSameAsPath(targetPeer.config.PeerAs, filterpath(targetPeer, newPathList)))) if targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED || len(sendPathList) == 0 { continue } @@ -651,7 +653,7 @@ func (server *BgpServer) handlePolicy(pl config.RoutingPolicy) { }).Info("call set policy") loc.setPolicy(targetPeer, server.policyMap) // set distribute policy - targetPeer.setPolicy(server.policyMap) + targetPeer.setDistributePolicy(server.policyMap) } } @@ -1132,7 +1134,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { if grpcReq.RequestType == REQ_NEIGHBOR_POLICY_ADD_DISTRIBUTE || grpcReq.RequestType == REQ_NEIGHBOR_POLICY_DEL_DISTRIBUTE { - peer.setPolicy(reqPolicyMap) + peer.setDistributePolicy(reqPolicyMap) } else { loc := server.localRibMap[peer.config.NeighborAddress.String()] loc.setPolicy(peer, reqPolicyMap) |