diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/server.go | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/server/server.go b/server/server.go index 6a766261..286ff85b 100644 --- a/server/server.go +++ b/server/server.go @@ -1605,7 +1605,21 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { } for _, dst := range arg.Table.Destinations { key := dst.Prefix - if _, err := f(id, key); err != nil { + if dst.LongerPrefixes { + _, prefix, _ := net.ParseCIDR(key) + for _, dst := range rib.Tables[af].GetLongerPrefixDestinations(prefix.String()) { + if d := dst.ToApiStruct(id); d != nil { + dsts = append(dsts, d) + } + } + } else if dst.ShorterPrefixes { + _, prefix, _ := net.ParseCIDR(key) + ones, bits := prefix.Mask.Size() + for i := ones; i > 0; i-- { + prefix.Mask = net.CIDRMask(i, bits) + f(id, prefix.String()) + } + } else if _, err := f(id, key); err != nil { if host := net.ParseIP(key); host != nil { masklen := 32 if af == bgp.RF_IPv6_UC { @@ -1617,14 +1631,6 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) { } } } - } else if dst.LongerPrefixes { - _, prefix, _ := net.ParseCIDR(key) - - for _, dst := range rib.Tables[af].GetLongerPrefixDestinations(prefix.String()) { - if d := dst.ToApiStruct(id); d != nil { - dsts = append(dsts, d) - } - } } } } else { |