summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/peer.go10
-rw-r--r--server/server.go47
2 files changed, 35 insertions, 22 deletions
diff --git a/server/peer.go b/server/peer.go
index bf4f2928..967a0e5d 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -108,13 +108,19 @@ func (peer *Peer) getBestFromLocal(rfList []bgp.RouteFamily) ([]*table.Path, []*
options := &table.PolicyOptions{
Neighbor: peer.fsm.peerInfo.Address,
}
- for _, path := range peer.localRib.GetBestPathList(peer.TableID(), rfList) {
+ var source []*table.Path
+ if peer.gConf.Collector.Enabled {
+ source = peer.localRib.GetPathList(peer.TableID(), rfList)
+ } else {
+ source = peer.localRib.GetBestPathList(peer.TableID(), rfList)
+ }
+ for _, path := range source {
p := peer.policy.ApplyPolicy(peer.TableID(), table.POLICY_DIRECTION_EXPORT, filterpath(peer, path), options)
if p == nil {
filtered = append(filtered, path)
continue
}
- if !peer.isRouteServerClient() {
+ if !peer.gConf.Collector.Enabled && !peer.isRouteServerClient() {
p = p.Clone(p.IsWithdraw)
p.UpdatePathAttrs(&peer.gConf, &peer.conf)
}
diff --git a/server/server.go b/server/server.go
index c8aba0d9..4dfb2ba2 100644
--- a/server/server.go
+++ b/server/server.go
@@ -896,18 +896,21 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([]
dsts := rib.ProcessPaths(pathList)
server.validatePaths(dsts, false)
sendPathList := make([]*table.Path, 0, len(dsts))
- for _, dst := range dsts {
- path := dst.NewFeed(table.GLOBAL_RIB_NAME)
- if path != nil {
- sendPathList = append(sendPathList, path)
+ if server.bgpConfig.Global.Collector.Enabled {
+ sendPathList = pathList
+ } else {
+ for _, dst := range dsts {
+ path := dst.NewFeed(table.GLOBAL_RIB_NAME)
+ if path != nil {
+ sendPathList = append(sendPathList, path)
+ }
}
- }
- if len(sendPathList) == 0 {
- return msgs, alteredPathList
+ if len(sendPathList) == 0 {
+ return msgs, alteredPathList
+ }
+ server.broadcastBests(sendPathList)
}
- server.broadcastBests(sendPathList)
-
for _, targetPeer := range server.neighborMap {
if targetPeer.isRouteServerClient() || targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED {
continue
@@ -917,7 +920,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([]
options.Neighbor = targetPeer.fsm.peerInfo.Address
for idx, path := range pathList {
path = server.policy.ApplyPolicy(table.GLOBAL_RIB_NAME, table.POLICY_DIRECTION_EXPORT, filterpath(targetPeer, path), options)
- if path != nil {
+ if path != nil && !server.bgpConfig.Global.Collector.Enabled {
path = path.Clone(path.IsWithdraw)
path.UpdatePathAttrs(&server.bgpConfig.Global, &targetPeer.conf)
}
@@ -1357,11 +1360,9 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest) []*table.Pat
case api.Operation_DEL:
if len(arg.Uuid) > 0 {
path := func() *table.Path {
- for _, rf := range server.globalRib.GetRFlist() {
- for _, path := range server.globalRib.GetPathList(table.GLOBAL_RIB_NAME, rf) {
- if len(path.UUID()) > 0 && bytes.Equal(path.UUID(), arg.Uuid) {
- return path
- }
+ for _, path := range server.globalRib.GetPathList(table.GLOBAL_RIB_NAME, server.globalRib.GetRFlist()) {
+ if len(path.UUID()) > 0 && bytes.Equal(path.UUID(), arg.Uuid) {
+ return path
}
}
return nil
@@ -1488,7 +1489,7 @@ func (server *BgpServer) handleVrfRequest(req *GrpcRequest) []*table.Path {
result.ResponseErr = fmt.Errorf("unsupported route family: %s", bgp.RouteFamily(arg.Family))
break
}
- paths := rib.GetPathList(table.GLOBAL_RIB_NAME, rf)
+ paths := rib.GetPathList(table.GLOBAL_RIB_NAME, []bgp.RouteFamily{rf})
dsts := make([]*api.Destination, 0, len(paths))
for _, path := range paths {
ok := table.CanImportToVrf(vrfs[name], path)
@@ -1828,10 +1829,16 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
}
if found {
- r.Insert(table.CidrToRadixkey(key), &api.Destination{
- Prefix: key,
- Paths: []*api.Path{p.ToApiStruct(peer.TableID())},
- })
+ b, _ := r.Get(table.CidrToRadixkey(key))
+ if b == nil {
+ r.Insert(table.CidrToRadixkey(key), &api.Destination{
+ Prefix: key,
+ Paths: []*api.Path{p.ToApiStruct(peer.TableID())},
+ })
+ } else {
+ d := b.(*api.Destination)
+ d.Paths = append(d.Paths, p.ToApiStruct(peer.TableID()))
+ }
}
}
r.Walk(func(s string, v interface{}) bool {