X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/29dbba02d775b87908c34d8233290331b67d02b3..681600546425819d6810e4e595d35e843130d878:/src/kernel/routing/AsImpl.cpp
diff --git a/src/kernel/routing/AsImpl.cpp b/src/kernel/routing/AsImpl.cpp
index 86c782b7b6..d30d7866fd 100644
--- a/src/kernel/routing/AsImpl.cpp
+++ b/src/kernel/routing/AsImpl.cpp
@@ -17,6 +17,14 @@ namespace simgrid {
namespace kernel {
namespace routing {
+ class BypassRoute {
+ public:
+ explicit BypassRoute(NetCard* gwSrc, NetCard* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
+ const NetCard* gw_src;
+ const NetCard* gw_dst;
+ std::vector links;
+ };
+
AsImpl::AsImpl(As* father, const char* name) : As(father, name)
{
xbt_assert(nullptr == xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL),
@@ -26,6 +34,11 @@ namespace simgrid {
xbt_lib_set(as_router_lib, name, ROUTING_ASR_LEVEL, static_cast(netcard_));
XBT_DEBUG("AS '%s' created with the id '%d'", name, netcard_->id());
}
+ AsImpl::~AsImpl()
+ {
+ for (auto& kv : bypassRoutes_)
+ delete kv.second;
+ }
simgrid::s4u::Host* AsImpl::createHost(const char* name, std::vector* speedPerPstate, int coreAmount)
{
@@ -41,15 +54,32 @@ namespace simgrid {
return res;
}
- void AsImpl::getOneLinkRoutes(std::vector* accumulator)
+ void AsImpl::addBypassRoute(sg_platf_route_cbarg_t e_route)
{
- // recursing only. I have no route myself :)
- char* key;
- xbt_dict_cursor_t cursor = nullptr;
- AsImpl* rc_child;
- xbt_dict_foreach (children(), cursor, key, rc_child) {
- rc_child->getOneLinkRoutes(accumulator);
+ /* Argument validity checks */
+ if (e_route->gw_dst) {
+ XBT_DEBUG("Load bypassASroute from %s@%s to %s@%s", e_route->src->cname(), e_route->gw_src->cname(),
+ e_route->dst->cname(), e_route->gw_dst->cname());
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s@%s and %s@%s cannot be empty.",
+ e_route->src->cname(), e_route->gw_src->cname(), e_route->dst->cname(), e_route->gw_dst->cname());
+ xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
+ "The bypass route between %s@%s and %s@%s already exists.", e_route->src->cname(),
+ e_route->gw_src->cname(), e_route->dst->cname(), e_route->gw_dst->cname());
+ } else {
+ XBT_DEBUG("Load bypassRoute from %s to %s", e_route->src->cname(), e_route->dst->cname());
+ xbt_assert(!e_route->link_list->empty(), "Bypass route between %s and %s cannot be empty.", e_route->src->cname(),
+ e_route->dst->cname());
+ xbt_assert(bypassRoutes_.find({e_route->src, e_route->dst}) == bypassRoutes_.end(),
+ "The bypass route between %s and %s already exists.", e_route->src->cname(), e_route->dst->cname());
}
+
+ /* Build a copy that will be stored in the dict */
+ kernel::routing::BypassRoute* newRoute = new kernel::routing::BypassRoute(e_route->gw_src, e_route->gw_dst);
+ for (auto link : *e_route->link_list)
+ newRoute->links.push_back(link);
+
+ /* Store it */
+ bypassRoutes_.insert({{e_route->src, e_route->dst}, newRoute});
}
/** @brief Get the common ancestor and its first children in each line leading to src and dst
@@ -171,7 +201,7 @@ namespace simgrid {
/* Base case, no recursion is needed */
if (dst->containingAS() == this && src->containingAS() == this) {
if (bypassRoutes_.find({src, dst}) != bypassRoutes_.end()) {
- AsRoute* bypassedRoute = bypassRoutes_.at({src, dst});
+ BypassRoute* bypassedRoute = bypassRoutes_.at({src, dst});
for (surf::Link* link : bypassedRoute->links) {
links->push_back(link);
if (latency)
@@ -215,7 +245,7 @@ namespace simgrid {
int max_index = std::max(max_index_src, max_index_dst);
/* (3) Search for a bypass making the path up to the ancestor useless */
- AsRoute* bypassedRoute = nullptr;
+ BypassRoute* bypassedRoute = nullptr;
std::pair key;
for (int max = 0; max <= max_index; max++) {
for (int i = 0; i < max; i++) {