diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-11-24 23:05:50 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-11-26 17:49:48 +0900 |
commit | 301b48532d4a5510c9d4ffdc44eb2754fdd1a3d1 (patch) | |
tree | 28aef2b5ef206121c745b304636d8f6abfedce8b /pkg/server/server.go | |
parent | a5763c20d4ab411a3d6375cad32c8c8255c43a64 (diff) |
support received, accepted, and advertised counters per family
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'pkg/server/server.go')
-rw-r--r-- | pkg/server/server.go | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go index 833bc6e9..09ff114e 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -708,17 +708,6 @@ func (s *BgpServer) toConfig(peer *peer, getAdvertised bool) *config.Neighbor { peer.fsm.lock.RUnlock() if state == bgp.BGP_FSM_ESTABLISHED { - rfList := peer.configuredRFlist() - if getAdvertised { - pathList, filtered := s.getBestFromLocal(peer, rfList) - conf.State.AdjTable.Advertised = uint32(len(pathList)) - conf.State.AdjTable.Filtered = uint32(len(filtered)) - } else { - conf.State.AdjTable.Advertised = 0 - } - conf.State.AdjTable.Received = uint32(peer.adjRibIn.Count(rfList)) - conf.State.AdjTable.Accepted = uint32(peer.adjRibIn.Accepted(rfList)) - peer.fsm.lock.RLock() conf.Transport.State.LocalAddress, conf.Transport.State.LocalPort = peer.fsm.LocalHostPort() _, conf.Transport.State.RemotePort = peer.fsm.RemoteHostPort() @@ -2528,7 +2517,34 @@ func (s *BgpServer) ListPeer(ctx context.Context, r *api.ListPeerRequest, fn fun continue } // FIXME: should remove toConfig() conversion - l = append(l, config.NewPeerFromConfigStruct(s.toConfig(peer, getAdvertised))) + p := config.NewPeerFromConfigStruct(s.toConfig(peer, getAdvertised)) + for _, family := range peer.configuredRFlist() { + for i, afisafi := range p.AfiSafis { + if afisafi.Config.Enabled != true { + continue + } + afi, safi := bgp.RouteFamilyToAfiSafi(family) + c := afisafi.Config + if c.Family != nil && c.Family.Afi == api.Family_Afi(afi) && c.Family.Safi == api.Family_Safi(safi) { + flist := []bgp.RouteFamily{family} + received := uint32(peer.adjRibIn.Count(flist)) + accepted := uint32(peer.adjRibIn.Accepted(flist)) + advertised := uint32(0) + if getAdvertised == true { + pathList, _ := s.getBestFromLocal(peer, flist) + advertised = uint32(len(pathList)) + } + p.AfiSafis[i].State = &api.AfiSafiState{ + Family: c.Family, + Enabled: true, + Received: received, + Accepted: accepted, + Advertised: advertised, + } + } + } + } + l = append(l, p) } return nil }, false) |