From 46401a2099d82b03cacf0521174b61406c49c439 Mon Sep 17 00:00:00 2001 From: Serguei Bezverkhi Date: Fri, 7 Feb 2020 19:09:35 -0500 Subject: fix panic in Family == nil Signed-off-by: Serguei Bezverkhi --- internal/pkg/apiutil/util.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'internal') diff --git a/internal/pkg/apiutil/util.go b/internal/pkg/apiutil/util.go index 1dd25c79..7eb3ee86 100644 --- a/internal/pkg/apiutil/util.go +++ b/internal/pkg/apiutil/util.go @@ -17,6 +17,7 @@ package apiutil import ( "encoding/json" + "fmt" "net" "time" @@ -90,6 +91,9 @@ func getNLRI(family bgp.RouteFamily, buf []byte) (bgp.AddrPrefixInterface, error } func GetNativeNlri(p *api.Path) (bgp.AddrPrefixInterface, error) { + if p.Family == nil { + return nil, fmt.Errorf("family cannot be nil") + } if len(p.NlriBinary) > 0 { return getNLRI(ToRouteFamily(p.Family), p.NlriBinary) } -- cgit v1.2.3