OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bgp_sandesh.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "bgp/bgp_sandesh.h"
6 
7 #include <boost/assign/list_of.hpp>
8 #include <boost/foreach.hpp>
9 #include <sandesh/request_pipeline.h>
10 
11 #include "bgp/bgp_multicast.h"
12 #include "bgp/bgp_mvpn.h"
13 #include "bgp/bgp_peer.h"
14 #include "bgp/bgp_peer_internal_types.h"
15 #include "bgp/bgp_server.h"
18 #include "bgp/inet/inet_table.h"
19 #include "bgp/mvpn/mvpn_table.h"
22 
23 using boost::assign::list_of;
24 using std::string;
25 using std::vector;
26 
28 public:
29  static bool CallbackS1(const Sandesh *sr,
30  const RequestPipeline::PipeSpec ps, int stage, int instNum,
32  static size_t FillBgpNeighborStatistics(
33  const ShowNeighborStatisticsReq *req, BgpServer *bgp_server);
34 };
35 
37  const ShowNeighborStatisticsReq *req, BgpServer *bgp_server) {
38  size_t count = 0;
39 
40  if (req->get_bgp_or_xmpp().empty() ||
41  boost::iequals(req->get_bgp_or_xmpp(), "bgp")) {
42  RoutingInstanceMgr *rim = bgp_server->routing_instance_mgr();
43  if (!req->get_domain().empty()) {
44  RoutingInstance *ri = rim->GetRoutingInstance(req->get_domain());
45  PeerManager *pmgr = ri ? ri->peer_manager() : NULL;
46  if (pmgr) {
47  count += pmgr->GetNeighborCount(req->get_up_or_down());
48  }
49  } else {
51  for (; it != rim->end(); it++) {
52  PeerManager *pmgr = it->second->peer_manager();
53  if (pmgr) {
54  count += pmgr->GetNeighborCount(req->get_up_or_down());
55  }
56  }
57  }
58  }
59 
60  return count;
61 }
62 
64  const Sandesh *sr, const RequestPipeline::PipeSpec ps,
65  int stage, int instNum, RequestPipeline::InstData *data) {
66  const ShowNeighborStatisticsReq *req;
67  BgpSandeshContext *bsc;
68 
69  req = static_cast<const ShowNeighborStatisticsReq *>(ps.snhRequest_.get());
70  bsc = static_cast<BgpSandeshContext *>(req->client_context());
71 
72  // Retrieve number of BGP peers.
73  size_t count = FillBgpNeighborStatistics(req, bsc->bgp_server);
74 
75  // Retrieve numner of XMPP agents.
76  if (req->get_bgp_or_xmpp().empty() ||
77  boost::iequals(req->get_bgp_or_xmpp(), "xmpp")) {
78  bsc->ShowNeighborStatisticsExtension(&count, req);
79  }
80 
81  ShowNeighborStatisticsResp *resp = new ShowNeighborStatisticsResp;
82  resp->set_bgp_or_xmpp(req->get_bgp_or_xmpp());
83  resp->set_up_or_down(req->get_up_or_down());
84  resp->set_domain(req->get_domain());
85  resp->set_count(count);
86  resp->set_context(req->context());
87  resp->Response();
88 
89  return true;
90 }
91 
92 void ShowNeighborStatisticsReq::HandleRequest() const {
93  // Use config task as we need to examine both bgp and xmpp data bases
94  // to compute the number of neighbors. Both BGP and XMPP peers are
95  // inserted/deleted under config task.
97  s1.taskId_ = TaskScheduler::GetInstance()->GetTaskId("bgp::Config");
98  s1.instances_.push_back(0);
100 
101  RequestPipeline::PipeSpec ps(this);
102  ps.stages_= list_of(s1)
103  .convert_to_container<vector<RequestPipeline::StageSpec> >();
104  RequestPipeline rp(ps);
105 }
106 
108 public:
109  static bool CallbackS1(const Sandesh *sr,
110  const RequestPipeline::PipeSpec ps, int stage,
111  int instNum, RequestPipeline::InstData * data);
112 };
113 
115  const Sandesh *sr, const RequestPipeline::PipeSpec ps,
116  int stage, int instNum, RequestPipeline::InstData *data) {
117  const ClearBgpNeighborReq *req;
118  BgpSandeshContext *bsc;
119 
120  req = static_cast<const ClearBgpNeighborReq *>(ps.snhRequest_.get());
121  bsc = static_cast<BgpSandeshContext *>(req->client_context());
122  BgpPeer *peer = bsc->bgp_server->FindPeer(req->get_name());
123 
124  ClearBgpNeighborResp *resp = new ClearBgpNeighborResp;
125  if (!bsc->test_mode()) {
126  resp->set_success(false);
127  } else if (peer) {
129  resp->set_success(true);
130  } else {
131  resp->set_success(false);
132  }
133  resp->set_context(req->context());
134  resp->Response();
135 
136  return true;
137 }
138 
139 // handler for 'clear bgp neighbor'
140 void ClearBgpNeighborReq::HandleRequest() const {
141  // Use config task since neighbors are added/deleted under that task.
142  // to compute the number of neighbors.
144  s1.taskId_ = TaskScheduler::GetInstance()->GetTaskId("bgp::Config");
145  s1.instances_.push_back(0);
147 
148  RequestPipeline::PipeSpec ps(this);
149  ps.stages_= list_of(s1)
150  .convert_to_container<vector<RequestPipeline::StageSpec> >();
151  RequestPipeline rp(ps);
152 }
153 
155 public:
157  vector<ShowMulticastTree> tree_list;
158  };
159 
161  return (new MulticastManagerDetailData);
162  }
163 
164  static void FillMulticastLinkInfo(const McastForwarder *forwarder,
165  ShowMulticastTreeLink *smtl) {
166  smtl->set_address(forwarder->address().to_string());
167  smtl->set_label(forwarder->label());
168  }
169 
170  static void FillMulticastForwarderInfo(const McastForwarder *forwarder,
171  ShowMulticastForwarder *smf) {
172  smf->set_address(forwarder->address().to_string());
173  smf->set_label(forwarder->label());
174  smf->set_label_block(forwarder->label_block()->ToString());
175  smf->set_router_id(forwarder->router_id().to_string());
176  for (McastForwarderList::const_iterator it =
177  forwarder->tree_links_.begin();
178  it != forwarder->tree_links_.end(); ++it) {
179  ShowMulticastTreeLink smtl;
180  FillMulticastLinkInfo(*it, &smtl);
181  smf->links.push_back(smtl);
182  }
183  }
184 
185  static void FillMulticastTreeInfo(const McastSGEntry *sg,
186  ShowMulticastTree *smt) {
187  smt->set_group(sg->group().to_string());
188  smt->set_source(sg->source().to_string());
189  for (uint8_t level = McastTreeManager::LevelFirst;
190  level < McastTreeManager::LevelCount; ++level) {
191  if (!sg->IsTreeBuilder(level))
192  continue;
193  for (McastSGEntry::ForwarderSet::const_iterator it =
194  sg->forwarder_sets_[level]->begin();
195  it != sg->forwarder_sets_[level]->end(); ++it) {
196  ShowMulticastForwarder smf;
197  FillMulticastForwarderInfo(*it, &smf);
198  if (level == McastTreeManager::LevelNative) {
199  smt->level0_forwarders.push_back(smf);
200  } else {
201  smt->level1_forwarders.push_back(smf);
202  }
203  }
204  }
205  }
206 
208  ErmVpnTable *table, int inst_id) {
209  McastTreeManager *tm = table->GetTreeManager();
210  McastManagerPartition *partition = tm->GetPartition(inst_id);
211  for (McastManagerPartition::SGList::const_iterator it =
212  partition->sg_list_.begin();
213  it != partition->sg_list_.end(); it++) {
214  ShowMulticastTree smt;
215  FillMulticastTreeInfo(*it, &smt);
216  data->tree_list.push_back(smt);
217  }
218  }
219 
220  static bool CallbackS1(const Sandesh *sr,
221  const RequestPipeline::PipeSpec ps,
222  int stage, int instNum,
224  int inst_id = ps.stages_[stage].instances_[instNum];
225 
227  static_cast<MulticastManagerDetailData *>(data);
228  const ShowMulticastManagerDetailReq *req =
229  static_cast<const ShowMulticastManagerDetailReq *>(
230  ps.snhRequest_.get());
231  BgpSandeshContext *bsc =
232  static_cast<BgpSandeshContext *>(req->client_context());
233  DBTableBase *table =
234  bsc->bgp_server->database()->FindTable(req->get_name());
235  ErmVpnTable *mcast_table = dynamic_cast<ErmVpnTable *>(table);
236  if (mcast_table && !mcast_table->IsVpnTable())
237  FillMulticastPartitionInfo(mydata, mcast_table, inst_id);
238 
239  return true;
240  }
241 
243  const RequestPipeline::StageData *sd,
244  vector<ShowMulticastTree> *tree_list) {
245  for (size_t idx = 0; idx < sd->size(); idx++) {
246  const MulticastManagerDetailData &data =
247  static_cast<const MulticastManagerDetailData &>(sd->at(idx));
248  tree_list->insert(tree_list->end(),
249  data.tree_list.begin(), data.tree_list.end());
250  }
251  }
252 
253  static bool CallbackS2(const Sandesh *sr,
254  const RequestPipeline::PipeSpec ps,
255  int stage, int instNum,
257  const ShowMulticastManagerReq *req =
258  static_cast<const ShowMulticastManagerReq *>(ps.snhRequest_.get());
259  const RequestPipeline::StageData *sd = ps.GetStageData(0);
260  vector<ShowMulticastTree> tree_list;
261  CombineMulticastPartitionInfo(sd, &tree_list);
262 
263  ShowMulticastManagerDetailResp *resp =
264  new ShowMulticastManagerDetailResp;
265  resp->set_trees(tree_list);
266  resp->set_context(req->context());
267  resp->Response();
268  return true;
269  }
270 };
271 
272 
273 void ShowMulticastManagerDetailReq::HandleRequest() const {
274  RequestPipeline::PipeSpec ps(this);
275 
276  // Request pipeline has 2 stages.
277  // First stage to collect multicast manager stats.
278  // Second stage to fill stats from stage 1 and respond to the request.
281 
282  s1.taskId_ = scheduler->GetTaskId("db::DBTable");
285  for (int i = 0; i < ErmVpnTable::kPartitionCount; i++) {
286  s1.instances_.push_back(i);
287  }
288 
289  s2.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
291  s2.instances_.push_back(0);
292 
293  ps.stages_ = list_of(s1)(s2)
294  .convert_to_container<vector<RequestPipeline::StageSpec> >();
295  RequestPipeline rp(ps);
296 }
297 
299 public:
301  vector<ShowMvpnNeighbor> neighbors;
302  };
303 
305  return (new MvpnManagerDetailData);
306  }
307 
308  static void FillMvpnNeighborInfo(const MvpnNeighbor *nbr,
309  ShowMvpnNeighbor *snbr) {
310  snbr->set_rd(nbr->rd().ToString());
311  snbr->set_originator(nbr->originator().to_string());
312  snbr->set_source_as(nbr->source_as());
313  }
314 
316  MvpnTable *table, int inst_id) {
317  MvpnManager *tm = table->manager();
318  if (!tm) return;
319  tbb::reader_writer_lock::scoped_lock_read lock(tm->neighbors_mutex());
320 
321  BOOST_FOREACH(const MvpnManager::NeighborMap::value_type &val,
322  tm->neighbors()) {
323  ShowMvpnNeighbor snbr;
324  FillMvpnNeighborInfo(&val.second, &snbr);
325  data->neighbors.push_back(snbr);
326  }
327  }
328 
329  static bool CallbackS1(const Sandesh *sr,
330  const RequestPipeline::PipeSpec ps,
331  int stage, int instNum,
333  int inst_id = ps.stages_[stage].instances_[instNum];
334 
335  MvpnManagerDetailData *mydata =
336  static_cast<MvpnManagerDetailData *>(data);
337  const ShowMvpnManagerDetailReq *req =
338  static_cast<const ShowMvpnManagerDetailReq *>(
339  ps.snhRequest_.get());
340  BgpSandeshContext *bsc =
341  static_cast<BgpSandeshContext *>(req->client_context());
342  DBTableBase *table =
343  bsc->bgp_server->database()->FindTable(req->get_name());
344  MvpnTable *mvpn_table = dynamic_cast<MvpnTable *>(table);
345  if (mvpn_table && !mvpn_table->IsVpnTable())
346  FillMvpnNeighborsInfo(mydata, mvpn_table, inst_id);
347 
348  ShowMvpnManagerDetailResp *resp = new ShowMvpnManagerDetailResp;
349  resp->set_neighbors(mydata->neighbors);
350  resp->set_context(req->context());
351  resp->Response();
352 
353  return true;
354  }
355 };
356 
357 void ShowMvpnManagerDetailReq::HandleRequest() const {
358  RequestPipeline::PipeSpec ps(this);
361 
362  s1.taskId_ = scheduler->GetTaskId("db::DBTable");
365  s1.instances_.push_back(0);
366  ps.stages_ = list_of(s1)
367  .convert_to_container<vector<RequestPipeline::StageSpec> >();
368 
369  RequestPipeline rp(ps);
370 }
371 
373 public:
375  vector<ShowMvpnState> states;
376  };
377 
379  return (new MvpnProjectManagerDetailData);
380  }
381 
382  static void FillMvpnProjectStateInfo(const MvpnState *state,
383  ShowMvpnState *st) {
384  st->set_source(state->sg().source.to_string());
385  st->set_group(state->sg().group.to_string());
386  if (state->global_ermvpn_tree_rt()) {
387  st->set_global_ermvpn_tree_rt(
388  state->global_ermvpn_tree_rt()->ToString());
389  }
390  if (state->spmsi_rt())
391  st->set_spmsi_rt(state->spmsi_rt()->ToString());
392  if (state->source_active_rt())
393  st->set_source_active_rt(state->source_active_rt()->ToString());
394 
395  vector<string> spmsi_routes_received;
396  BOOST_FOREACH(MvpnRoute *rt, state->spmsi_routes_received()) {
397  spmsi_routes_received.push_back(rt->ToString());
398  }
399  st->set_spmsi_routes_received(spmsi_routes_received);
400 
401  vector<string> leafad_routes_attr_received;
402  BOOST_FOREACH(const MvpnState::RoutesMap::value_type &val,
403  state->leafad_routes_attr_received()) {
404  const PmsiTunnel *pmsi = val.second->pmsi_tunnel();
405  if (pmsi) {
406  leafad_routes_attr_received.push_back(
407  pmsi->pmsi_tunnel().ToString());
408  }
409  }
410  st->set_leafad_routes_attr_received(leafad_routes_attr_received);
411  st->set_total_states(state->states()->size());
412  st->set_project_manager(state->project_manager()->table()->name());
413  st->set_refcount(state->refcount());
414  }
415 
417  ErmVpnTable *table, int inst_id) {
419  if (!tm) return;
420  MvpnProjectManagerPartition *partition = tm->GetPartition(inst_id);
421  BOOST_FOREACH(MvpnState::StatesMap::value_type &val,
422  partition->states()) {
423  ShowMvpnState st;
424  FillMvpnProjectStateInfo(val.second, &st);
425  data->states.push_back(st);
426  }
427  }
428 
429  static bool CallbackS1(const Sandesh *sr,
430  const RequestPipeline::PipeSpec ps,
431  int stage, int instNum,
433  int inst_id = ps.stages_[stage].instances_[instNum];
434 
436  static_cast<MvpnProjectManagerDetailData *>(data);
437  const ShowMvpnProjectManagerDetailReq *req =
438  static_cast<const ShowMvpnProjectManagerDetailReq *>(
439  ps.snhRequest_.get());
440  BgpSandeshContext *bsc =
441  static_cast<BgpSandeshContext *>(req->client_context());
442  DBTableBase *table =
443  bsc->bgp_server->database()->FindTable(req->get_name());
444  ErmVpnTable *ermvpn_table = dynamic_cast<ErmVpnTable *>(table);
445  if (ermvpn_table && !ermvpn_table->IsVpnTable())
446  FillMvpnProjectPartitionInfo(mydata, ermvpn_table, inst_id);
447 
448  return true;
449  }
450 
452  const RequestPipeline::StageData *sd,
453  vector<ShowMvpnState> *states) {
454  for (size_t idx = 0; idx < sd->size(); idx++) {
455  const MvpnProjectManagerDetailData &data =
456  static_cast<const MvpnProjectManagerDetailData &>(sd->at(idx));
457  states->insert(states->end(),
458  data.states.begin(), data.states.end());
459  }
460  }
461 
462  static bool CallbackS2(const Sandesh *sr,
463  const RequestPipeline::PipeSpec ps,
464  int stage, int instNum,
466  const ShowMvpnProjectManagerReq *req =
467  static_cast<const ShowMvpnProjectManagerReq *>(
468  ps.snhRequest_.get());
469  const RequestPipeline::StageData *sd = ps.GetStageData(0);
470  vector<ShowMvpnState> states;
471  CombineMvpnProjectPartitionInfo(sd, &states);
472 
473  ShowMvpnProjectManagerDetailResp *resp =
474  new ShowMvpnProjectManagerDetailResp;
475  resp->set_states(states);
476  resp->set_context(req->context());
477  resp->Response();
478  return true;
479  }
480 };
481 
482 
483 void ShowMvpnProjectManagerDetailReq::HandleRequest() const {
484  RequestPipeline::PipeSpec ps(this);
485 
486  // Request pipeline has 2 stages.
487  // First stage to collect multicast manager stats.
488  // Second stage to fill stats from stage 1 and respond to the request.
491 
492  s1.taskId_ = scheduler->GetTaskId("db::DBTable");
495  for (int i = 0; i < ErmVpnTable::kPartitionCount; i++) {
496  s1.instances_.push_back(i);
497  }
498 
499  s2.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
501  s2.instances_.push_back(0);
502 
503  ps.stages_ = list_of(s1)(s2)
504  .convert_to_container<vector<RequestPipeline::StageSpec> >();
505  RequestPipeline rp(ps);
506 }
507 
509 public:
511  vector<ShowRoute> routes;
512  };
513 
515  return (new SearchRouteInVrfData);
516  }
517 
518  static bool CallbackS1(const Sandesh *sr,
519  const RequestPipeline::PipeSpec ps,
520  int stage, int instNum,
522  SearchRouteInVrfData *sdata = static_cast<SearchRouteInVrfData *>(data);
523  const ShowRouteVrfReq *req =
524  static_cast<const ShowRouteVrfReq *>(ps.snhRequest_.get());
525  BgpSandeshContext *bsc =
526  static_cast<BgpSandeshContext *>(req->client_context());
528  RoutingInstance *ri = rim->GetRoutingInstance(req->get_vrf());
529  if (!ri) return true;
530  BgpTable *table = ri->GetTable(Address::INET);
531  if (!table) return true;
532  Ip4Prefix prefix(Ip4Prefix::FromString(req->get_prefix()));
533  InetTable::RequestKey key(prefix, NULL);
534 
535  // Find route from the calling task instance specific db partition.
536  InetRoute *route = static_cast<InetRoute *>(table->Find(&key, instNum));
537  if (!route) return true;
538  ShowRoute show_route;
539  show_route.set_prefix(route->ToString());
540  show_route.set_last_modified(duration_usecs_to_string(
541  UTCTimestampUsec() - route->last_change_at()));
542  vector<ShowRoutePath> show_route_paths;
543  for (Route::PathList::const_iterator it = route->GetPathList().begin();
544  it != route->GetPathList().end(); it++) {
545  const BgpPath *path = static_cast<const BgpPath *>(it.operator->());
546  ShowRoutePath srp;
547  srp.set_protocol("BGP");
548  const BgpAttr *attr = path->GetAttr();
549  if (attr->as_path() != NULL)
550  srp.set_as_path(attr->as_path()->path().ToString());
551  srp.set_local_preference(attr->local_pref());
552  if (path->GetPeer()) srp.set_source(path->GetPeer()->ToString());
553  srp.set_last_modified(duration_usecs_to_string(
554  UTCTimestampUsec() - path->time_stamp_usecs()));
555  srp.set_next_hop(attr->nexthop().to_string());
556  srp.set_label(path->GetLabel());
557  show_route_paths.push_back(srp);
558  }
559  show_route.set_paths(show_route_paths);
560  sdata->routes.push_back(show_route);
561  return true;
562  }
563 
564  static bool CallbackS2(const Sandesh *sr,
565  const RequestPipeline::PipeSpec ps,
566  int stage, int instNum,
568  const RequestPipeline::StageData *sd = ps.GetStageData(0);
569  ShowRoute route;
570  for (size_t i = 0; i < sd->size(); i++) {
571  const SearchRouteInVrfData &data =
572  static_cast<const SearchRouteInVrfData &>(sd->at(i));
573  if (data.routes.size()) {
574  route = data.routes.front();
575  break;
576  }
577  }
578 
579  ShowRouteVrfResp *resp = new ShowRouteVrfResp;
580  resp->set_route(route);
581  const ShowRouteVrfReq *req =
582  static_cast<const ShowRouteVrfReq *>(ps.snhRequest_.get());
583  resp->set_context(req->context());
584  resp->Response();
585  return true;
586  }
587 };
588 
589 void ShowRouteVrfReq::HandleRequest() const {
590  RequestPipeline::PipeSpec ps(this);
591  BgpSandeshContext *bsc = static_cast<BgpSandeshContext *>(client_context());
592 
593  // Request pipeline has 2 stages.
594  // First stage to search in different partition
595  // Second stage to fill stats from stage 1 and respond to the request.
598 
599  s1.taskId_ = scheduler->GetTaskId("db::DBTable");
602  for (int i = 0; i < bsc->bgp_server->database()->PartitionCount(); i++) {
603  s1.instances_.push_back(i);
604  }
605 
606  s2.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
608  s2.instances_.push_back(0);
609 
610  ps.stages_ = list_of(s1)(s2)
611  .convert_to_container<vector<RequestPipeline::StageSpec> >();
612  RequestPipeline rp(ps);
613 }
614 
616 public:
617  static bool CallbackS1(const Sandesh *sr,
618  const RequestPipeline::PipeSpec ps, int stage, int instNum,
620  const ShowBgpServerReq *req =
621  static_cast<const ShowBgpServerReq *>(ps.snhRequest_.get());
622  BgpSandeshContext *bsc =
623  static_cast<BgpSandeshContext *>(req->client_context());
624 
625  ShowBgpServerResp *resp = new ShowBgpServerResp;
626  SocketIOStats peer_socket_stats;
627  bsc->bgp_server->session_manager()->GetRxSocketStats(&peer_socket_stats);
628  resp->set_rx_socket_stats(peer_socket_stats);
629 
630  bsc->bgp_server->session_manager()->GetTxSocketStats(&peer_socket_stats);
631  resp->set_tx_socket_stats(peer_socket_stats);
632 
633  resp->set_context(req->context());
634  resp->Response();
635  return true;
636  }
637 };
638 
639 void ShowBgpServerReq::HandleRequest() const {
640  RequestPipeline::PipeSpec ps(this);
641 
642  // Request pipeline has single stage to collect neighbor config info
643  // and respond to the request
646  s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
648  s1.instances_.push_back(0);
649  ps.stages_ = list_of(s1)
650  .convert_to_container<vector<RequestPipeline::StageSpec> >();
651  RequestPipeline rp(ps);
652 }
653 
655  : bgp_server(NULL),
656  xmpp_peer_manager(NULL),
657  test_mode_(false),
658  page_limit_(0),
659  iter_limit_(0) {
660 }
661 
663  const NeighborListExtension &show_neighbor,
664  const NeighborStatisticsExtension &show_neighbor_statistics) {
665  show_neighbor_ext_ = show_neighbor;
666  show_neighbor_statistics_ext_ = show_neighbor_statistics;
667 }
668 
670  bool summary, uint32_t page_limit, uint32_t iter_limit,
671  const string &start_neighbor, const string &search_string,
672  vector<BgpNeighborResp> *list, string *next_neighbor) const {
673  if (!show_neighbor_ext_)
674  return true;
675  bool done = show_neighbor_ext_(bsc, summary, page_limit, iter_limit,
676  start_neighbor, search_string, list, next_neighbor);
677  return done;
678 }
679 
681  size_t *count, const ShowNeighborStatisticsReq *req) const {
683  return;
684  show_neighbor_statistics_ext_(count, this, req);
685 }
686 
688  const PeeringReqHandler &show_peering_req_handler,
689  const PeeringReqIterateHandler &show_peering_req_iterate_handler) {
690  show_peering_req_handler_ = show_peering_req_handler;
691  show_peering_req_iterate_handler_ = show_peering_req_iterate_handler;
692 }
693 
695  const ShowBgpPeeringConfigReq *req) {
697  show_peering_req_handler_(this, req);
698  } else {
699  ShowBgpPeeringConfigResp *resp = new ShowBgpPeeringConfigResp;
700  resp->Response();
701  }
702 }
703 
705  const ShowBgpPeeringConfigReqIterate *req_iterate) {
707  show_peering_req_iterate_handler_(this, req_iterate);
708  } else {
709  ShowBgpPeeringConfigResp *resp = new ShowBgpPeeringConfigResp;
710  resp->Response();
711  }
712 }
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:160
ErmVpnRoute * global_ermvpn_tree_rt()
Definition: bgp_mvpn.cc:294
std::vector< int > instances_
const NeighborMap & neighbors() const
Definition: bgp_mvpn.cc:250
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:514
static void FillMvpnNeighborsInfo(MvpnManagerDetailData *data, MvpnTable *table, int inst_id)
Definition: bgp_sandesh.cc:315
virtual std::string ToString() const
Definition: mvpn_route.cc:845
const MvpnState::StatesMap & states() const
Definition: bgp_mvpn.h:377
const RouteDistinguisher & rd() const
Definition: bgp_mvpn.cc:222
NeighborListExtension show_neighbor_ext_
Definition: bgp_sandesh.h:72
uint32_t local_pref() const
Definition: bgp_attr.h:889
const IpAddress & nexthop() const
Definition: bgp_attr.h:886
BgpTable * GetTable(Address::Family fmly)
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
Definition: task.h:178
PeerManager * peer_manager()
RoutingInstance * GetRoutingInstance(const std::string &name)
PeeringReqIterateHandler show_peering_req_iterate_handler_
Definition: bgp_sandesh.h:75
const AsPathSpec & path() const
Definition: bgp_aspath.h:127
bool IsTreeBuilder(uint8_t level) const
boost::function< bool(const BgpSandeshContext *, bool, uint32_t, uint32_t, const std::string &, const std::string &, std::vector< BgpNeighborResp > *, std::string *)> NeighborListExtension
Definition: bgp_sandesh.h:26
boost::ptr_vector< InstData > StageData
static void FillMvpnNeighborInfo(const MvpnNeighbor *nbr, ShowMvpnNeighbor *snbr)
Definition: bgp_sandesh.cc:308
static void FillMvpnProjectStateInfo(const MvpnState *state, ShowMvpnState *st)
Definition: bgp_sandesh.cc:382
BgpServer * bgp_server
Definition: bgp_sandesh.h:46
DB * database()
Definition: bgp_server.h:200
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:114
static void FillMulticastLinkInfo(const McastForwarder *forwarder, ShowMulticastTreeLink *smtl)
Definition: bgp_sandesh.cc:164
std::string ToString() const
Definition: label_block.cc:106
MvpnRoute * source_active_rt()
Definition: bgp_mvpn.cc:334
static void CombineMulticastPartitionInfo(const RequestPipeline::StageData *sd, vector< ShowMulticastTree > *tree_list)
Definition: bgp_sandesh.cc:242
RoutesSet & spmsi_routes_received()
Definition: bgp_mvpn.cc:310
MvpnProjectManager * mvpn_project_manager()
Definition: ermvpn_table.h:68
ErmVpnTable * table()
Definition: bgp_mvpn.cc:560
static void FillMulticastTreeInfo(const McastSGEntry *sg, ShowMulticastTree *smt)
Definition: bgp_sandesh.cc:185
void GetTxSocketStats(SocketIOStats *socket_stats) const
Definition: tcp_server.cc:643
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:329
boost::function< void(const BgpSandeshContext *, const ShowBgpPeeringConfigReq *)> PeeringReqHandler
Definition: bgp_sandesh.h:32
RoutingInstanceMgr * routing_instance_mgr()
Definition: bgp_server.h:102
void SetPeeringShowHandlers(const PeeringReqHandler &show_peering_req_handler, const PeeringReqIterateHandler &show_peering_req_iterate_handler)
Definition: bgp_sandesh.cc:687
RoutingInstanceIterator end()
virtual std::string ToString() const
Definition: bgp_aspath.cc:73
BgpPeer * FindPeer(const std::string &name)
NeighborStatisticsExtension show_neighbor_statistics_ext_
Definition: bgp_sandesh.h:73
void GetRxSocketStats(SocketIOStats *socket_stats) const
Definition: tcp_server.cc:639
uint32_t source_as() const
Definition: bgp_mvpn.cc:226
uint32_t label() const
void set_as_path(AsPathPtr aspath)
Definition: bgp_attr.cc:955
void ShowNeighborStatisticsExtension(size_t *count, const ShowNeighborStatisticsReq *req) const
Definition: bgp_sandesh.cc:680
int GetTaskId(const std::string &name)
Definition: task.cc:856
const MvpnManager * manager() const
Definition: mvpn_table.h:64
tbb::reader_writer_lock & neighbors_mutex()
Definition: bgp_mvpn.h:186
const uint64_t last_change_at() const
Definition: db_entry.h:68
Ip4Address router_id() const
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:564
bool test_mode() const
Definition: bgp_sandesh.h:61
McastTreeManager * GetTreeManager()
bool ShowNeighborExtension(const BgpSandeshContext *bsc, bool summary, uint32_t page_limit, uint32_t iter_limit, const std::string &start_neighbor, const std::string &search_string, std::vector< BgpNeighborResp > *list, std::string *next_neighbor) const
Definition: bgp_sandesh.cc:669
static TaskScheduler * GetInstance()
Definition: task.cc:547
virtual std::string ToString() const
static Ip4Prefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
Definition: inet_route.cc:84
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:220
virtual const std::string & ToString() const =0
boost::function< void(size_t *, const BgpSandeshContext *, const ShowNeighborStatisticsReq *)> NeighborStatisticsExtension
Definition: bgp_sandesh.h:29
static const std::string duration_usecs_to_string(const uint64_t usecs)
Definition: time_util.h:62
const LabelBlock * label_block() const
IpAddress source
Definition: bgp_mvpn.h:275
BgpSessionManager * session_manager()
Definition: bgp_server.h:97
std::vector< StageSpec > stages_
Ip4Address address() const
IPeer * GetPeer()
Definition: bgp_path.h:76
MvpnProjectManagerPartition * GetPartition(int part_id)
Definition: bgp_mvpn.cc:148
const std::string & name() const
Definition: db_table.h:110
RoutesMap & leafad_routes_attr_received()
Definition: bgp_mvpn.cc:318
int refcount() const
Definition: bgp_mvpn.h:303
uint32_t GetLabel() const
Definition: bgp_path.h:89
virtual std::string ToString() const
Definition: bgp_attr.cc:309
virtual bool IsVpnTable() const
Definition: ermvpn_table.h:39
const AsPath * as_path() const
Definition: bgp_attr.h:899
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:253
boost::function< void(const BgpSandeshContext *, const ShowBgpPeeringConfigReqIterate *)> PeeringReqIterateHandler
Definition: bgp_sandesh.h:34
static const int kPartitionCount
Definition: ermvpn_table.h:21
virtual bool IsVpnTable() const
Definition: mvpn_table.h:45
std::vector< ForwarderSet * > forwarder_sets_
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:378
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:429
static uint64_t UTCTimestampUsec()
Definition: time_util.h:13
static void FillMvpnProjectPartitionInfo(MvpnProjectManagerDetailData *data, ErmVpnTable *table, int inst_id)
Definition: bgp_sandesh.cc:416
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:462
const BgpAttr * GetAttr() const
Definition: bgp_path.h:87
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:617
McastForwarderList tree_links_
std::string ToString() const
Definition: rd.cc:56
DBEntry * Find(const DBEntry *entry)
Definition: db_table.cc:469
static void FillMulticastPartitionInfo(MulticastManagerDetailData *data, ErmVpnTable *table, int inst_id)
Definition: bgp_sandesh.cc:207
const PmsiTunnelSpec & pmsi_tunnel() const
Definition: bgp_attr.h:373
boost::shared_ptr< const SandeshRequest > snhRequest_
const StatesMap * states() const
Definition: bgp_mvpn.h:294
MvpnRoute * spmsi_rt()
Definition: bgp_mvpn.cc:302
const uint64_t time_stamp_usecs() const
Definition: path.h:17
RoutingInstanceIterator begin()
void SetNeighborShowExtensions(const NeighborListExtension &show_neighbor, const NeighborStatisticsExtension &show_neighbor_statistics)
Definition: bgp_sandesh.cc:662
IpAddress group
Definition: bgp_mvpn.h:276
static int PartitionCount()
Definition: db.cc:32
const SG & sg() const
Definition: bgp_mvpn.cc:290
void PeeringShowReqHandler(const ShowBgpPeeringConfigReq *req)
Definition: bgp_sandesh.cc:694
static size_t FillBgpNeighborStatistics(const ShowNeighborStatisticsReq *req, BgpServer *bgp_server)
Definition: bgp_sandesh.cc:36
const IpAddress & originator() const
Definition: bgp_mvpn.cc:230
PeeringReqHandler show_peering_req_handler_
Definition: bgp_sandesh.h:74
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:518
const StageData * GetStageData(int stage) const
void PeeringShowReqIterateHandler(const ShowBgpPeeringConfigReqIterate *req_iterate)
Definition: bgp_sandesh.cc:704
MvpnProjectManager * project_manager()
Definition: bgp_mvpn.h:299
static void CombineMvpnProjectPartitionInfo(const RequestPipeline::StageData *sd, vector< ShowMvpnState > *states)
Definition: bgp_sandesh.cc:451
Ip4Address group() const
Ip4Address source() const
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:304
RoutingInstanceList::iterator RoutingInstanceIterator
static void FillMulticastForwarderInfo(const McastForwarder *forwarder, ShowMulticastForwarder *smf)
Definition: bgp_sandesh.cc:170
virtual std::string ToString() const
Definition: inet_route.h:69
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:63
McastManagerPartition * GetPartition(int part_id)
void Clear(int subcode)
Definition: bgp_peer.cc:1306
DBTableBase * FindTable(const std::string &name)
Definition: db.cc:68
const PathList & GetPathList() const
Definition: route.h:46
size_t GetNeighborCount(std::string up_or_down)