diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/server/grpc_server.go | 3 | ||||
-rw-r--r-- | pkg/server/server.go | 40 |
2 files changed, 28 insertions, 15 deletions
diff --git a/pkg/server/grpc_server.go b/pkg/server/grpc_server.go index 4f1e4df6..6bc68011 100644 --- a/pkg/server/grpc_server.go +++ b/pkg/server/grpc_server.go @@ -651,9 +651,6 @@ func newNeighborFromAPIStruct(a *api.Peer) (*config.Neighbor, error) { pconf.State.SessionState = config.SessionState(strings.ToUpper(string(a.State.SessionState))) pconf.State.AdminState = config.IntToAdminStateMap[int(a.State.AdminState)] - pconf.State.AdjTable.Received = a.State.Received - pconf.State.AdjTable.Accepted = a.State.Accepted - pconf.State.AdjTable.Advertised = a.State.Advertised pconf.State.PeerAs = a.State.PeerAs pconf.State.PeerType = config.IntToPeerTypeMap[int(a.State.PeerType)] pconf.State.NeighborAddress = a.State.NeighborAddress 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) |