diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-04-10 15:38:46 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-04-15 05:31:40 +0000 |
commit | d405c203ad8070298f256856605edb6d5480ba04 (patch) | |
tree | dccd1bf4ba74abf95d9606dcafb8f3422979e708 /server | |
parent | a6efaf6ed6baf26050090b400310196464bab06f (diff) |
table: sort peers/routes at client side instead of bgpd side
peer/route sorting is for pretty priting. do it at the client side.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/server/server.go b/server/server.go index c83c48df..5492cb1c 100644 --- a/server/server.go +++ b/server/server.go @@ -22,7 +22,6 @@ import ( "github.com/osrg/gobgp/policy" "net" "os" - "sort" "strconv" ) @@ -267,42 +266,12 @@ func (server *BgpServer) SetPolicy(pl config.RoutingPolicy) { server.policyMap = pMap } -type peers []*Peer - -func (p peers) Len() int { - return len(p) -} - -func (p peers) Swap(i, j int) { - p[i], p[j] = p[j], p[i] -} - -func (p peers) Less(i, j int) bool { - p1 := p[i].peerConfig.NeighborAddress - p2 := p[j].peerConfig.NeighborAddress - p1Isv4 := p1.To4() != nil - p2Isv4 := p2.To4() != nil - if p1Isv4 != p2Isv4 { - if p1Isv4 == true { - return true - } - return false - } - strings := sort.StringSlice{p1.String(), p2.String()} - return strings.Less(0, 1) -} - func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { switch grpcReq.RequestType { case REQ_NEIGHBORS: - peerList := peers{} for _, info := range server.peerMap { - peerList = append(peerList, info.peer) - } - sort.Sort(peerList) - for _, peer := range peerList { result := &GrpcResponse{ - Data: peer.ToApiStruct(), + Data: info.peer.ToApiStruct(), } grpcReq.ResponseCh <- result } |