diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-19 14:54:14 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-19 14:54:14 +0900 |
commit | 271d42a440645c6e6b12cdd48bde94bfbf6df7bf (patch) | |
tree | 5adf3908c20b390ca29f0c5a12a57eb5fff9fd4a /server | |
parent | 856f867aea28dcee4d2f7b6d312cefe6808202de (diff) |
gobgp: improve the time to show routes
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/server/server.go b/server/server.go index 063431d6..78e9095f 100644 --- a/server/server.go +++ b/server/server.go @@ -19,6 +19,7 @@ import ( "bytes" "fmt" log "github.com/Sirupsen/logrus" + "github.com/armon/go-radix" "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" @@ -1089,12 +1090,28 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { case REQ_GLOBAL_RIB: if t, ok := server.localRibMap[GLOBAL_RIB_NAME].rib.Tables[grpcReq.RouteFamily]; ok { results := make([]*GrpcResponse, len(t.GetDestinations())) - i := 0 - for _, dst := range t.GetDestinations() { - result := &GrpcResponse{} - result.Data = dst.ToApiStruct() - results[i] = result - i++ + if grpcReq.RouteFamily == bgp.RF_IPv4_UC { + r := radix.New() + for _, dst := range t.GetDestinations() { + result := &GrpcResponse{} + result.Data = dst.ToApiStruct() + r.Insert(dst.RadixKey, result) + } + i := 0 + r.Walk(func(s string, v interface{}) bool { + r, _ := v.(*GrpcResponse) + results[i] = r + i++ + return false + }) + } else { + i := 0 + for _, dst := range t.GetDestinations() { + result := &GrpcResponse{} + result.Data = dst.ToApiStruct() + results[i] = result + i++ + } } go sendMultipleResponses(grpcReq, results) } |