summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-21 11:05:09 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-21 11:05:09 +0900
commit13243a07034fc3bc2e3dc6c86a7bb4f43d469083 (patch)
tree2c8dc4a87f63820adb23d39c515b38d561526f6d /server/server.go
parent78703baf275a21276066ebe4137b329812b6ac96 (diff)
speed up showing ipv6 routes
same as ipv4. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/server/server.go b/server/server.go
index cd4134da..7935d0fc 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1122,9 +1122,10 @@ 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()))
- if grpcReq.RouteFamily == bgp.RF_IPv4_UC {
+ switch grpcReq.RouteFamily {
+ case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC:
results = sortedDsts(server.localRibMap[GLOBAL_RIB_NAME].rib.Tables[grpcReq.RouteFamily])
- } else {
+ default:
i := 0
for _, dst := range t.GetDestinations() {
result := &GrpcResponse{}
@@ -1180,9 +1181,10 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
remoteAddr := grpcReq.Name
if t, ok := server.localRibMap[remoteAddr].rib.Tables[grpcReq.RouteFamily]; ok {
results := make([]*GrpcResponse, len(t.GetDestinations()))
- if grpcReq.RouteFamily == bgp.RF_IPv4_UC {
+ switch grpcReq.RouteFamily {
+ case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC:
results = sortedDsts(server.localRibMap[remoteAddr].rib.Tables[grpcReq.RouteFamily])
- } else {
+ default:
i := 0
for _, dst := range t.GetDestinations() {
result := &GrpcResponse{}
@@ -1221,7 +1223,8 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
}
results := make([]*GrpcResponse, len(paths))
- if rf == bgp.RF_IPv4_UC {
+ switch rf {
+ case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC:
r := radix.New()
for _, p := range paths {
r.Insert(table.CidrToRadixkey(p.GetNlri().String()), toResult(p))
@@ -1233,7 +1236,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
i++
return false
})
- } else {
+ default:
for i, p := range paths {
results[i] = toResult(p)
}