summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gobgp/neighbor.go12
-rw-r--r--server/server.go15
-rw-r--r--table/destination.go3
3 files changed, 21 insertions, 9 deletions
diff --git a/gobgp/neighbor.go b/gobgp/neighbor.go
index b8c60273..36eea805 100644
--- a/gobgp/neighbor.go
+++ b/gobgp/neighbor.go
@@ -416,6 +416,14 @@ func showNeighborRib(r string, name string, args []string) error {
return err
}
+ isResultSorted := func(rf bgp.RouteFamily) bool {
+ switch rf {
+ case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC:
+ return true
+ }
+ return false
+ }
+
dsts := []*Destination{}
maxOnes := 0
counter := 0
@@ -448,7 +456,7 @@ func showNeighborRib(r string, name string, args []string) error {
if err != nil {
return err
}
- if rf == bgp.RF_IPv4_UC && !globalOpts.Json && len(dst.Paths) > 0 {
+ if isResultSorted(rf) && !globalOpts.Json && len(dst.Paths) > 0 {
ps := paths{}
ps = append(ps, dst.Paths...)
sort.Sort(ps)
@@ -468,7 +476,7 @@ func showNeighborRib(r string, name string, args []string) error {
return nil
}
- if rf == bgp.RF_IPv4_UC && counter != 0 {
+ if isResultSorted(rf) && counter != 0 {
// we already showed
return nil
}
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)
}
diff --git a/table/destination.go b/table/destination.go
index 55c90b53..96979a78 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -93,7 +93,8 @@ func NewDestination(nlri bgp.AddrPrefixInterface) *Destination {
withdrawList: make([]*Path, 0),
newPathList: make([]*Path, 0),
}
- if d.routeFamily == bgp.RF_IPv4_UC {
+ switch d.routeFamily {
+ case bgp.RF_IPv4_UC, bgp.RF_IPv6_UC:
d.RadixKey = CidrToRadixkey(nlri.String())
}
return d