LCOV - code coverage report
Current view: top level - bgp - peer_stats.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 68 68 100.0 %
Date: 2026-09-07 02:14:47 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include "bgp/peer_stats.h"
       6             : 
       7         602 : void PeerStats::FillProtoStats(const IPeerDebugStats::ProtoStats &stats,
       8             :                                PeerProtoStats *proto_stats) {
       9         602 :     proto_stats->set_open(stats.open);
      10         602 :     proto_stats->set_keepalive(stats.keepalive);
      11         602 :     proto_stats->set_close(stats.close);
      12         602 :     proto_stats->set_update(stats.update);
      13         602 :     proto_stats->set_notification(stats.notification);
      14         602 :     proto_stats->set_total(stats.open + stats.keepalive + stats.close +
      15         602 :         stats.update + stats.notification);
      16         602 : }
      17             : 
      18        1204 : void PeerStats::FillRouteUpdateStats(const IPeerDebugStats::UpdateStats &stats,
      19             :                                      PeerUpdateStats *rt_stats) {
      20        1204 :     rt_stats->set_total(stats.total);
      21        1204 :     rt_stats->set_reach(stats.reach);
      22        1204 :     rt_stats->set_unreach(stats.unreach);
      23        1204 : }
      24             : 
      25         301 : void PeerStats::FillRxErrorStats(const IPeerDebugStats::RxErrorStats &src,
      26             :                                  PeerRxErrorStats *dest) {
      27         301 :     PeerRxInet6ErrorStats error_stats;
      28         301 :     error_stats.set_bad_inet6_xml_token_count(src.inet6_bad_xml_token_count);
      29         301 :     error_stats.set_bad_inet6_prefix_count(src.inet6_bad_prefix_count);
      30         301 :     error_stats.set_bad_inet6_nexthop_count(src.inet6_bad_nexthop_count);
      31         301 :     error_stats.set_bad_inet6_afi_safi_count(src.inet6_bad_afi_safi_count);
      32         301 :     dest->set_inet6_error_stats(error_stats);
      33         301 : }
      34             : 
      35         301 : void PeerStats::FillRxRouteStats(const IPeerDebugStats::RxRouteStats &src,
      36             :                                  PeerRxRouteStats *dest) {
      37         301 :     dest->set_total_path_count(src.total_path_count);
      38         301 :     dest->set_primary_path_count(src.primary_path_count);
      39         301 : }
      40             : 
      41         602 : void PeerStats::FillPeerUpdateStats(const IPeerDebugStats *peer_stats,
      42             :                                     PeerUpdateStats *rt_stats_rx,
      43             :                                     PeerUpdateStats *rt_stats_tx) {
      44             : 
      45         602 :     IPeerDebugStats::UpdateStats update_stats_rx;
      46         602 :     peer_stats->GetRxRouteUpdateStats(&update_stats_rx);
      47         602 :     FillRouteUpdateStats(update_stats_rx, rt_stats_rx);
      48             : 
      49         602 :     IPeerDebugStats::UpdateStats update_stats_tx;
      50         602 :     peer_stats->GetTxRouteUpdateStats(&update_stats_tx);
      51         602 :     FillRouteUpdateStats(update_stats_tx, rt_stats_tx);
      52         602 : }
      53             : 
      54         301 : void PeerStats::FillPeerUpdateStats(const IPeerDebugStats *peer_stats,
      55             :                                     PeerStatsData *peer_stats_data) {
      56         301 :     PeerUpdateStats stats_rx;
      57         301 :     PeerUpdateStats stats_tx;
      58             : 
      59         301 :     FillPeerUpdateStats(peer_stats, &stats_rx, &stats_tx);
      60         301 :     peer_stats_data->set_raw_rx_update_stats(stats_rx);
      61         301 :     peer_stats_data->set_raw_tx_update_stats(stats_tx);
      62         301 : }
      63             : 
      64         301 : void PeerStats::FillPeerDebugStats(const IPeerDebugStats *peer_stats,
      65             :                                    PeerStatsInfo *stats) {
      66         301 :     PeerProtoStats proto_stats_tx;
      67         301 :     PeerProtoStats proto_stats_rx;
      68         301 :     PeerUpdateStats rt_stats_rx;
      69         301 :     PeerUpdateStats rt_stats_tx;
      70         301 :     PeerRxErrorStats dest_error_stats_rx;
      71         301 :     PeerRxRouteStats dest_route_stats_rx;
      72             : 
      73         301 :     IPeerDebugStats::ProtoStats stats_rx;
      74         301 :     peer_stats->GetRxProtoStats(&stats_rx);
      75         301 :     FillProtoStats(stats_rx, &proto_stats_rx);
      76             : 
      77         301 :     IPeerDebugStats::ProtoStats stats_tx;
      78         301 :     peer_stats->GetTxProtoStats(&stats_tx);
      79         301 :     FillProtoStats(stats_tx, &proto_stats_tx);
      80             : 
      81         301 :     FillPeerUpdateStats(peer_stats, &rt_stats_rx, &rt_stats_tx);
      82             : 
      83         301 :     IPeerDebugStats::RxErrorStats src_error_stats_rx;
      84         301 :     peer_stats->GetRxErrorStats(&src_error_stats_rx);
      85         301 :     FillRxErrorStats(src_error_stats_rx, &dest_error_stats_rx);
      86             : 
      87         301 :     IPeerDebugStats::RxRouteStats src_route_stats_rx;
      88         301 :     peer_stats->GetRxRouteStats(&src_route_stats_rx);
      89         301 :     FillRxRouteStats(src_route_stats_rx, &dest_route_stats_rx);
      90             : 
      91         301 :     stats->set_rx_proto_stats(proto_stats_rx);
      92         301 :     stats->set_tx_proto_stats(proto_stats_tx);
      93         301 :     stats->set_rx_update_stats(rt_stats_rx);
      94         301 :     stats->set_tx_update_stats(rt_stats_tx);
      95         301 :     stats->set_rx_error_stats(dest_error_stats_rx);
      96         301 :     stats->set_rx_route_stats(dest_route_stats_rx);
      97         301 : }

Generated by: LCOV version 1.14