From f99c0674039227bf47a7d02c9fe038ee57229da3 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 8 Aug 2021 20:25:39 +0900 Subject: server: fix ListVrf api to handle Name member Currently, just ignored. Signed-off-by: FUJITA Tomonori --- pkg/server/server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 3cdcd6e4..37985e5e 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -2163,7 +2163,7 @@ func (s *BgpServer) listVrf() (l []*table.Vrf) { return l } -func (s *BgpServer) ListVrf(ctx context.Context, _ *api.ListVrfRequest, fn func(*api.Vrf)) error { +func (s *BgpServer) ListVrf(ctx context.Context, rq *api.ListVrfRequest, fn func(*api.Vrf)) error { toApi := func(v *table.Vrf) *api.Vrf { return &api.Vrf{ Name: v.Name, @@ -2176,7 +2176,10 @@ func (s *BgpServer) ListVrf(ctx context.Context, _ *api.ListVrfRequest, fn func( var l []*api.Vrf s.mgmtOperation(func() error { l = make([]*api.Vrf, 0, len(s.globalRib.Vrfs)) - for _, vrf := range s.globalRib.Vrfs { + for name, vrf := range s.globalRib.Vrfs { + if rq.Name != "" && rq.Name != name { + continue + } l = append(l, toApi(vrf.Clone())) } return nil -- cgit v1.2.3