@@ -57,6 +57,21 @@ func wrapGetRIBErr(err error, rtr string, vrfID uint64, version api.IP_Version)
5757 return fmt .Errorf ("unable to get RIB (%s/%s/v%d): %w" , rtr , vrf .RouteDistinguisherHumanReadable (vrfID ), version , err )
5858}
5959
60+ func wrapRIBNotReadyErr (err error , rtr string , vrfID uint64 , version api.IP_Version ) error {
61+ return fmt .Errorf ("RIB not ready yet (%s/%s/v%d): %w" , rtr , vrf .RouteDistinguisherHumanReadable (vrfID ), version , err )
62+ }
63+
64+ func ipVersionFromProto (v netapi.IP_Version ) uint16 {
65+ switch v {
66+ case netapi .IP_IPv4 :
67+ return 4
68+ case netapi .IP_IPv6 :
69+ return 6
70+ }
71+
72+ return 0
73+ }
74+
6075func (s Server ) getRIB (rtr string , vrfID uint64 , ipVersion netapi.IP_Version ) (* locRIB.LocRIB , error ) {
6176 r := s .bmp .GetRouter (rtr )
6277 if r == nil {
@@ -179,6 +194,10 @@ func (s *Server) ObserveRIB(req *pb.ObserveRIBRequest, stream pb.RoutingInformat
179194 return status .New (codes .Unavailable , wrapGetRIBErr (err , req .Router , vrfID , ipVersion ).Error ()).Err ()
180195 }
181196
197+ if ! s .bmp .GetRouter (req .Router ).Ready (vrfID , ipVersionFromProto (ipVersion )) {
198+ return status .New (codes .Unavailable , wrapRIBNotReadyErr (err , req .Router , vrfID , ipVersion ).Error ()).Err ()
199+ }
200+
182201 risObserveFIBClients .WithLabelValues (req .Router , fmt .Sprintf ("%d" , req .VrfId ), fmt .Sprintf ("%d" , req .Afisafi )).Inc ()
183202 defer risObserveFIBClients .WithLabelValues (req .Router , fmt .Sprintf ("%d" , req .VrfId ), fmt .Sprintf ("%d" , req .Afisafi )).Dec ()
184203
0 commit comments