LCOV - code coverage report
Current view: top level - bgp - bgp_show_multicast_manager.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 67 0.0 %
Date: 2026-11-16 02:06:09 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include "bgp/bgp_show_handler.h"
       7             : 
       8             : #include "base/regex.h"
       9             : #include "bgp/bgp_peer_internal_types.h"
      10             : #include "bgp/bgp_multicast.h"
      11             : #include "bgp/bgp_server.h"
      12             : #include "bgp/ermvpn/ermvpn_table.h"
      13             : #include "bgp/routing-instance/routing_instance.h"
      14             : 
      15             : using contrail::regex;
      16             : using contrail::regex_match;
      17             : using contrail::regex_search;
      18             : using std::string;
      19             : using std::vector;
      20             : 
      21             : //
      22             : // Fill in information for an ermvpn table.
      23             : //
      24           0 : static void FillMulticastManagerInfo(ShowMulticastManager *smm,
      25             :     const BgpSandeshContext *bsc, const ErmVpnTable *table) {
      26           0 :     smm->set_name(table->name());
      27           0 :     const McastTreeManager *manager = table->GetTreeManager();
      28           0 :     if (!manager)
      29           0 :         return;
      30             : 
      31           0 :     smm->set_deleted(manager->deleted());
      32           0 :     smm->set_deleted_at(
      33           0 :         UTCUsecToString(manager->deleter()->delete_time_stamp_usecs()));
      34             : 
      35           0 :     uint32_t total_trees = 0;
      36           0 :     for (McastTreeManager::const_iterator it = manager->begin();
      37           0 :          it != manager->end(); ++it) {
      38           0 :         const McastManagerPartition *partition = *it;
      39           0 :         total_trees += partition->size();
      40             :     }
      41           0 :     smm->set_total_trees(total_trees);
      42             : }
      43             : 
      44             : //
      45             : // Specialization of BgpShowHandler<>::CallbackCommon.
      46             : //
      47             : template <>
      48           0 : bool BgpShowHandler<ShowMulticastManagerReq, ShowMulticastManagerReqIterate,
      49             :     ShowMulticastManagerResp, ShowMulticastManager>::CallbackCommon(
      50             :     const BgpSandeshContext *bsc, Data *data) {
      51           0 :     uint32_t page_limit = bsc->page_limit() ? bsc->page_limit() : kPageLimit;
      52           0 :     uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit;
      53           0 :     RoutingInstanceMgr *rim = bsc->bgp_server->routing_instance_mgr();
      54             : 
      55           0 :     regex search_expr(data->search_string);
      56             :     RoutingInstanceMgr::const_name_iterator it =
      57           0 :         rim->name_clower_bound(data->next_entry);
      58           0 :     for (uint32_t iter_count = 0; it != rim->name_cend(); ++it, ++iter_count) {
      59           0 :         const RoutingInstance *rtinstance = it->second;
      60             :         const ErmVpnTable *table = static_cast<const ErmVpnTable *>(
      61           0 :             rtinstance->GetTable(Address::ERMVPN));
      62           0 :         if (!table)
      63           0 :             continue;
      64           0 :         if ((!regex_search(table->name(), search_expr)) &&
      65           0 :             (data->search_string != "deleted" || !table->IsDeleted())) {
      66           0 :             continue;
      67             :         }
      68           0 :         ShowMulticastManager smm;
      69           0 :         FillMulticastManagerInfo(&smm, bsc, table);
      70           0 :         data->show_list.push_back(smm);
      71           0 :         if (data->show_list.size() >= page_limit)
      72           0 :             break;
      73           0 :         if (iter_count >= iter_limit)
      74           0 :             break;
      75           0 :     }
      76             : 
      77             :     // All done if we've looked at all instances.
      78           0 :     if (it == rim->name_cend() || ++it == rim->name_cend())
      79           0 :         return true;
      80             : 
      81             :     // Return true if we've reached the page limit, false if we've reached the
      82             :     // iteration limit.
      83           0 :     bool done = data->show_list.size() >= page_limit;
      84           0 :     SaveContextToData(it->second->name(), done, data);
      85           0 :     return done;
      86           0 : }
      87             : 
      88             : //
      89             : // Specialization of BgpShowHandler<>::FillShowList.
      90             : //
      91             : template <>
      92           0 : void BgpShowHandler<ShowMulticastManagerReq, ShowMulticastManagerReqIterate,
      93             :     ShowMulticastManagerResp, ShowMulticastManager>::FillShowList(
      94             :     ShowMulticastManagerResp *resp,
      95             :     const vector<ShowMulticastManager> &show_list) {
      96           0 :     resp->set_managers(show_list);
      97           0 : }
      98             : 
      99             : //
     100             : // Handler for ShowMulticastManagerReq.
     101             : //
     102           0 : void ShowMulticastManagerReq::HandleRequest() const {
     103           0 :     RequestPipeline::PipeSpec ps(this);
     104           0 :     RequestPipeline::StageSpec s1;
     105           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     106             : 
     107           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     108             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     109             :         ShowMulticastManagerReq,
     110             :         ShowMulticastManagerReqIterate,
     111             :         ShowMulticastManagerResp,
     112           0 :         ShowMulticastManager>::Callback, _1, _2, _3, _4, _5);
     113             :     s1.allocFn_ = BgpShowHandler<
     114             :         ShowMulticastManagerReq,
     115             :         ShowMulticastManagerReqIterate,
     116             :         ShowMulticastManagerResp,
     117           0 :         ShowMulticastManager>::CreateData;
     118           0 :     s1.instances_.push_back(0);
     119           0 :     ps.stages_.push_back(s1);
     120           0 :     RequestPipeline rp(ps);
     121           0 : }
     122             : 
     123             : //
     124             : // Handler for ShowMulticastManagerReqIterate.
     125             : //
     126           0 : void ShowMulticastManagerReqIterate::HandleRequest() const {
     127           0 :     RequestPipeline::PipeSpec ps(this);
     128           0 :     RequestPipeline::StageSpec s1;
     129           0 :     TaskScheduler *scheduler = TaskScheduler::GetInstance();
     130             : 
     131           0 :     s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
     132             :     s1.cbFn_ = boost::bind(&BgpShowHandler<
     133             :         ShowMulticastManagerReq,
     134             :         ShowMulticastManagerReqIterate,
     135             :         ShowMulticastManagerResp,
     136           0 :         ShowMulticastManager>::CallbackIterate, _1, _2, _3, _4, _5);
     137             :     s1.allocFn_ = BgpShowHandler<
     138             :         ShowMulticastManagerReq,
     139             :         ShowMulticastManagerReqIterate,
     140             :         ShowMulticastManagerResp,
     141           0 :         ShowMulticastManager>::CreateData;
     142           0 :     s1.instances_.push_back(0);
     143           0 :     ps.stages_.push_back(s1);
     144           0 :     RequestPipeline rp(ps);
     145           0 : }

Generated by: LCOV version 1.14