diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-12-06 10:38:16 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-12-06 10:38:16 +0900 |
commit | ec6bcf13f15f9b717c87e4d22232a38572e1d6f2 (patch) | |
tree | 9eb1a5199324775f61bed64a70b29093bd8cfe38 /server | |
parent | 7ff862f3eefceb3a58ca8be09ead21336d5cb504 (diff) |
api/cli: show all longer prefixes with longer-prefixes option
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/server/server.go b/server/server.go index 089d8e0a..2bb89d8e 100644 --- a/server/server.go +++ b/server/server.go @@ -1441,27 +1441,24 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { } for _, dst := range arg.Destinations { key := dst.Prefix - y, err := f(key) - if err != nil { + if _, err := f(key); err != nil { if host := net.ParseIP(key); host != nil { masklen := 32 if af == bgp.RF_IPv6_UC { masklen = 128 } for i := masklen; i > 0; i-- { - if y, _ = f(fmt.Sprintf("%s/%d", key, i)); y { + if y, _ := f(fmt.Sprintf("%s/%d", key, i)); y { break } } } - } else if !y && dst.LongerPrefix { + } else if dst.LongerPrefixes { _, prefix, _ := net.ParseCIDR(key) ones, bits := prefix.Mask.Size() for i := ones + 1; i <= bits; i++ { prefix.Mask = net.CIDRMask(i, bits) - if y, _ = f(prefix.String()); y { - break - } + f(prefix.String()) } } } |