Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
[Feature] Adding support for port delete, also include L2/L3 neighbor…
Browse files Browse the repository at this point in the history
… delete (#166)

* consume the latest proto3 contract

* print out the new port and zeta fields

* fix comments and text

* added L2 port/neighbor delete plus updated tests

* fixing ovs_L3 test

* move the handling of host DVR mac restore to the router level

* improve the above implementation

* L3 neighbor delete

* adding L3 neighbor delete test case

* consume the latest schema

* adding neighbor delete into traffic test cases

* fixing delete test cases

* fixing test cases

* fixing tests

* fix function names and comments

* update per PR feedback

* fix issue found during testing
  • Loading branch information
er1cthe0ne authored Nov 20, 2020
1 parent cb371ea commit 8429dfb
Show file tree
Hide file tree
Showing 14 changed files with 1,393 additions and 1,058 deletions.
2 changes: 1 addition & 1 deletion alcor
Submodule alcor updated 306 files
18 changes: 12 additions & 6 deletions include/aca_ovs_l2_programmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ class ACA_OVS_L2_Programmer {

int setup_ovs_bridges_if_need();

int configure_port(const std::string vpc_id, const std::string port_name,
const std::string virtual_ip, uint tunnel_id, ulong &culminative_time);
int create_port(const std::string vpc_id, const std::string port_name,
const std::string virtual_ip, uint tunnel_id, ulong &culminative_time);

int create_update_neighbor_port(const std::string vpc_id,
alcor::schema::NetworkType network_type,
const std::string remote_host_ip,
uint tunnel_id, ulong &culminative_time);
int delete_port(const std::string vpc_id, const std::string port_name,
uint tunnel_id, ulong &culminative_time);

int create_or_update_l2_neighbor(const std::string neighbor_id, const std::string vpc_id,
alcor::schema::NetworkType network_type,
const std::string remote_host_ip,
uint tunnel_id, ulong &culminative_time);

int delete_l2_neighbor(const std::string neighbor_id, const std::string vpc_id,
const std::string outport_name, ulong &culminative_time);

void execute_ovsdb_command(const std::string cmd_string,
ulong &culminative_time, int &overall_rc);
Expand Down
22 changes: 14 additions & 8 deletions include/aca_ovs_l3_programmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace std;
using namespace alcor::schema;

// port id is stored as the key to ports table
struct port_table_entry {
struct neighbor_port_table_entry {
string virtual_ip;
string virtual_mac;
string host_ip;
Expand All @@ -46,9 +46,11 @@ struct subnet_routing_table_entry {
uint tunnel_id;
string gateway_ip;
string gateway_mac;
// list of ports within the subnet
unordered_map<string, port_table_entry> ports;
// list of neighbor ports within the subnet
// hashtable <key: neighbor ID, value: neighbor_port_table_entry>
unordered_map<string, neighbor_port_table_entry> neighbor_ports;
// list of routing rules for this subnet
// hashtable <key: routing rule ID, value: routing_rule_entry>
unordered_map<string, routing_rule_entry> routing_rules;
};

Expand All @@ -59,21 +61,24 @@ class ACA_OVS_L3_Programmer {
public:
static ACA_OVS_L3_Programmer &get_instance();

void clear_all_data();

int create_or_update_router(RouterConfiguration &current_RouterConfiguration,
GoalState &parsed_struct,
ulong &culminative_time_dataplane_programming_time);

int delete_router(RouterConfiguration &current_RouterConfiguration,
ulong &culminative_time_dataplane_programming_time);

// TODO: also need to add the corresponding update and delete operations
// at least the prototype but ideally the full implementation
int create_or_update_neighbor_l3(const string vpc_id, const string subnet_id,
alcor::schema::NetworkType network_type,
const string virtual_ip, const string virtual_mac,
int create_or_update_l3_neighbor(const string neighbor_id, const string vpc_id,
const string subnet_id, const string virtual_ip,
const string virtual_mac,
const string remote_host_ip, uint tunnel_id,
ulong &culminative_time_dataplane_programming_time);

int delete_l3_neighbor(const string neighbor_id, const string subnet_id,
const string virtual_ip, ulong &culminative_time);

// compiler will flag the error when below is called.
ACA_OVS_L3_Programmer(ACA_OVS_L3_Programmer const &) = delete;
void operator=(ACA_OVS_L3_Programmer const &) = delete;
Expand All @@ -84,6 +89,7 @@ class ACA_OVS_L3_Programmer {

string _host_dvr_mac;

// hashtable <key: router IDs, value: hashtable <key: subnet IDs, value: subnet_routing_table_entry> >
unordered_map<string, unordered_map<string, subnet_routing_table_entry> > _routers_table;

// mutex for reading and writing to routers_table
Expand Down
22 changes: 15 additions & 7 deletions include/aca_vlan_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef ACA_VLAN_MANAGER_H
#define ACA_VLAN_MANAGER_H

#include "goalstateprovisioner.grpc.pb.h"
#include <string>
#include <list>
#include <unordered_map>
Expand All @@ -34,25 +35,32 @@ struct vpc_table_entry {
uint vlan_id;
// list of ovs_ports names on this host in the same VPC to share the same internal vlan_id
list<string> ovs_ports;
// list of output (e.g. vxlan) tunnel ports to the neighbor host communication in the same VPC
list<string> outports;
// hashtable of output (e.g. vxlan) tunnel ports to the neighbor host communication
// to neighbor port ID mapping in this VPC
// unordered_map <outports, list of neighbor port IDs>
unordered_map<string, list<string> > outports_neighbors_table;
};

class ACA_Vlan_Manager {
public:
static ACA_Vlan_Manager &get_instance();

void clear_all_data();

uint get_or_create_vlan_id(string vpc_id);

void add_ovs_port(string vpc_id, string ovs_port);
int create_ovs_port(string vpc_id, string ovs_port, uint tunnel_id, ulong &culminative_time);

int remove_ovs_port(string vpc_id, string ovs_port);
int delete_ovs_port(string vpc_id, string ovs_port, uint tunnel_id, ulong &culminative_time);

void add_outport(string vpc_id, string outport);
int create_neighbor_outport(string neighbor_id, string vpc_id,
alcor::schema::NetworkType network_type, string remote_host_ip,
uint tunnel_id, ulong &culminative_time);

int remove_outport(string vpc_id, string outport);
int delete_neighbor_outport(string neighbor_id, string vpc_id,
string outport_name, ulong &culminative_time);

int get_outports(string vpc_id, string &outports);
int get_outports_unsafe(string vpc_id, string &outports);

// compiler will flag error when below is called
ACA_Vlan_Manager(ACA_Vlan_Manager const &) = delete;
Expand Down
52 changes: 37 additions & 15 deletions src/comm/aca_comm_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Aca_Comm_Manager &Aca_Comm_Manager::get_instance()
return instance;
}

int Aca_Comm_Manager::deserialize(const unsigned char *mq_buffer, size_t buffer_length, GoalState &parsed_struct)
int Aca_Comm_Manager::deserialize(const unsigned char *mq_buffer,
size_t buffer_length, GoalState &parsed_struct)
{
int rc;

Expand Down Expand Up @@ -157,36 +158,51 @@ void Aca_Comm_Manager::print_goal_state(GoalState parsed_struct)
fprintf(stdout, "current_VpcConfiguration.revision_number(): %d\n",
current_VpcConfiguration.revision_number());

fprintf(stdout, "current_VpcConfiguration.project_id(): %s\n",
current_VpcConfiguration.project_id().c_str());
fprintf(stdout, "current_VpcConfiguration.request_id(): %s\n",
current_VpcConfiguration.request_id().c_str());

fprintf(stdout, "current_VpcConfiguration.id(): %s\n",
current_VpcConfiguration.id().c_str());

fprintf(stdout, "current_VpcConfiguration.update_type(): %d\n",
current_VpcConfiguration.update_type());

fprintf(stdout, "current_VpcConfiguration.project_id(): %s\n",
current_VpcConfiguration.project_id().c_str());

fprintf(stdout, "current_VpcConfiguration.name(): %s \n",
current_VpcConfiguration.name().c_str());

fprintf(stdout, "current_VpcConfiguration.cidr(): %s \n",
current_VpcConfiguration.cidr().c_str());

fprintf(stdout, "current_VpcConfiguration.tunnel_id(): %ld \n",
fprintf(stdout, "current_VpcConfiguration.tunnel_id(): %u \n",
current_VpcConfiguration.tunnel_id());

for (int j = 0; j < current_VpcConfiguration.subnet_ids_size(); j++) {
fprintf(stdout, "current_VpcConfiguration.subnet_ids(%d): %s \n", j,
current_VpcConfiguration.subnet_ids(j).id().c_str());
}

for (int k = 0; k < current_VpcConfiguration.routes_size(); k++) {
fprintf(stdout,
"current_VpcConfiguration.routes(%d).destination(): "
"%s \n",
k, current_VpcConfiguration.routes(k).destination().c_str());
auto current_auxiliary_gateway = current_VpcConfiguration.auxiliary_gateway();

fprintf(stdout,
"current_VpcConfiguration.routes(%d).next_hop(): "
"%s \n",
k, current_VpcConfiguration.routes(k).next_hop().c_str());
fprintf(stdout, "current_auxiliary_gateway.auxgateway_type(): %d\n",
current_auxiliary_gateway.aux_gateway_type());

fprintf(stdout, "current_auxiliary_gateway.id(): %s\n",
current_auxiliary_gateway.id().c_str());

for (int k = 0; k < current_auxiliary_gateway.destinations_size(); k++) {
fprintf(stdout, "current_auxiliary_gateway.destinations(%d).ip_address(): %s \n",
k, current_auxiliary_gateway.destinations(k).ip_address().c_str());

fprintf(stdout, "current_auxiliary_gateway.destinations(%d).mac_address(): %s \n",
k, current_auxiliary_gateway.destinations(k).mac_address().c_str());
}

if (current_auxiliary_gateway.has_zeta_info()) {
fprintf(stdout, "current_auxiliary_gateway.zeta_info().port_inband_operation: %d\n",
current_auxiliary_gateway.zeta_info().port_inband_operation());
}

printf("\n");
Expand Down Expand Up @@ -281,6 +297,12 @@ void Aca_Comm_Manager::print_goal_state(GoalState parsed_struct)
fprintf(stdout, "current_PortConfiguration.name(): %s \n",
current_PortConfiguration.name().c_str());

fprintf(stdout, "current_PortConfiguration.device_id(): %s\n",
current_PortConfiguration.device_id().c_str());

fprintf(stdout, "current_PortConfiguration.device_owner(): %s \n",
current_PortConfiguration.device_owner().c_str());

fprintf(stdout, "current_PortConfiguration.mac_address(): %s \n",
current_PortConfiguration.mac_address().c_str());

Expand Down Expand Up @@ -386,8 +408,8 @@ void Aca_Comm_Manager::print_goal_state(GoalState parsed_struct)
fprintf(stdout, "current_SecurityGroupConfiguration.id(): %s\n",
current_SecurityGroupConfiguration.id().c_str());

fprintf(stdout, "current_SecurityGroupConfiguration.message_type(): %d\n",
current_SecurityGroupConfiguration.message_type());
fprintf(stdout, "current_SecurityGroupConfiguration.update_type(): %d\n",
current_SecurityGroupConfiguration.update_type());

fprintf(stdout, "current_SecurityGroupConfiguration.project_id(): %s\n",
current_SecurityGroupConfiguration.project_id().c_str());
Expand Down
Loading

0 comments on commit 8429dfb

Please sign in to comment.