OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mvpn_table.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "bgp/mvpn/mvpn_table.h"
6 
7 #include <utility>
8 #include <boost/foreach.hpp>
9 
10 #include "base/task_annotations.h"
13 #include "bgp/ipeer.h"
14 #include "bgp/bgp_factory.h"
15 #include "bgp/bgp_log.h"
16 #include "bgp/bgp_multicast.h"
17 #include "bgp/bgp_mvpn.h"
18 #include "bgp/bgp_server.h"
19 #include "bgp/bgp_update.h"
20 #include "bgp/inet/inet_table.h"
24 #include "bgp/routing-instance/routing_instance_analytics_types.h"
26 
27 using std::unique_ptr;
28 using std::pair;
29 using std::string;
30 using std::set;
31 
32 size_t MvpnTable::HashFunction(const MvpnPrefix &prefix) const {
33  if ((prefix.type() == MvpnPrefix::IntraASPMSIADRoute) ||
34  (prefix.type() == MvpnPrefix::LeafADRoute)) {
35  uint32_t data = prefix.originator().to_ulong();
36  return boost::hash_value(data);
37  }
38  if (prefix.type() == MvpnPrefix::InterASPMSIADRoute) {
39  uint32_t data = prefix.asn();
40  return boost::hash_value(data);
41  }
42  return boost::hash_value(prefix.group().to_ulong());
43 }
44 
45 MvpnTable::MvpnTable(DB *db, const string &name)
46  : BgpTable(db, name), manager_(NULL) {
47 }
48 
50  if (routing_instance()->IsMasterRoutingInstance())
51  return NULL;
53  path_resolver->set_nexthop_longest_match(true);
54  return path_resolver;
55 }
56 
57 unique_ptr<DBEntry> MvpnTable::AllocEntry(
58  const DBRequestKey *key) const {
59  const RequestKey *pfxkey = static_cast<const RequestKey *>(key);
60  return unique_ptr<DBEntry> (new MvpnRoute(pfxkey->prefix));
61 }
62 
63 unique_ptr<DBEntry> MvpnTable::AllocEntryStr(
64  const string &key_str) const {
65  MvpnPrefix prefix = MvpnPrefix::FromString(key_str);
66  return unique_ptr<DBEntry> (new MvpnRoute(prefix));
67 }
68 
69 size_t MvpnTable::Hash(const DBEntry *entry) const {
70  const MvpnRoute *rt_entry = static_cast<const MvpnRoute *>(entry);
71  const MvpnPrefix &mvpnprefix = rt_entry->GetPrefix();
72  size_t value = MvpnTable::HashFunction(mvpnprefix);
73  return value % kPartitionCount;
74 }
75 
76 size_t MvpnTable::Hash(const DBRequestKey *key) const {
77  const RequestKey *rkey = static_cast<const RequestKey *>(key);
78  Ip4Prefix prefix(rkey->prefix.group(), 32);
79  size_t value = InetTable::HashFunction(prefix);
80  return value % kPartitionCount;
81 }
82 
84  const DBRequestKey *prefix) {
85  const RequestKey *pfxkey = static_cast<const RequestKey *>(prefix);
86  MvpnRoute rt_key(pfxkey->prefix);
87  return static_cast<BgpRoute *>(rtp->Find(&rt_key));
88 }
89 
90 DBTableBase *MvpnTable::CreateTable(DB *db, const string &name) {
91  MvpnTable *table = new MvpnTable(db, name);
92  table->Init();
93  return table;
94 }
95 
97  if (manager_)
98  return;
99 
100  // Don't create the MvpnManager if ProjectManager is not present.
102  if (!pm)
103  return;
104  manager_ = BgpStaticObjectFactory::Create<MvpnManager>(this, pm->table());
105  manager_->Initialize();
106 
107  // Notify all routes in the table for further evaluation.
109 
110  // TODO(Ananth): Should we also notify routes in the bgp.mvpn.0 table ?
111 }
112 
114  if (!manager_)
115  return;
116  if (IsDeleted())
118  manager_->Terminate();
119  delete manager_;
120  manager_ = NULL;
121 }
122 
124  if (!server()->mvpn_ipv4_enable())
125  return;
126  RoutingInstance *rtinstance = routing_instance();
127  tbb::mutex::scoped_lock lock(rtinstance->manager()->mutex());
128 
129  // Don't create the MvpnManager for the VPN table.
130  if (!rtinstance->IsMasterRoutingInstance() &&
131  !rtinstance->mvpn_project_manager_network().empty()) {
132  pair<MvpnProjectManagerNetworks::iterator, bool> ret =
133  rtinstance->manager()->mvpn_project_managers().insert(make_pair(
134  rtinstance->mvpn_project_manager_network(), set<string>()));
135  ret.first->second.insert(rtinstance->name());
136 
137  // Initialize MVPN Manager.
138  CreateManager();
139  }
140 
141  MvpnProjectManagerNetworks::iterator iter =
142  rtinstance->manager()->mvpn_project_managers().find(
143  rtinstance->name());
144  if (iter == rtinstance->manager()->mvpn_project_managers().end())
145  return;
146 
147  BOOST_FOREACH(const string &mvpn_network, iter->second) {
148  RoutingInstance *rti =
149  rtinstance->manager()->GetRoutingInstance(mvpn_network);
150  if (!rti || rti->deleted())
151  continue;
152  MvpnTable *table =
153  dynamic_cast<MvpnTable *>(rti->GetTable(Address::MVPN));
154  if (!table || table->IsDeleted())
155  continue;
156  table->CreateManager();
157  }
158 }
159 
161  if (!server()->mvpn_ipv4_enable())
162  return;
163  if (routing_instance()->mvpn_project_manager_network().empty())
164  return;
165  tbb::mutex::scoped_lock lock(routing_instance()->manager()->mutex());
166  MvpnProjectManagerNetworks::iterator iter =
168  routing_instance()->mvpn_project_manager_network());
169  if (iter != routing_instance()->manager()->mvpn_project_managers().end()) {
170  iter->second.erase(routing_instance()->name());
171  if (iter->second.empty())
172  routing_instance()->manager()->mvpn_project_managers().erase(iter);
173  }
174 }
175 
176 // Call the const version to avoid code duplication.
178  return const_cast<MvpnProjectManager *>(
179  static_cast<const MvpnTable *>(this)->GetProjectManager());
180 }
181 
182 // Get MvpnProjectManager object for this Mvpn. Each MVPN network is associated
183 // with a parent project maanger network via configuration. MvpnProjectManager
184 // is retrieved from this parent network RoutingInstance's ErmVpnTable.
186  std::string pm_network = routing_instance()->mvpn_project_manager_network();
187  if (pm_network.empty())
188  return NULL;
189  const RoutingInstance *rtinstance =
190  routing_instance()->manager()->GetRoutingInstance(pm_network);
191  if (!rtinstance)
192  return NULL;
193  const ErmVpnTable *table = dynamic_cast<const ErmVpnTable *>(
194  rtinstance->GetTable(Address::ERMVPN));
195  if (!table)
196  return NULL;
197  return table->mvpn_project_manager();
198 }
199 
201  std::string pm_network = routing_instance()->mvpn_project_manager_network();
202  if (pm_network.empty())
203  return false;
204  const RoutingInstance *rtinstance =
205  routing_instance()->manager()->GetRoutingInstance(pm_network);
206  if (!rtinstance || rtinstance->deleted())
207  return false;
208  const ErmVpnTable *table = dynamic_cast<const ErmVpnTable *>(
209  rtinstance->GetTable(Address::ERMVPN));
210  if (!table || table->IsDeleted())
211  return false;
212 
213  if (!table->mvpn_project_manager() ||
214  table->mvpn_project_manager()->deleter()->IsDeleted()) {
215  return false;
216  }
217  return true;
218 }
219 
220 // Return the MvpnProjectManagerPartition for this route using the same DB
221 // partition index as of the route.
223  BgpRoute *route) const {
225  if (!manager)
226  return NULL;
227  int part_id = route->get_table_partition()->index();
228  return manager->GetPartition(part_id);
229 }
230 
231 // Override virtual method to retrive target table for MVPN routes. For now,
232 // only Type-4 LeafAD routes require special treatment, as they always come
233 // with the same route target <router-id>:0. Hence, if normal rtf selection
234 // mode is used, every table with MVPN enalbled would have to be notified for
235 // replication. Instead, find the table based on the correspondong S-PMSI route.
236 // This route can be retrieved from the MVPN state of the <S-G> maintained in
237 // the MvpnProjectManagerPartition object.
239  TableSet *secondary_tables) {
240  MvpnRoute *mvpn_rt = dynamic_cast<MvpnRoute *>(rt);
241  assert(mvpn_rt);
242 
243  // Special table lookup is required only for the Type4 LeafAD routes.
244  if (mvpn_rt->GetPrefix().type() != MvpnPrefix::LeafADRoute)
245  return;
246 
247  // Find Type-3 S-PMSI route from the Type-4 prefix route.
248  MvpnPrefix spmsi_prefix;
249  spmsi_prefix.SetSPMSIPrefixFromLeafADPrefix(mvpn_rt->GetPrefix());
250  const MvpnRoute *spmsi_rt = FindRoute(spmsi_prefix);
251  if (!spmsi_rt || !spmsi_rt->IsUsable())
252  return;
253  if (!spmsi_rt->BestPath()->IsReplicated())
254  return;
255 
256  const BgpTable *table = dynamic_cast<const BgpSecondaryPath *>(
257  spmsi_rt->BestPath())->src_table();
258  const MvpnTable *mvpn_table = dynamic_cast<const MvpnTable *>(table);
259  if (!mvpn_table || mvpn_table->IsMaster() || !mvpn_table->manager())
260  return;
262  mvpn_rt, secondary_tables);
263 }
264 
265 // Find or create the route.
267  MvpnRoute rt_key(prefix);
268  DBTablePartition *rtp = static_cast<DBTablePartition *>(
269  GetTablePartition(&rt_key));
270  return dynamic_cast<MvpnRoute *>(rtp->Find(&rt_key));
271 }
272 
273 const MvpnRoute *MvpnTable::FindRoute(const MvpnPrefix &prefix) const {
274  MvpnRoute rt_key(prefix);
275  const DBTablePartition *rtp = static_cast<const DBTablePartition *>(
276  GetTablePartition(&rt_key));
277  return dynamic_cast<const MvpnRoute *>(rtp->Find(&rt_key));
278 }
279 
280 // Find or create the route.
282  MvpnRoute rt_key(prefix);
283  DBTablePartition *rtp = static_cast<DBTablePartition *>(
284  GetTablePartition(&rt_key));
285  MvpnRoute *dest_route = dynamic_cast<MvpnRoute *>(rtp->Find(&rt_key));
286  if (dest_route == NULL) {
287  dest_route = new MvpnRoute(prefix);
288  rtp->Add(dest_route);
289  } else {
290  dest_route->ClearDelete();
291  }
292  return dest_route;
293 }
294 
296  assert(type3_rt->GetPrefix().type() == MvpnPrefix::SPMSIADRoute);
297  const Ip4Address originator_ip(server()->bgp_identifier());
298  MvpnPrefix prefix(MvpnPrefix::LeafADRoute, originator_ip);
299  prefix.SetLeafADPrefixFromSPMSIPrefix(type3_rt->GetPrefix());
300  return prefix;
301 }
302 
304  MvpnPrefix prefix = CreateType4LeafADRoutePrefix(type3_spmsi_rt);
305  return LocateRoute(prefix);
306 }
307 
309  assert(type7_rt->GetPrefix().type() == MvpnPrefix::SourceTreeJoinRoute);
310  const RouteDistinguisher rd = type7_rt->GetPrefix().route_distinguisher();
311  Ip4Address source = type7_rt->GetPrefix().source();
312  Ip4Address group = type7_rt->GetPrefix().group();
313  const Ip4Address originator_ip(server()->bgp_identifier());
314  MvpnPrefix prefix(MvpnPrefix::SPMSIADRoute, rd, originator_ip,
315  group, source);
316  return prefix;
317 }
318 
321  Ip4Address source = rt->GetPrefix().source();
322  Ip4Address group = rt->GetPrefix().group();
324  0, group, source);
325  return prefix;
326 }
327 
329  MvpnRoute *rt) const {
330  // get the source-rd from attributes as we store type-5 route with zero-rd
331  const BgpAttr *attr = rt->BestPath()->GetAttr();
332  assert(attr);
333  assert(!attr->source_rd().IsZero());
334  const RouteDistinguisher rd = attr->source_rd();
335  Ip4Address source = rt->GetPrefix().source();
336  Ip4Address group = rt->GetPrefix().group();
338  server()->autonomous_system(), group, source);
339  return prefix;
340 }
341 
343  MvpnPrefix prefix = CreateType3SPMSIRoutePrefix(type7_rt);
344  return LocateRoute(prefix);
345 }
346 
348  const RouteDistinguisher *rd = routing_instance()->GetRD();
350  server()->autonomous_system());
351  return prefix;
352 }
353 
355  const Ip4Address &originator_ip) {
356  const RouteDistinguisher rd(originator_ip.to_ulong(),
357  routing_instance()->index());
358  MvpnPrefix prefix(MvpnPrefix::IntraASPMSIADRoute, rd, originator_ip);
359  return prefix;
360 }
361 
363  return CreateType1ADRoutePrefix(Ip4Address(server()->bgp_identifier()));
364 }
365 
368  return LocateRoute(prefix);
369 }
370 
372  MvpnPrefix prefix = CreateType1ADRoutePrefix(originator_ip);
373  return FindRoute(prefix);
374 }
375 
377  Ip4Address originator_ip(server()->bgp_identifier());
378  return FindType1ADRoute(Ip4Address(server()->bgp_identifier()));
379 }
380 
382  MvpnPrefix prefix;
385  if (rt->GetPrefix().type() == MvpnPrefix::SPMSIADRoute) {
386  prefix = CreateLocalType7Prefix(rt);
387  }
388  return FindRoute(prefix);
389 }
390 
392  BgpRoute *rt, const BgpPath *src_path, ExtCommunityPtr community) {
393  MvpnTable *src_table = dynamic_cast<MvpnTable *>(stable);
394  assert(src_table);
395  MvpnRoute *src_rt = dynamic_cast<MvpnRoute *>(rt);
396  assert(src_rt);
397 
398  if (!server->mvpn_ipv4_enable()) {
399  return ReplicatePath(server, src_rt->GetPrefix(), src_table, src_rt,
400  src_path, community);
401  }
402 
403  // Replicate Type7 C-Join route.
404  if (src_rt->GetPrefix().type() == MvpnPrefix::SourceTreeJoinRoute) {
405  return ReplicateType7SourceTreeJoin(server, src_table, src_rt,
406  src_path, community);
407  }
408 
409  if (!IsMaster()) {
410  // For type-4 paths, only replicate if there is a type-3 primary path
411  // present in the table.
412  if (src_rt->GetPrefix().type() == MvpnPrefix::LeafADRoute) {
414  if (!pm)
415  return NULL;
416  MvpnStatePtr mvpn_state = pm->GetState(src_rt);
417  if (!mvpn_state || !mvpn_state->spmsi_rt() ||
418  !mvpn_state->spmsi_rt()->IsUsable()) {
419  return NULL;
420  }
421  if (mvpn_state->spmsi_rt()->table() != this)
422  return NULL;
423  }
424  }
425 
426  // Replicate all other types.
427  return ReplicatePath(server, src_rt->GetPrefix(), src_table, src_rt,
428  src_path, community);
429 }
430 
432  MvpnTable *src_table, MvpnRoute *src_rt, const BgpPath *src_path,
433  ExtCommunityPtr ext_community) {
434 
435  // Only replicate if route has a target that matches this table's auto
436  // created route target (vit).
437  if (!IsMaster()) {
438  RouteTarget vit(Ip4Address(server->bgp_identifier()),
439  routing_instance()->index());
440  bool vit_found = false;
441  BOOST_FOREACH(const ExtCommunity::ExtCommunityValue &comm,
442  ext_community->communities()) {
443  if (ExtCommunity::is_route_target(comm)) {
444  RouteTarget rtarget(comm);
445  if (rtarget == vit) {
446  vit_found = true;
447  break;
448  }
449  }
450  }
451 
452  if (!vit_found) {
453  MVPN_RT_LOG(src_rt, "Route was not replicated as rt-import "
454  "extended-community was not found");
455  return NULL;
456  }
457  }
458 
459  // If replicating from Master table, no special checks are required.
460  if (src_table->IsMaster()) {
461  return ReplicatePath(server, src_rt->GetPrefix(), src_table, src_rt,
462  src_path, ext_community);
463  }
464 
465  // This is the case when routes are replicated either to Master or to other
466  // vrf.mvpn.0 as identified the route targets. In either case, basic idea
467  // is to target the replicated path directly to vrf where sender resides.
468  //
469  // Route-target of the target vrf is derived from the Vrf Import Target of
470  // the route the source resolves to. Resolver code would have already
471  // computed this and encoded inside source-rd. Also source-as to encode in
472  // the RD is also encoded as part of the SourceAS extended community.
473  const BgpAttr *attr = src_path->GetAttr();
474  if (!attr)
475  return NULL;
476 
477  // Do not resplicate if the source is not resolvable.
478  if (attr->source_rd().IsZero()) {
479  MVPN_RT_LOG(src_rt, "Route was not replicated as source_rd is zero");
480  return NULL;
481  }
482 
483  // Find source-as extended-community. If not present, do not replicate
484  bool source_as_found = false;
485  SourceAs source_as;
486  BOOST_FOREACH(const ExtCommunity::ExtCommunityValue &value,
487  attr->ext_community()->communities()) {
488  if (ExtCommunity::is_source_as(value)) {
489  source_as_found = true;
490  source_as = SourceAs(value);
491  break;
492  }
493  }
494 
495  if (!source_as_found) {
496  MVPN_RT_LOG(src_rt, "Route was not replicated as source_as is zero");
497  return NULL;
498  }
499 
500  // No need to send SourceAS with this mvpn route. This is only sent along
501  // with the unicast routes.
502  ext_community =
503  server->extcomm_db()->RemoveSourceASAndLocate(ext_community.get());
504 
505  // Replicate path using source route's<C-S,G>, source_rd and asn as encoded
506  // in the source-as attribute.
508  source_as.GetAsn(), src_rt->GetPrefix().group(),
509  src_rt->GetPrefix().source());
510 
511  // Replicate the path with the computed prefix and attributes.
512  return ReplicatePath(server, prefix, src_table, src_rt, src_path,
513  ext_community);
514 }
515 
517  MvpnTable *src_table, MvpnRoute *src_rt, const BgpPath *src_path,
518  ExtCommunityPtr comm) {
519  MvpnRoute rt_key(mprefix);
520 
521  // Find or create the route.
522  DBTablePartition *rtp =
523  static_cast<DBTablePartition *>(GetTablePartition(&rt_key));
524  BgpRoute *dest_route = static_cast<BgpRoute *>(rtp->Find(&rt_key));
525  if (dest_route == NULL) {
526  dest_route = new MvpnRoute(mprefix);
527  rtp->Add(dest_route);
528  } else {
529  dest_route->ClearDelete();
530  }
531 
532  BgpAttrPtr new_attr =
533  server->attr_db()->ReplaceExtCommunityAndLocate(src_path->GetAttr(),
534  comm.get());
535  // Replace Nexthop with controller address, MX rejects the route if
536  // nexthop is same as neighbor address, needed for Type-7 routes
537  new_attr = server->attr_db()->ReplaceNexthopAndLocate(new_attr.get(),
538  Ip4Address(server->bgp_identifier()));
539  // Need to strip off route targets other than sender-ip:0
540  if (src_rt->GetPrefix().type() == MvpnPrefix::LeafADRoute) {
543  RouteTarget leaf_ad_rtarget(ip, 0);
544  BOOST_FOREACH(const ExtCommunity::ExtCommunityValue &value,
545  comm->communities()) {
546  if (ExtCommunity::is_route_target(value)) {
547  if (leaf_ad_rtarget == RouteTarget(value)) {
548  rtarget.push_back(value);
549  break;
550  }
551  }
552  }
553 
554  if (rtarget.size() == 1) {
555  ExtCommunityPtr ext_community = server->extcomm_db()->
556  ReplaceRTargetAndLocate(new_attr->ext_community(), rtarget);
557  new_attr = server->attr_db()->ReplaceExtCommunityAndLocate(
558  src_path->GetAttr(), ext_community.get());
559  } else {
560  MVPN_RT_LOG(src_rt,
561  "Could not find <originator>:0 route-target community");
562  }
563  }
564 
565  // Check whether peer already has a path.
566  BgpPath *dest_path = dest_route->FindSecondaryPath(src_rt,
567  src_path->GetSource(), src_path->GetPeer(),
568  src_path->GetPathId());
569  if (dest_path != NULL) {
570  if (new_attr != dest_path->GetOriginalAttr() ||
571  src_path->GetFlags() != dest_path->GetFlags()) {
572  bool success = dest_route->RemoveSecondaryPath(src_rt,
573  src_path->GetSource(), src_path->GetPeer(),
574  src_path->GetPathId());
575  assert(success);
576  } else {
577  return dest_route;
578  }
579  }
580 
581  // Create replicated path and insert it on the route.
582  BgpSecondaryPath *replicated_path =
583  new BgpSecondaryPath(src_path->GetPeer(), src_path->GetPathId(),
584  src_path->GetSource(), new_attr,
585  src_path->GetFlags(), src_path->GetLabel());
586  replicated_path->SetReplicateInfo(src_table, src_rt);
587  dest_route->InsertPath(replicated_path);
588  rtp->Notify(dest_route);
589  MVPN_RT_LOG(src_rt, "Route was successfully replicated");
590  return dest_route;
591 }
592 
593 bool MvpnTable::Export(RibOut *ribout, Route *route,
594  const RibPeerSet &peerset, UpdateInfoSList &uinfo_slist) {
595  MvpnRoute *mvpn_route = dynamic_cast<MvpnRoute *>(route);
596 
597  if (ribout->IsEncodingXmpp()) {
598  UpdateInfo *uinfo = GetMvpnUpdateInfo(ribout, mvpn_route, peerset);
599  if (!uinfo)
600  return false;
601  uinfo_slist->push_front(*uinfo);
602  return true;
603  }
604  BgpRoute *bgp_route = static_cast<BgpRoute *> (route);
605 
606  UpdateInfo *uinfo = GetUpdateInfo(ribout, bgp_route, peerset);
607  if (!uinfo) {
608  MVPN_RT_LOG(mvpn_route, "Route was exported as update_info could not "
609  "be computed");
610  return false;
611  }
612  uinfo_slist->push_front(*uinfo);
613  return true;
614 }
615 
617  const RibPeerSet &peerset, RibPeerSet *new_peerset) {
618  RibOut::PeerIterator iter(ribout, peerset);
619  while (iter.HasNext()) {
620  int current_index = iter.index();
621  IPeer *peer = dynamic_cast<IPeer *>(iter.Next());
622  assert(peer);
623  for (Route::PathList::const_iterator it = route->GetPathList().begin();
624  it != route->GetPathList().end(); ++it) {
625  const BgpPath *path = static_cast<const BgpPath *>(it.operator->());
626  if (path->IsFeasible() && peer == path->GetPeer()) {
627  new_peerset->set(current_index);
628  break;
629  }
630  }
631  }
632 }
633 
635  const RibPeerSet &peerset) {
636  if ((route->GetPrefix().type() != MvpnPrefix::SourceActiveADRoute) &&
638  return NULL;
639  if (!route->IsUsable())
640  return NULL;
641 
642  if (route->BestPath()->IsReplicated())
643  return NULL;
644 
646  if (!pm) {
647  MVPN_RT_LOG(route, "Route was exported as ProjectManager was "
648  "not found");
649  return NULL;
650  }
651 
652  RibPeerSet new_peerset;
653  GetPeerSet(ribout, route, peerset, &new_peerset);
654 
655  if (new_peerset.empty())
656  return NULL;
657 
658  UpdateInfo *uinfo = pm->GetUpdateInfo(route);
659  if (uinfo)
660  uinfo->target = new_peerset;
661  return uinfo;
662 }
663 
664 bool MvpnTable::IsMaster() const {
666 }
667 
668 static void RegisterFactory() {
670 }
671 
MvpnStatePtr GetState(MvpnRoute *route) const
Definition: bgp_mvpn.cc:165
int index() const
Definition: bgp_ribout.h:276
virtual void Initialize()
Definition: bgp_mvpn.cc:606
boost::array< uint8_t, 8 > ExtCommunityValue
Definition: community.h:152
BgpTable * GetTable(Address::Family fmly)
const BgpPath * BestPath() const
Definition: bgp_route.cc:46
const RouteDistinguisher * GetRD() const
RoutingInstance * GetRoutingInstance(const std::string &name)
void DeleteMvpnManager()
Definition: mvpn_table.cc:160
UpdateInfo * GetUpdateInfo(RibOut *ribout, BgpRoute *route, const RibPeerSet &peerset)
Definition: bgp_table.cc:578
bool RemoveSecondaryPath(const BgpRoute *src_rt, BgpPath::PathSource src, const IPeer *peer, uint32_t path_id)
Definition: bgp_route.cc:397
MvpnRoute * LocateRoute(const MvpnPrefix &prefix)
Definition: mvpn_table.cc:281
DBEntry * Find(const DBEntry *entry)
size_t HashFunction(const MvpnPrefix &prefix) const
Definition: mvpn_table.cc:32
static void RegisterFactory()
Definition: mvpn_table.cc:668
virtual bool Export(RibOut *ribout, Route *route, const RibPeerSet &peerset, UpdateInfoSList &info_slist)
Definition: mvpn_table.cc:593
RoutingInstance * routing_instance()
Definition: bgp_table.h:148
BgpRoute * ReplicatePath(BgpServer *server, const MvpnPrefix &mprefix, MvpnTable *src_table, MvpnRoute *src_rt, const BgpPath *src_path, ExtCommunityPtr comm)
Definition: mvpn_table.cc:516
virtual void Terminate()
Definition: bgp_mvpn.cc:431
virtual std::unique_ptr< DBEntry > AllocEntryStr(const std::string &key) const
Definition: mvpn_table.cc:63
MvpnProjectManager * mvpn_project_manager()
Definition: ermvpn_table.h:68
ErmVpnTable * table()
Definition: bgp_mvpn.cc:560
Definition: route.h:14
MvpnPrefix CreateType3SPMSIRoutePrefix(const MvpnRoute *type7_rt)
Definition: mvpn_table.cc:308
BgpAttrPtr ReplaceNexthopAndLocate(const BgpAttr *attr, const IpAddress &addr)
Definition: bgp_attr.cc:1413
void SetLeafADPrefixFromSPMSIPrefix(const MvpnPrefix &prefix)
Definition: mvpn_route.cc:767
static bool is_source_as(const ExtCommunityValue &val)
Definition: community.h:335
const uint32_t GetPathId() const
Definition: bgp_path.h:78
MvpnRoute * LocateType4LeafADRoute(const MvpnRoute *type3_spmsi_rt)
Definition: mvpn_table.cc:303
MvpnPrefix CreateType2ADRoutePrefix()
Definition: mvpn_table.cc:347
const std::string & name() const
virtual BgpRoute * RouteReplicate(BgpServer *server, BgpTable *src_table, BgpRoute *src_rt, const BgpPath *path, ExtCommunityPtr ptr)
Definition: mvpn_table.cc:391
void NotifyAllEntries()
Definition: db_table.cc:596
bool HasNext() const
Definition: bgp_ribout.h:268
const RouteDistinguisher & source_rd() const
Definition: bgp_attr.h:896
uint32_t GetFlags() const
Definition: bgp_path.h:100
Definition: ipeer.h:186
bool empty() const
Definition: bitset.cc:165
virtual void UpdateSecondaryTablesForReplication(MvpnRoute *rt, BgpTable::TableSet *secondary_tables) const
Definition: bgp_mvpn.cc:1178
const std::string & mvpn_project_manager_network() const
void UpdateSecondaryTablesForReplication(BgpRoute *rt, TableSet *secondary_tables)
Definition: mvpn_table.cc:238
MvpnRoute * FindType1ADRoute()
Definition: mvpn_table.cc:376
BgpAttrPtr ReplaceExtCommunityAndLocate(const BgpAttr *attr, ExtCommunityPtr extcomm)
Definition: bgp_attr.cc:1330
void CreateMvpnManagers()
Definition: mvpn_table.cc:123
bool IsUsable() const
Definition: bgp_route.cc:324
const MvpnManager * manager() const
Definition: mvpn_table.h:64
bool IsDeleted() const
Definition: bgp_table.h:143
Definition: db.h:24
MvpnRoute * FindRoute(const MvpnPrefix &prefix)
Definition: mvpn_table.cc:266
boost::intrusive_ptr< const BgpAttr > BgpAttrPtr
Definition: bgp_attr.h:991
void SetReplicateInfo(const BgpTable *table, const BgpRoute *rt)
Definition: bgp_path.h:172
void Init()
Definition: db_table.cc:387
uint8_t type() const
Definition: mvpn_route.h:72
void DestroyManager()
Definition: mvpn_table.cc:113
bool IsFeasible() const
Definition: bgp_path.h:92
boost::intrusive_ptr< MvpnState > MvpnStatePtr
Definition: bgp_mvpn.h:39
virtual size_t Hash(const DBEntry *entry) const
Definition: mvpn_table.cc:69
MvpnPrefix CreateType1ADRoutePrefix()
Definition: mvpn_table.cc:362
PathSource GetSource() const
Definition: bgp_path.h:103
RibPeerSet target
Definition: bgp_update.h:103
PathResolver * CreatePathResolver()
Definition: mvpn_table.cc:49
const MvpnRoute * FindType7SourceTreeJoinRoute(MvpnRoute *rt) const
Definition: mvpn_table.cc:381
const ExtCommunityList & communities() const
Definition: community.h:180
bool IsDeleted() const
Definition: lifetime.h:131
BgpRoute * ReplicateType7SourceTreeJoin(BgpServer *server, MvpnTable *src_table, MvpnRoute *src_rt, const BgpPath *src_path, ExtCommunityPtr ext_community)
Definition: mvpn_table.cc:431
ExtCommunityDB * extcomm_db()
Definition: bgp_server.h:187
boost::intrusive_ptr< const ExtCommunity > ExtCommunityPtr
Definition: community.h:448
bool mvpn_ipv4_enable() const
Definition: bgp_server.h:303
void CreateManager()
Definition: mvpn_table.cc:96
std::set< BgpTable * > TableSet
Definition: bgp_table.h:38
const LifetimeActor * deleter() const
Definition: bgp_mvpn.cc:110
const MvpnTable * table() const
Definition: mvpn_table.h:112
IPeer * GetPeer()
Definition: bgp_path.h:76
virtual BgpRoute * TableFind(DBTablePartition *rtp, const DBRequestKey *prefix)
Definition: mvpn_table.cc:83
static size_t HashFunction(const Ip4Prefix &addr)
Definition: inet_table.cc:28
uint32_t asn() const
Definition: mvpn_route.h:81
MvpnProjectManagerPartition * GetPartition(int part_id)
Definition: bgp_mvpn.cc:148
const std::string & name() const
Definition: db_table.h:110
static RouteDistinguisher kZeroRd
Definition: rd.h:14
uint32_t GetAsn() const
Definition: source_as.cc:25
void ClearDelete()
Definition: db_entry.h:48
uint32_t GetLabel() const
Definition: bgp_path.h:89
void GetPeerSet(RibOut *ribout, MvpnRoute *route, const RibPeerSet &peerset, RibPeerSet *new_peerset)
Definition: mvpn_table.cc:616
static const int kPartitionCount
Definition: mvpn_table.h:26
MvpnPrefix CreateType4LeafADRoutePrefix(const MvpnRoute *type3_rt)
Definition: mvpn_table.cc:295
MvpnPrefix CreateType7SourceTreeJoinRoutePrefix(MvpnRoute *rt) const
Definition: mvpn_table.cc:328
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
UpdateInfo * GetUpdateInfo(MvpnRoute *route)
Definition: bgp_mvpn.cc:1244
void InsertPath(BgpPath *path)
Definition: bgp_route.cc:60
tbb::mutex & mutex()
const BgpAttr * GetOriginalAttr() const
Definition: bgp_path.h:88
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
Definition: db_table.cc:436
BgpServer * server()
Definition: bgp_table.cc:88
const RoutingInstanceMgr * manager() const
ExtCommunityPtr RemoveSourceASAndLocate(const ExtCommunity *src)
Definition: community.cc:815
void SetSPMSIPrefixFromLeafADPrefix(const MvpnPrefix &prefix)
Definition: mvpn_route.cc:799
BitSet & set(size_t pos)
Definition: bitset.cc:125
uint32_t bgp_identifier() const
Definition: bgp_server.h:208
bool IsMasterRoutingInstance() const
BgpPath * FindSecondaryPath(BgpRoute *src_rt, BgpPath::PathSource src, const IPeer *peer, uint32_t path_id)
Definition: bgp_route.cc:372
UpdateInfo * GetMvpnUpdateInfo(RibOut *ribout, MvpnRoute *route, const RibPeerSet &peerset)
Definition: mvpn_table.cc:634
const ExtCommunity * ext_community() const
Definition: bgp_attr.h:915
const MvpnProjectManager * GetProjectManager() const
Definition: mvpn_table.cc:185
BgpAttrDB * attr_db()
Definition: bgp_server.h:181
const MvpnProjectManagerPartition * GetProjectManagerPartition(BgpRoute *route) const
Definition: mvpn_table.cc:222
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *key) const
Definition: mvpn_table.cc:57
std::vector< ExtCommunityValue > ExtCommunityList
Definition: community.h:153
bool IsMaster() const
Definition: mvpn_table.cc:664
static bool is_route_target(const ExtCommunityValue &val)
Definition: community.h:265
const BgpAttr * GetAttr() const
Definition: bgp_path.h:87
bool IsEncodingXmpp() const
Definition: bgp_ribout.h:328
MvpnTable(DB *db, const std::string &name)
Definition: mvpn_table.cc:45
void set_nexthop_longest_match(bool flag)
bool empty() const
Definition: db_table.h:101
const MvpnProjectManagerNetworks & mvpn_project_managers() const
virtual void Add(DBEntry *entry)
MvpnPrefix CreateLocalType7Prefix(MvpnRoute *rt) const
Definition: mvpn_table.cc:319
DBTablePartBase * get_table_partition() const
Definition: db_entry.cc:115
void Notify(DBEntryBase *entry)
std::size_t hash_value(BgpAttr const &attr)
Definition: bgp_attr.cc:1259
static MvpnPrefix FromString(const std::string &str, boost::system::error_code *errorp=NULL)
Definition: mvpn_route.cc:483
Ip4Address source() const
Definition: mvpn_route.h:75
bool IsZero() const
Definition: rd.h:43
const MvpnPrefix & GetPrefix() const
Definition: mvpn_route.h:139
bool deleted() const
const RouteDistinguisher & route_distinguisher() const
Definition: mvpn_route.h:73
Ip4Address originator() const
Definition: mvpn_route.h:76
MvpnRoute * LocateType3SPMSIRoute(const MvpnRoute *type7_join_rt)
Definition: mvpn_table.cc:342
virtual bool IsReplicated() const
Definition: bgp_path.h:91
static DBTableBase * CreateTable(DB *db, const std::string &name)
Definition: mvpn_table.cc:90
bool IsProjectManagerUsable() const
Definition: mvpn_table.cc:200
#define MVPN_RT_LOG(rt,...)
Definition: bgp_mvpn.h:490
Ip4Address GetType3OriginatorFromType4Route() const
Definition: mvpn_route.cc:85
#define MODULE_INITIALIZER(Func)
Definition: util.h:61
IPeerUpdate * Next()
Definition: bgp_ribout.h:271
int index() const
MvpnManager * manager_
Definition: mvpn_table.h:114
MvpnRoute * LocateType1ADRoute()
Definition: mvpn_table.cc:366
PathResolver * path_resolver()
Definition: bgp_table.h:153
static void RegisterFactory(const std::string &prefix, CreateFunction create_fn)
Definition: db.cc:24
int index() const
const PathList & GetPathList() const
Definition: route.h:46
Ip4Address group() const
Definition: mvpn_route.h:74