Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions src/ovs/aca_ovs_l3_programmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,94 @@ int ACA_OVS_L3_Programmer::create_or_update_router(RouterConfiguration &current_
new_routing_rule_entry.next_hop_mac =
current_routing_rule.routing_rule_extra_info().next_hop_mac();

auto remote_host_ip = "";
ulong culminative_dataplane_programming_time = 0;
for (auto each_neighbor : parsed_struct.neighbor_states()) {
NeighborConfiguration current_NeighborConfiguration1 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 'Configuration1' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 'Configuration1' ?

Just following the variable names in the V1 version.

each_neighbor.second.configuration();
ACA_LOG_INFO("current_NeighborConfiguration.host_ip_address(): %s \n",
current_NeighborConfiguration1.host_ip_address().c_str());
for (int y = 0; y < current_NeighborConfiguration1.fixed_ips_size(); y++) {
ACA_LOG_INFO("current_NeighborConfiguration.fixed_ips(%d): neighbor_type: %d, subnet_id %s, ip_address %s \n",
y, current_NeighborConfiguration1.fixed_ips(y).neighbor_type(),
current_NeighborConfiguration1.fixed_ips(y)
.subnet_id()
.c_str(),
current_NeighborConfiguration1.fixed_ips(y)
.ip_address()
.c_str());
ACA_LOG_INFO("current_routing_rule.next_hop_ip() %s\n",
current_routing_rule.next_hop_ip().c_str());
auto current_fixed_ip = current_NeighborConfiguration1.fixed_ips(y);
string virtual_ip_address = current_fixed_ip.ip_address();
string virtual_mac_address =
current_NeighborConfiguration1.mac_address();
string subnet_id_of_fixed_ip = current_fixed_ip.subnet_id();
string gw_mac;
uint dest_tunnel_id = 0;

if (strcmp(current_routing_rule.next_hop_ip().c_str(),
current_fixed_ip.ip_address().c_str()) == 0) {
auto subnet_iterator = parsed_struct.subnet_states().find(subnet_id_of_fixed_ip);
if (subnet_iterator != parsed_struct.subnet_states().end()) {
gw_mac = subnet_iterator->second.configuration().gateway().mac_address();
dest_tunnel_id = subnet_iterator->second.configuration().tunnel_id();
ACA_LOG_INFO("gw_mac: %s\n", gw_mac.c_str());
ACA_LOG_INFO("dest_tunnel_id: %d\n", dest_tunnel_id);
} else {
ACA_LOG_INFO("Founding find subnet ID: [%s] in the goalstate", subnet_id_of_fixed_ip);
}

remote_host_ip =
current_NeighborConfiguration1.host_ip_address().c_str();
int source_vlan_id =
ACA_Vlan_Manager::get_instance().get_or_create_vlan_id(found_tunnel_id);

int destination_vlan_id =
ACA_Vlan_Manager::get_instance().get_or_create_vlan_id(dest_tunnel_id);

bool is_port_on_same_host =
ACA_OVS_L2_Programmer::get_instance().is_ip_on_the_same_host(remote_host_ip);

ACA_LOG_INFO("current_fixed_ip.subnet_id(): %s\n",
current_fixed_ip.subnet_id().c_str());
ACA_LOG_INFO("current_subnet_routing_table.subnet_id(): %s\n",
current_subnet_routing_table.subnet_id().c_str());

if (is_port_on_same_host) {
if (current_fixed_ip.subnet_id() !=
current_subnet_routing_table.subnet_id()) {
cmd_string =
"table=0,priority=50,ip,dl_vlan=" +
to_string(source_vlan_id) +
",nw_dst=" + current_routing_rule.destination() +
",dl_dst=" + found_gateway_mac +
" actions=mod_vlan_vid:" + to_string(destination_vlan_id) +
",mod_dl_src:" + gw_mac +
",mod_dl_dst:" + virtual_mac_address + ",output:IN_PORT";
}
} else {
cmd_string =
"table=0,priority=50,ip,dl_vlan=" +
to_string(source_vlan_id) +
",nw_dst=" + current_routing_rule.destination() +
",dl_dst=" + found_gateway_mac +
" actions=mod_vlan_vid:" + to_string(destination_vlan_id) +
",mod_dl_src:" + _host_dvr_mac +
",mod_dl_dst:" + virtual_mac_address + ",resubmit(,2)";
}

ACA_OVS_L2_Programmer::get_instance().execute_openflow(culminative_dataplane_programming_time,
"br-tun",
cmd_string,
"add");
}
}
if (strcmp(remote_host_ip, "") != 0) {
break;
}
}

if (!is_routing_rule_exist) {
new_subnet_routing_table_entry.routing_rules.emplace(
current_routing_rule.id(), new_routing_rule_entry);
Expand Down