Skip to content

Commit

Permalink
Merge "Allow unidirectional connections between routing instances"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Dec 3, 2015
2 parents b05eb5f + 109b987 commit 3b34a90
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 74 deletions.
37 changes: 35 additions & 2 deletions src/bgp/bgp_config_ifmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,39 @@ static void GetRoutingInstanceExportTargets(DBGraph *graph, IFMapNode *node,
}
}

//
// Fill in all the export route targets of the routing-instance at the other
// end of a connection. The src_node is the routing-instance from which we
// reached the connection node. The name of the source routing-instance is
// src_instance.
//
// If the connection is unidirectional and the destination-instance for the
// connection is not the routing-instance from which we started, we should
// not get any targets from this connection. This is what a unidirectional
// connection means.
//
static void GetConnectionExportTargets(DBGraph *graph, IFMapNode *src_node,
const string &src_instance, IFMapNode *node,
vector<string> *target_list) {
const autogen::Connection *conn =
dynamic_cast<autogen::Connection *>(node->GetObject());
if (!conn)
return;
const autogen::ConnectionType &conn_type = conn->data();
if (!conn_type.destination_instance.empty() &&
conn_type.destination_instance != src_instance)
return;
for (DBGraphVertex::adjacency_iterator iter = node->begin(graph);
iter != node->end(graph); ++iter) {
IFMapNode *adj = static_cast<IFMapNode *>(iter.operator->());
if (adj == src_node)
continue;
if (strcmp(adj->table()->Typename(), "routing-instance") != 0)
continue;
GetRoutingInstanceExportTargets(graph, adj, target_list);
}
}

//
// Fill in all the routing-policies for a routing-instance. The input
// IFMapNode represents the routing-instance-routing-policy. We traverse to
Expand Down Expand Up @@ -939,9 +972,9 @@ void BgpIfmapInstanceConfig::Update(BgpIfmapConfigManager *manager,
RoutingPolicyAttachInfo policy_info;
GetRoutingInstanceRoutingPolicy(graph, adj, &policy_info);
policy_list.push_back(policy_info);
} else if (strcmp(adj->table()->Typename(), "routing-instance") == 0) {
} else if (strcmp(adj->table()->Typename(), "connection") == 0) {
vector<string> target_list;
GetRoutingInstanceExportTargets(graph, adj, &target_list);
GetConnectionExportTargets(graph, node, name_, adj, &target_list);
BOOST_FOREACH(string target, target_list) {
import_list.insert(target);
}
Expand Down
5 changes: 5 additions & 0 deletions src/bgp/bgp_config_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ void BgpConfigListener::DependencyTrackerInit() {
("self", list_of("bgp-peering"));
policy->insert(make_pair("bgp-router", bgp_router_react));

ReactionMap connection_react = map_list_of<string, PropagateList>
("self", list_of("connection"))
("connection", list_of("connection"));
policy->insert(make_pair("connection", connection_react));

ReactionMap rt_instance_react = map_list_of<string, PropagateList>
("instance-target", list_of("self")("connection"))
("connection", list_of("self"))
Expand Down

0 comments on commit 3b34a90

Please sign in to comment.