From f09d8ec955835636e5b7ad9742c0181b392e778b Mon Sep 17 00:00:00 2001 From: pudelkoM Date: Tue, 9 Nov 2021 13:40:22 -0800 Subject: [PATCH 1/2] Do not dereference `getPortStats` gRPC message pointer on error --- pfcpiface/bess.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pfcpiface/bess.go b/pfcpiface/bess.go index 2a98a6dcc..623b481db 100644 --- a/pfcpiface/bess.go +++ b/pfcpiface/bess.go @@ -219,8 +219,8 @@ func (b *bess) getPortStats(ifname string) *pb.GetPortStatsResponse { } res, err := b.client.GetPortStats(ctx, req) - if err != nil || res.GetError() != nil { - log.Println("Error calling GetPortStats", ifname, err, res.GetError().Errmsg) + if err != nil { + log.Println("Error calling GetPortStats", ifname, err, res) return nil } From 106c76d1fa8264763caf3bfb5e82bc5debf1e668 Mon Sep 17 00:00:00 2001 From: pudelkoM Date: Thu, 11 Nov 2021 10:39:05 -0800 Subject: [PATCH 2/2] Re-add error message from response --- pfcpiface/bess.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pfcpiface/bess.go b/pfcpiface/bess.go index 623b481db..aa2cb88eb 100644 --- a/pfcpiface/bess.go +++ b/pfcpiface/bess.go @@ -220,7 +220,11 @@ func (b *bess) getPortStats(ifname string) *pb.GetPortStatsResponse { res, err := b.client.GetPortStats(ctx, req) if err != nil { - log.Println("Error calling GetPortStats", ifname, err, res) + log.Println("Error calling GetPortStats", ifname, err) + return nil + } + if res.GetError() != nil { + log.Println("Error calling GetPortStats", ifname, err, res.GetError().Errmsg) return nil }