From a17ee18e5b1fe90a7c80d6cb1f0778b97f00235a Mon Sep 17 00:00:00 2001 From: Wataru Ishida Date: Sat, 20 Aug 2016 10:21:23 +0000 Subject: server: fix RIB lookup with longer-prefixes option the feature was somehow broken. Signed-off-by: Wataru Ishida --- server/server.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'server') diff --git a/server/server.go b/server/server.go index d3f05853..049f3e46 100644 --- a/server/server.go +++ b/server/server.go @@ -1483,20 +1483,22 @@ func (s *BgpServer) GetRib(addr string, family bgp.RouteFamily, prefixes []*Look key := p.Prefix switch p.LookupOption { case LOOKUP_LONGER: - _, prefix, err := net.ParseCIDR(key) + ds, e := rib.Tables[af].GetLongerPrefixDestinations(key) if err != nil { - return id, nil, err + err = e + return } - for _, dst := range rib.Tables[af].GetLongerPrefixDestinations(prefix.String()) { + for _, dst := range ds { if paths := dst.GetKnownPathList(id); len(paths) > 0 { dsts[dst.GetNlri().String()] = clonePathList(paths) } } case LOOKUP_SHORTER: - _, prefix, err := net.ParseCIDR(key) - if err != nil { - return id, nil, err + _, prefix, e := net.ParseCIDR(key) + if e != nil { + err = e + return } ones, bits := prefix.Mask.Size() for i := ones; i > 0; i-- { -- cgit v1.2.3