OpenSDN source code
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)
319  return;
320  std::shared_lock<std::shared_mutex> lock(tm->neighbors_mutex());
321 
322  BOOST_FOREACH(const MvpnManager::NeighborMap::value_type &val,
323  tm->neighbors()) {
324  ShowMvpnNeighbor snbr;
325  FillMvpnNeighborInfo(&val.second, &snbr);
326  data->neighbors.push_back(snbr);
327  }
328  }
329 
330  static bool CallbackS1(const Sandesh *sr,
331  const RequestPipeline::PipeSpec ps,
332  int stage, int instNum,
334  int inst_id = ps.stages_[stage].instances_[instNum];
335 
336  MvpnManagerDetailData *mydata =
337  static_cast<MvpnManagerDetailData *>(data);
338  const ShowMvpnManagerDetailReq *req =
339  static_cast<const ShowMvpnManagerDetailReq *>(
340  ps.snhRequest_.get());
341  BgpSandeshContext *bsc =
342  static_cast<BgpSandeshContext *>(req->client_context());
343  DBTableBase *table =
344  bsc->bgp_server->database()->FindTable(req->get_name());
345  MvpnTable *mvpn_table = dynamic_cast<MvpnTable *>(table);
346  if (mvpn_table && !mvpn_table->IsVpnTable())
347  FillMvpnNeighborsInfo(mydata, mvpn_table, inst_id);
348 
349  ShowMvpnManagerDetailResp *resp = new ShowMvpnManagerDetailResp;
350  resp->set_neighbors(mydata->neighbors);
351  resp->set_context(req->context());
352  resp->Response();
353 
354  return true;
355  }
356 };
357 
358 void ShowMvpnManagerDetailReq::HandleRequest() const {
359  RequestPipeline::PipeSpec ps(this);
362 
363  s1.taskId_ = scheduler->GetTaskId("db::DBTable");
366  s1.instances_.push_back(0);
367  ps.stages_ = list_of(s1)
368  .convert_to_container<vector<RequestPipeline::StageSpec> >();
369 
370  RequestPipeline rp(ps);
371 }
372 
374 public:
376  vector<ShowMvpnState> states;
377  };
378 
380  return (new MvpnProjectManagerDetailData);
381  }
382 
383  static void FillMvpnProjectStateInfo(const MvpnState *state,
384  ShowMvpnState *st) {
385  st->set_source(state->sg().source.to_string());
386  st->set_group(state->sg().group.to_string());
387  if (state->global_ermvpn_tree_rt()) {
388  st->set_global_ermvpn_tree_rt(
389  state->global_ermvpn_tree_rt()->ToString());
390  }
391  if (state->spmsi_rt())
392  st->set_spmsi_rt(state->spmsi_rt()->ToString());
393  if (state->source_active_rt())
394  st->set_source_active_rt(state->source_active_rt()->ToString());
395 
396  vector<string> spmsi_routes_received;
397  BOOST_FOREACH(MvpnRoute *rt, state->spmsi_routes_received()) {
398  spmsi_routes_received.push_back(rt->ToString());
399  }
400  st->set_spmsi_routes_received(spmsi_routes_received);
401 
402  vector<string> leafad_routes_attr_received;
403  BOOST_FOREACH(const MvpnState::RoutesMap::value_type &val,
404  state->leafad_routes_attr_received()) {
405  const PmsiTunnel *pmsi = val.second->pmsi_tunnel();
406  if (pmsi) {
407  leafad_routes_attr_received.push_back(
408  pmsi->pmsi_tunnel().ToString());
409  }
410  }
411  st->set_leafad_routes_attr_received(leafad_routes_attr_received);
412  st->set_total_states(state->states()->size());
413  st->set_project_manager(state->project_manager()->table()->name());
414  st->set_refcount(state->refcount());
415  }
416 
418  ErmVpnTable *table, int inst_id) {
420  if (!tm) return;
421  MvpnProjectManagerPartition *partition = tm->GetPartition(inst_id);
422  BOOST_FOREACH(MvpnState::StatesMap::value_type &val,
423  partition->states()) {
424  ShowMvpnState st;
425  FillMvpnProjectStateInfo(val.second, &st);
426  data->states.push_back(st);
427  }
428  }
429 
430  static bool CallbackS1(const Sandesh *sr,
431  const RequestPipeline::PipeSpec ps,
432  int stage, int instNum,
434  int inst_id = ps.stages_[stage].instances_[instNum];
435 
437  static_cast<MvpnProjectManagerDetailData *>(data);
438  const ShowMvpnProjectManagerDetailReq *req =
439  static_cast<const ShowMvpnProjectManagerDetailReq *>(
440  ps.snhRequest_.get());
441  BgpSandeshContext *bsc =
442  static_cast<BgpSandeshContext *>(req->client_context());
443  DBTableBase *table =
444  bsc->bgp_server->database()->FindTable(req->get_name());
445  ErmVpnTable *ermvpn_table = dynamic_cast<ErmVpnTable *>(table);
446  if (ermvpn_table && !ermvpn_table->IsVpnTable())
447  FillMvpnProjectPartitionInfo(mydata, ermvpn_table, inst_id);
448 
449  return true;
450  }
451 
453  const RequestPipeline::StageData *sd,
454  vector<ShowMvpnState> *states) {
455  for (size_t idx = 0; idx < sd->size(); idx++) {
456  const MvpnProjectManagerDetailData &data =
457  static_cast<const MvpnProjectManagerDetailData &>(sd->at(idx));
458  states->insert(states->end(),
459  data.states.begin(), data.states.end());
460  }
461  }
462 
463  static bool CallbackS2(const Sandesh *sr,
464  const RequestPipeline::PipeSpec ps,
465  int stage, int instNum,
467  const ShowMvpnProjectManagerReq *req =
468  static_cast<const ShowMvpnProjectManagerReq *>(
469  ps.snhRequest_.get());
470  const RequestPipeline::StageData *sd = ps.GetStageData(0);
471  vector<ShowMvpnState> states;
472  CombineMvpnProjectPartitionInfo(sd, &states);
473 
474  ShowMvpnProjectManagerDetailResp *resp =
475  new ShowMvpnProjectManagerDetailResp;
476  resp->set_states(states);
477  resp->set_context(req->context());
478  resp->Response();
479  return true;
480  }
481 };
482 
483 
484 void ShowMvpnProjectManagerDetailReq::HandleRequest() const {
485  RequestPipeline::PipeSpec ps(this);
486 
487  // Request pipeline has 2 stages.
488  // First stage to collect multicast manager stats.
489  // Second stage to fill stats from stage 1 and respond to the request.
492 
493  s1.taskId_ = scheduler->GetTaskId("db::DBTable");
496  for (int i = 0; i < ErmVpnTable::kPartitionCount; i++) {
497  s1.instances_.push_back(i);
498  }
499 
500  s2.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
502  s2.instances_.push_back(0);
503 
504  ps.stages_ = list_of(s1)(s2)
505  .convert_to_container<vector<RequestPipeline::StageSpec> >();
506  RequestPipeline rp(ps);
507 }
508 
510 public:
512  vector<ShowRoute> routes;
513  };
514 
516  return (new SearchRouteInVrfData);
517  }
518 
519  static bool CallbackS1(const Sandesh *sr,
520  const RequestPipeline::PipeSpec ps,
521  int stage, int instNum,
523  SearchRouteInVrfData *sdata = static_cast<SearchRouteInVrfData *>(data);
524  const ShowRouteVrfReq *req =
525  static_cast<const ShowRouteVrfReq *>(ps.snhRequest_.get());
526  BgpSandeshContext *bsc =
527  static_cast<BgpSandeshContext *>(req->client_context());
529  RoutingInstance *ri = rim->GetRoutingInstance(req->get_vrf());
530  if (!ri) return true;
531  BgpTable *table = ri->GetTable(Address::INET);
532  if (!table) return true;
533  Ip4Prefix prefix(Ip4Prefix::FromString(req->get_prefix()));
534  InetTable::RequestKey key(prefix, NULL);
535 
536  // Find route from the calling task instance specific db partition.
537  InetRoute *route = static_cast<InetRoute *>(table->Find(&key, instNum));
538  if (!route) return true;
539  ShowRoute show_route;
540  show_route.set_prefix(route->ToString());
541  show_route.set_last_modified(duration_usecs_to_string(
542  UTCTimestampUsec() - route->last_change_at()));
543  vector<ShowRoutePath> show_route_paths;
544  for (Route::PathList::const_iterator it = route->GetPathList().begin();
545  it != route->GetPathList().end(); it++) {
546  const BgpPath *path = static_cast<const BgpPath *>(it.operator->());
547  ShowRoutePath srp;
548  srp.set_protocol("BGP");
549  const BgpAttr *attr = path->GetAttr();
550  if (attr->as_path() != NULL)
551  srp.set_as_path(attr->as_path()->path().ToString());
552  srp.set_local_preference(attr->local_pref());
553  if (path->GetPeer()) srp.set_source(path->GetPeer()->ToString());
554  srp.set_last_modified(duration_usecs_to_string(
555  UTCTimestampUsec() - path->time_stamp_usecs()));
556  srp.set_next_hop(attr->nexthop().to_string());
557  srp.set_label(path->GetLabel());
558  show_route_paths.push_back(srp);
559  }
560  show_route.set_paths(show_route_paths);
561  sdata->routes.push_back(show_route);
562  return true;
563  }
564 
565  static bool CallbackS2(const Sandesh *sr,
566  const RequestPipeline::PipeSpec ps,
567  int stage, int instNum,
569  const RequestPipeline::StageData *sd = ps.GetStageData(0);
570  ShowRoute route;
571  for (size_t i = 0; i < sd->size(); i++) {
572  const SearchRouteInVrfData &data =
573  static_cast<const SearchRouteInVrfData &>(sd->at(i));
574  if (data.routes.size()) {
575  route = data.routes.front();
576  break;
577  }
578  }
579 
580  ShowRouteVrfResp *resp = new ShowRouteVrfResp;
581  resp->set_route(route);
582  const ShowRouteVrfReq *req =
583  static_cast<const ShowRouteVrfReq *>(ps.snhRequest_.get());
584  resp->set_context(req->context());
585  resp->Response();
586  return true;
587  }
588 };
589 
590 void ShowRouteVrfReq::HandleRequest() const {
591  RequestPipeline::PipeSpec ps(this);
592  BgpSandeshContext *bsc = static_cast<BgpSandeshContext *>(client_context());
593 
594  // Request pipeline has 2 stages.
595  // First stage to search in different partition
596  // Second stage to fill stats from stage 1 and respond to the request.
599 
600  s1.taskId_ = scheduler->GetTaskId("db::DBTable");
603  for (int i = 0; i < bsc->bgp_server->database()->PartitionCount(); i++) {
604  s1.instances_.push_back(i);
605  }
606 
607  s2.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
609  s2.instances_.push_back(0);
610 
611  ps.stages_ = list_of(s1)(s2)
612  .convert_to_container<vector<RequestPipeline::StageSpec> >();
613  RequestPipeline rp(ps);
614 }
615 
617 public:
618  static bool CallbackS1(const Sandesh *sr,
619  const RequestPipeline::PipeSpec ps, int stage, int instNum,
621  const ShowBgpServerReq *req =
622  static_cast<const ShowBgpServerReq *>(ps.snhRequest_.get());
623  BgpSandeshContext *bsc =
624  static_cast<BgpSandeshContext *>(req->client_context());
625 
626  ShowBgpServerResp *resp = new ShowBgpServerResp;
627  SocketIOStats peer_socket_stats;
628  bsc->bgp_server->session_manager()->GetRxSocketStats(&peer_socket_stats);
629  resp->set_rx_socket_stats(peer_socket_stats);
630 
631  bsc->bgp_server->session_manager()->GetTxSocketStats(&peer_socket_stats);
632  resp->set_tx_socket_stats(peer_socket_stats);
633 
634  resp->set_context(req->context());
635  resp->Response();
636  return true;
637  }
638 };
639 
640 void ShowBgpServerReq::HandleRequest() const {
641  RequestPipeline::PipeSpec ps(this);
642 
643  // Request pipeline has single stage to collect neighbor config info
644  // and respond to the request
647  s1.taskId_ = scheduler->GetTaskId("bgp::ShowCommand");
649  s1.instances_.push_back(0);
650  ps.stages_ = list_of(s1)
651  .convert_to_container<vector<RequestPipeline::StageSpec> >();
652  RequestPipeline rp(ps);
653 }
654 
656  : bgp_server(NULL),
657  xmpp_peer_manager(NULL),
658  test_mode_(false),
659  page_limit_(0),
660  iter_limit_(0) {
661 }
662 
664  const NeighborListExtension &show_neighbor,
665  const NeighborStatisticsExtension &show_neighbor_statistics) {
666  show_neighbor_ext_ = show_neighbor;
667  show_neighbor_statistics_ext_ = show_neighbor_statistics;
668 }
669 
671  bool summary, uint32_t page_limit, uint32_t iter_limit,
672  const string &start_neighbor, const string &search_string,
673  vector<BgpNeighborResp> *list, string *next_neighbor) const {
674  if (!show_neighbor_ext_)
675  return true;
676  bool done = show_neighbor_ext_(bsc, summary, page_limit, iter_limit,
677  start_neighbor, search_string, list, next_neighbor);
678  return done;
679 }
680 
682  size_t *count, const ShowNeighborStatisticsReq *req) const {
684  return;
685  show_neighbor_statistics_ext_(count, this, req);
686 }
687 
689  const PeeringReqHandler &show_peering_req_handler,
690  const PeeringReqIterateHandler &show_peering_req_iterate_handler) {
691  show_peering_req_handler_ = show_peering_req_handler;
692  show_peering_req_iterate_handler_ = show_peering_req_iterate_handler;
693 }
694 
696  const ShowBgpPeeringConfigReq *req) {
698  show_peering_req_handler_(this, req);
699  } else {
700  ShowBgpPeeringConfigResp *resp = new ShowBgpPeeringConfigResp;
701  resp->Response();
702  }
703 }
704 
706  const ShowBgpPeeringConfigReqIterate *req_iterate) {
708  show_peering_req_iterate_handler_(this, req_iterate);
709  } else {
710  ShowBgpPeeringConfigResp *resp = new ShowBgpPeeringConfigResp;
711  resp->Response();
712  }
713 }
@ INET
Definition: address.h:26
const AsPathSpec & path() const
Definition: bgp_aspath.h:127
uint32_t local_pref() const
Definition: bgp_attr.h:891
const AsPath * as_path() const
Definition: bgp_attr.h:901
void set_as_path(AsPathPtr aspath)
Definition: bgp_attr.cc:956
const IpAddress & nexthop() const
Definition: bgp_attr.h:888
uint32_t GetLabel() const
Definition: bgp_path.h:89
IPeer * GetPeer()
Definition: bgp_path.h:76
const BgpAttr * GetAttr() const
Definition: bgp_path.h:87
void Clear(int subcode)
Definition: bgp_peer.cc:1305
RoutingInstanceMgr * routing_instance_mgr()
Definition: bgp_server.h:106
DB * database()
Definition: bgp_server.h:207
BgpPeer * FindPeer(const std::string &name)
BgpSessionManager * session_manager()
Definition: bgp_server.h:101
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:114
const uint64_t last_change_at() const
Definition: db_entry.h:67
const std::string & name() const
Definition: db_table.h:110
DBEntry * Find(const DBEntry *entry)
Definition: db_table.cc:495
DBTableBase * FindTable(const std::string &name)
Definition: db.cc:68
virtual std::string ToString() const
virtual bool IsVpnTable() const
Definition: ermvpn_table.h:39
MvpnProjectManager * mvpn_project_manager()
Definition: ermvpn_table.h:68
static const int kPartitionCount
Definition: ermvpn_table.h:21
McastTreeManager * GetTreeManager()
virtual const std::string & ToString() const =0
virtual std::string ToString() const
Definition: inet_route.h:69
static Ip4Prefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
Definition: inet_route.cc:84
std::string ToString() const
Definition: label_block.cc:106
const LabelBlock * label_block() const
Ip4Address router_id() const
Ip4Address address() const
McastForwarderList tree_links_
uint32_t label() const
std::vector< ForwarderSet * > forwarder_sets_
Ip4Address source() const
Ip4Address group() const
bool IsTreeBuilder(uint8_t level) const
McastManagerPartition * GetPartition(int part_id)
std::shared_mutex & neighbors_mutex()
Definition: bgp_mvpn.h:187
const NeighborMap & neighbors() const
Definition: bgp_mvpn.cc:250
const MvpnState::StatesMap & states() const
Definition: bgp_mvpn.h:378
MvpnProjectManagerPartition * GetPartition(int part_id)
Definition: bgp_mvpn.cc:148
ErmVpnTable * table()
Definition: bgp_mvpn.cc:560
virtual std::string ToString() const
Definition: mvpn_route.cc:845
const StatesMap * states() const
Definition: bgp_mvpn.h:295
RoutesMap & leafad_routes_attr_received()
Definition: bgp_mvpn.cc:318
ErmVpnRoute * global_ermvpn_tree_rt()
Definition: bgp_mvpn.cc:294
const SG & sg() const
Definition: bgp_mvpn.cc:290
MvpnRoute * spmsi_rt()
Definition: bgp_mvpn.cc:302
int refcount() const
Definition: bgp_mvpn.h:304
RoutesSet & spmsi_routes_received()
Definition: bgp_mvpn.cc:310
MvpnRoute * source_active_rt()
Definition: bgp_mvpn.cc:334
MvpnProjectManager * project_manager()
Definition: bgp_mvpn.h:300
const MvpnManager * manager() const
Definition: mvpn_table.h:64
virtual bool IsVpnTable() const
Definition: mvpn_table.h:45
const uint64_t time_stamp_usecs() const
Definition: path.h:17
size_t GetNeighborCount(std::string up_or_down)
const PmsiTunnelSpec & pmsi_tunnel() const
Definition: bgp_attr.h:373
boost::ptr_vector< InstData > StageData
std::string ToString() const
Definition: rd.cc:56
const PathList & GetPathList() const
Definition: route.h:46
RoutingInstanceIterator end()
RoutingInstanceList::iterator RoutingInstanceIterator
RoutingInstance * GetRoutingInstance(const std::string &name)
RoutingInstanceIterator begin()
PeerManager * peer_manager()
BgpTable * GetTable(Address::Family fmly)
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:618
static void FillMulticastLinkInfo(const McastForwarder *forwarder, ShowMulticastTreeLink *smtl)
Definition: bgp_sandesh.cc:164
static void FillMulticastForwarderInfo(const McastForwarder *forwarder, ShowMulticastForwarder *smf)
Definition: bgp_sandesh.cc:170
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:160
static void FillMulticastPartitionInfo(MulticastManagerDetailData *data, ErmVpnTable *table, int inst_id)
Definition: bgp_sandesh.cc:207
static void CombineMulticastPartitionInfo(const RequestPipeline::StageData *sd, vector< ShowMulticastTree > *tree_list)
Definition: bgp_sandesh.cc:242
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:253
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:220
static void FillMulticastTreeInfo(const McastSGEntry *sg, ShowMulticastTree *smt)
Definition: bgp_sandesh.cc:185
static void FillMvpnNeighborInfo(const MvpnNeighbor *nbr, ShowMvpnNeighbor *snbr)
Definition: bgp_sandesh.cc:308
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:330
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:304
static void FillMvpnNeighborsInfo(MvpnManagerDetailData *data, MvpnTable *table, int inst_id)
Definition: bgp_sandesh.cc:315
static void CombineMvpnProjectPartitionInfo(const RequestPipeline::StageData *sd, vector< ShowMvpnState > *states)
Definition: bgp_sandesh.cc:452
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:463
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:430
static void FillMvpnProjectPartitionInfo(MvpnProjectManagerDetailData *data, ErmVpnTable *table, int inst_id)
Definition: bgp_sandesh.cc:417
static void FillMvpnProjectStateInfo(const MvpnState *state, ShowMvpnState *st)
Definition: bgp_sandesh.cc:383
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:379
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:63
static size_t FillBgpNeighborStatistics(const ShowNeighborStatisticsReq *req, BgpServer *bgp_server)
Definition: bgp_sandesh.cc:36
static RequestPipeline::InstData * CreateData(int stage)
Definition: bgp_sandesh.cc:515
static bool CallbackS2(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:565
static bool CallbackS1(const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data)
Definition: bgp_sandesh.cc:519
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
Definition: task.h:304
int GetTaskId(const std::string &name)
Definition: task.cc:861
static TaskScheduler * GetInstance()
Definition: task.cc:554
void GetRxSocketStats(SocketIOStats *socket_stats) const
Definition: tcp_server.cc:641
void GetTxSocketStats(SocketIOStats *socket_stats) const
Definition: tcp_server.cc:645
virtual std::string ToString() const
Definition: bgp_aspath.cc:73
void SetPeeringShowHandlers(const PeeringReqHandler &show_peering_req_handler, const PeeringReqIterateHandler &show_peering_req_iterate_handler)
Definition: bgp_sandesh.cc:688
void SetNeighborShowExtensions(const NeighborListExtension &show_neighbor, const NeighborStatisticsExtension &show_neighbor_statistics)
Definition: bgp_sandesh.cc:663
NeighborStatisticsExtension show_neighbor_statistics_ext_
Definition: bgp_sandesh.h:73
void ShowNeighborStatisticsExtension(size_t *count, const ShowNeighborStatisticsReq *req) const
Definition: bgp_sandesh.cc:681
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:670
PeeringReqIterateHandler show_peering_req_iterate_handler_
Definition: bgp_sandesh.h:75
uint32_t iter_limit() const
Definition: bgp_sandesh.h:65
bool test_mode() const
Definition: bgp_sandesh.h:61
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::function< void(size_t *, const BgpSandeshContext *, const ShowNeighborStatisticsReq *)> NeighborStatisticsExtension
Definition: bgp_sandesh.h:29
boost::function< void(const BgpSandeshContext *, const ShowBgpPeeringConfigReq *)> PeeringReqHandler
Definition: bgp_sandesh.h:32
uint32_t page_limit() const
Definition: bgp_sandesh.h:63
boost::function< void(const BgpSandeshContext *, const ShowBgpPeeringConfigReqIterate *)> PeeringReqIterateHandler
Definition: bgp_sandesh.h:34
PeeringReqHandler show_peering_req_handler_
Definition: bgp_sandesh.h:74
void PeeringShowReqHandler(const ShowBgpPeeringConfigReq *req)
Definition: bgp_sandesh.cc:695
NeighborListExtension show_neighbor_ext_
Definition: bgp_sandesh.h:72
BgpServer * bgp_server
Definition: bgp_sandesh.h:46
void PeeringShowReqIterateHandler(const ShowBgpPeeringConfigReqIterate *req_iterate)
Definition: bgp_sandesh.cc:705
const IpAddress & originator() const
Definition: bgp_mvpn.cc:230
uint32_t source_as() const
Definition: bgp_mvpn.cc:226
const RouteDistinguisher & rd() const
Definition: bgp_mvpn.cc:222
IpAddress source
Definition: bgp_mvpn.h:276
IpAddress group
Definition: bgp_mvpn.h:277
virtual std::string ToString() const
Definition: bgp_attr.cc:309
boost::shared_ptr< const SandeshRequest > snhRequest_
const StageData * GetStageData(int stage) const
std::vector< StageSpec > stages_
std::vector< int > instances_
static const std::string duration_usecs_to_string(const uint64_t usecs)
Definition: time_util.h:62
static uint64_t UTCTimestampUsec()
Definition: time_util.h:13