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

Add vxlan-generic support #180

Merged
merged 1 commit into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
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
12 changes: 5 additions & 7 deletions include/aca_vlan_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct vpc_table_entry {
// CTSL::HashMap <key: ovs_port name, value: int* (not used)>
CTSL::HashMap<string, int *> ovs_ports;

string auxGateway_id;
string zeta_gateway_id;
};

class ACA_Vlan_Manager {
Expand All @@ -59,15 +59,13 @@ class ACA_Vlan_Manager {
int delete_l2_neighbor(string virtual_ip, string virtual_mac, uint tunnel_id,
ulong &culminative_time);

// create a neighbor port without specifying vpc_id and neighbor ID
int create_neighbor_outport(alcor::schema::NetworkType network_type, string remote_host_ip,
uint tunnel_id, ulong &culminative_time);
void set_zeta_gateway(uint tunnel_id, const string auxGateway_id);

void set_aux_gateway(uint tunnel_id, const string auxGateway_id);
int remove_zeta_gateway(uint tunnel_id);

string get_aux_gateway_id(uint tunnel_id);
string get_zeta_gateway_id(uint tunnel_id);

bool is_exist_aux_gateway(const string auxGateway_id);
bool is_exist_zeta_gateway(const string auxGateway_id);

// compiler will flag error when below is called
ACA_Vlan_Manager(ACA_Vlan_Manager const &) = delete;
Expand Down
120 changes: 120 additions & 0 deletions include/aca_zeta_oam_server.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright 2019 The Alcor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ACA_ZETA_OAM_SERVER_H
#define ACA_ZETA_OAM_SERVER_H

#include <cstdint>
#include <string>
#include <arpa/inet.h>
#include <net/ethernet.h>
#include <netinet/ether.h>

#include "goalstateprovisioner.grpc.pb.h"

using namespace std;
namespace aca_zeta_oam_server
{
//OAM Message Type
#define OAM_MSG_FLOW_INJECTION (0)
#define OAM_MSG_FLOW_DELETION (1)
#define OAM_MSG_NONE (2)
#define OAM_MSG_MAX (3)

struct oam_match {
string sip;
string dip;
string sport;
string dport;
string proto;
uint vni;
};

struct oam_action {
string inst_nw_dst;
string node_nw_dst;
string inst_dl_dst;
string node_dl_dst;
string idle_timeout;
};

struct flow_inject_msg {
struct in_addr inner_src_ip; // Inner Packet SIP
struct in_addr inner_dst_ip; // Inner Packet DIP
uint16_t src_port; // Inner Packet SPort
uint16_t dst_port; // Inner Packet DPort
uint8_t proto; // Inner Packet Protocol
uint8_t vni[3]; // tunnel_id, 3bytes
struct in_addr inst_dst_ip; // Destination Inst IP
struct in_addr node_dst_ip; // Destination Node IP
uint8_t inst_dst_mac[6]; // Destination Inst MAC
uint8_t node_dst_mac[6]; // Destination Node MAC
uint16_t idle_timeout; // 0 - 65536s
};

struct flow_del_msg {
struct in_addr inner_src_ip;
struct in_addr inner_dst_ip;
uint16_t src_port;
uint16_t dst_port;
uint8_t proto;
uint8_t vni[3];
};

struct oam_message {
uint32_t op_code;
union op_data {
struct flow_inject_msg msg_inject_flow;
struct flow_del_msg msg_del_flow;
} data;
};

class ACA_Zeta_Oam_Server {
public:
ACA_Zeta_Oam_Server();
~ACA_Zeta_Oam_Server();

static ACA_Zeta_Oam_Server &get_instance();
void oams_recv(uint32_t udp_dport, void *message);
bool lookup_oam_port_in_cache(uint port_number);
void add_oam_port_cache(uint port_number);

private:
uint8_t _get_message_type(oam_message *oammsg);
string _get_mac_addr(uint8_t *mac);
uint _get_tunnel_id(uint8_t *vni);
bool _validate_oam_message(oam_message *oammsg);
bool _check_oam_server_port(uint32_t udp_dport, oam_match match);
oam_match _get_oam_match_field(oam_message *oammsg);
oam_action _get_oam_action_field(oam_message *oammsg);

int _add_direct_path(oam_match match, oam_action action);
int _del_direct_path(oam_match match);

void _init_oam_msg_ops();
void _parse_oam_flow_injection(uint32_t udp_dport, oam_message *oammsg);
void _parse_oam_flow_deletion(uint32_t udp_dport, oam_message *oammsg);
void _parse_oam_none(uint32_t /* in_port */, oam_message *oammsg);

void (aca_zeta_oam_server::ACA_Zeta_Oam_Server ::*_parse_oam_msg_ops[OAM_MSG_MAX])(
uint32_t udp_dpost, oam_message *oammsg);

// unordered_set<oam_port_number>
unordered_set<uint> _oam_ports_cache;

// mutex for reading and writing to _oam_ports_cache
mutex _oam_ports_cache_mutex;
};
} // namespace aca_zeta_oam_server
#endif // #ifndef ACA_Zeta_OAM_SERVER_H
49 changes: 24 additions & 25 deletions include/aca_zeta_programming.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,55 @@
#include <list>
#include <atomic>
#include "goalstateprovisioner.grpc.pb.h"
#include "hashmap/HashMap.h"

using namespace std;

static atomic_uint current_available_group_id(1);

namespace aca_zeta_programming
{
struct zeta_config {
string group_id;
//
list<string> zeta_buckets;
uint32_t port_inband_operation;
};

struct aux_gateway_entry {
uint oam_port;
uint group_id;
uint oam_port;
// set<gateway_node_ip_address>
unordered_set<string> zeta_buckets;
};

class ACA_Zeta_Programming {
public:
ACA_Zeta_Programming();
~ACA_Zeta_Programming();
static ACA_Zeta_Programming &get_instance();

uint get_or_create_group_id(string auxGateway_id);
void create_entry(string zeta_gateway_id, uint oam_port);

int create_or_update_zeta_config(const alcor::schema::AuxGateway current_AuxGateway,
const string vpc_id, uint32_t tunnel_id);
void clear_all_data();

int delete_zeta_config(const alcor::schema::AuxGateway current_AuxGateway,
const string vpc_id, uint32_t tunnel_id);
int create_zeta_config(const alcor::schema::AuxGateway current_AuxGateway, uint tunnel_id);

bool is_exist_group_rule(uint group_id);
int delete_zeta_config(const alcor::schema::AuxGateway current_AuxGateway, uint tunnel_id);

uint get_oam_server_port(string auxGateway_id);
bool oam_port_rule_exists(uint port_number);

void set_oam_server_port(string auxGateway_id, uint port_number);
bool group_rule_exists(uint group_id);

bool is_exist_oam_port(uint port_number);
uint get_oam_port(string zeta_gateway_id);

private:
int _create_or_update_zeta_group_entry(zeta_config *zeta_config_in);

int _delete_zeta_group_entry(zeta_config *zeta_config_in);
uint get_group_id(string zeta_gateway_id);

private:
// unordered_map<aux_gateway_id, aux_gateway_entry>
unordered_map<string, aux_gateway_entry> _zeta_gateways_table;
int _create_oam_ofp(uint port_number);
int _delete_oam_ofp(uint port_number);

mutex _zeta_gateways_table_mutex;
int _create_group_punt_rule(uint tunnel_id, uint group_id);
int _delete_group_punt_rule(uint tunnel_id);

int _create_zeta_group_entry(zeta_config *zeta_config_in);
int _delete_zeta_group_entry(zeta_config *zeta_config_in);

void create_entry_unsafe(string auxGateway_id);
// hashtable <key: zeta_gateway_id, value: zeta_config>
CTSL::HashMap<string, zeta_config *> _zeta_config_table;
};
} // namespace aca_zeta_programming
#endif // #ifndef ACA_ZETA_PROGRAMMING_H
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ set(SOURCES
./ovs/aca_ovs_control.cpp
./dhcp/aca_dhcp_state_handler.cpp
./dhcp/aca_dhcp_server.cpp
./zeta/aca_oam_server.cpp
./zeta/aca_zeta_oam_server.cpp
./zeta/aca_zeta_programming.cpp
./zeta/aca_oam_port_manager.cpp
)
FIND_LIBRARY(RDKAFKA rdkafka /usr/lib/x86_64-linux-gnu NO_DEFAULT_PATH)
FIND_LIBRARY(CPPKAFKA cppkafka /usr/local/lib NO_DEFAULT_PATH)
Expand Down
6 changes: 3 additions & 3 deletions src/dp_abstraction/aca_dataplane_ovs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ int ACA_Dataplane_OVS::update_port_state_workitem(const PortState current_PortSt
if (found_auxgateway.aux_gateway_type() == ZETA) {
ACA_LOG_INFO("%s", "AuxGateway_type is zeta!\n");
// Update the zeta settings of vpc
overall_rc = ACA_Zeta_Programming::get_instance().create_or_update_zeta_config(
found_auxgateway, current_PortConfiguration.vpc_id(), found_tunnel_id);
overall_rc = ACA_Zeta_Programming::get_instance().create_zeta_config(
found_auxgateway, found_tunnel_id);
}

break;
Expand Down Expand Up @@ -277,7 +277,7 @@ int ACA_Dataplane_OVS::update_port_state_workitem(const PortState current_PortSt
ACA_LOG_INFO("%s", "AuxGateway_type is zeta!\n");
// Delete the zeta settings of vpc
overall_rc = ACA_Zeta_Programming::get_instance().delete_zeta_config(
found_auxgateway, current_PortConfiguration.vpc_id(), found_tunnel_id);
found_auxgateway, found_tunnel_id);
}

break;
Expand Down
8 changes: 3 additions & 5 deletions src/ovs/aca_ovs_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
#include <netinet/ip.h>
#include <arpa/inet.h>
#include "aca_dhcp_server.h"
#include "aca_oam_server.h"
#include "aca_oam_port_manager.h"
#include "aca_zeta_oam_server.h"

using namespace std;
using namespace ovs_control;
Expand Down Expand Up @@ -267,10 +266,9 @@ void ACA_OVS_Control::parse_packet(uint32_t in_port, void *packet)
}

/* oam message procedure */
if (aca_oam_port_manager::Aca_Oam_Port_Manager::get_instance().is_oam_server_port(
(uint32_t)udp_dport)) {
if (aca_zeta_oam_server::ACA_Zeta_Oam_Server::get_instance().lookup_oam_port_in_cache((uint)udp_dport)) {
ACA_LOG_INFO("%s", " Message Type: OAM\n");
aca_oam_server::ACA_Oam_Server::get_instance().oams_recv(
aca_zeta_oam_server::ACA_Zeta_Oam_Server::get_instance().oams_recv(
(uint32_t)udp_dport, const_cast<unsigned char *>(payload));
}
}
Expand Down
Loading