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