From 17d0b3cce52bf7009f65e19e7107e152d28fabf5 Mon Sep 17 00:00:00 2001 From: shao Date: Wed, 11 Nov 2020 10:58:37 +0800 Subject: fix wrong vrf neighbors display --- cmd/gobgp/neighbor.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/gobgp/neighbor.go b/cmd/gobgp/neighbor.go index 5b0d5012..8c80338b 100644 --- a/cmd/gobgp/neighbor.go +++ b/cmd/gobgp/neighbor.go @@ -113,10 +113,21 @@ func counter(p *api.Peer) (uint64, uint64, uint64, error) { } func showNeighbors(vrf string) error { - m, err := getNeighbors("", false) + l, err := getNeighbors("", false) if err != nil { return err } + m := make([]*api.Peer, 0) + if vrf == "" { + m = l + } else { + for _, n := range l { + if n.Conf.Vrf == vrf { + m = append(m, n) + } + } + } + if globalOpts.Json { j, _ := json.Marshal(m) fmt.Println(string(j)) -- cgit v1.2.3