Skip to content

Commit

Permalink
TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Aitov committed Feb 9, 2024
1 parent e588f03 commit 04e6451
Show file tree
Hide file tree
Showing 18 changed files with 486 additions and 370 deletions.
14 changes: 9 additions & 5 deletions common/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,15 @@ using ranges_uint16_t = ranges_t<uint16_t>;
namespace idp
{

using acl_transport_table = std::vector<std::tuple<acl::transport_key_t, tAclGroupId>>;
using acl_total_table = std::vector<std::tuple<acl::total_key_t, tAclGroupId>>;

using request = std::tuple<acl_transport_table,
acl_total_table>;
using network_ipv4_source = std::vector<acl::tree_chunk_8bit_t>;
using network_ipv4_destination = std::vector<acl::tree_chunk_8bit_t>;
using transport_table = std::vector<std::tuple<acl::transport_key_t, tAclGroupId>>;
using total_table = std::vector<std::tuple<acl::total_key_t, tAclGroupId>>;

using request = std::tuple<network_ipv4_source,
network_ipv4_destination,
transport_table,
total_table>;

using response = eResult;

Expand Down
14 changes: 1 addition & 13 deletions common/idp.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ enum class requestType : uint32_t
route_tunnel_weight_update,
route_tunnel_value_update,
early_decap_flags,
acl_network_ipv4_source,
acl_network_ipv4_destination,
acl_network_ipv6_source,
acl_network_ipv6_destination_ht,
acl_network_ipv6_destination,
Expand Down Expand Up @@ -306,16 +304,6 @@ namespace update_early_decap_flags
using request = bool;
}

namespace acl_network_ipv4_source
{
using request = std::vector<acl::tree_chunk_8bit_t>;
}

namespace acl_network_ipv4_destination
{
using request = std::vector<acl::tree_chunk_8bit_t>;
}

namespace acl_network_ipv6_source
{
using request = std::vector<acl::tree_chunk_8bit_t>;
Expand Down Expand Up @@ -508,7 +496,7 @@ using requestVariant = std::variant<std::tuple<>,
update_balancer::request,
update_balancer_services::request,
route_tunnel_weight_update::request,
acl_network_ipv4_source::request, /// + acl_network_ipv4_destination, acl_network_ipv6_source, acl_network_ipv6_destination
acl_network_ipv6_source::request, /// + acl_network_ipv4_destination, acl_network_ipv6_source, acl_network_ipv6_destination
acl_network_ipv6_destination_ht::request,
acl_network_table::request, /// + aclTransportDestination
acl_network_flags::request,
Expand Down
8 changes: 4 additions & 4 deletions controlplane/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ typedef std::vector<uint32_t> ids_t;

struct result_t
{
common::idp::updateGlobalBase::acl_network_ipv4_source::request acl_network_ipv4_source;
common::idp::updateGlobalBase::acl_network_ipv4_destination::request acl_network_ipv4_destination;
common::acl::idp::network_ipv4_source acl_network_ipv4_source;
common::acl::idp::network_ipv4_destination acl_network_ipv4_destination;
common::idp::updateGlobalBase::acl_network_ipv6_source::request acl_network_ipv6_source;
common::idp::updateGlobalBase::acl_network_ipv6_destination_ht::request acl_network_ipv6_destination_ht;
common::idp::updateGlobalBase::acl_network_ipv6_destination::request acl_network_ipv6_destination;
common::idp::updateGlobalBase::acl_network_table::request acl_network_table;
common::idp::updateGlobalBase::acl_network_flags::request acl_network_flags;
common::idp::updateGlobalBase::acl_transport_layers::request acl_transport_layers;
std::vector<common::acl::idp::acl_transport_table> acl_transport_tables;
common::acl::idp::acl_total_table acl_total_table;
std::vector<common::acl::idp::transport_table> acl_transport_tables;
common::acl::idp::total_table acl_total_table;
common::idp::updateGlobalBase::acl_values::request acl_values;

std::vector<ids_t> ids_map;
Expand Down
2 changes: 1 addition & 1 deletion controlplane/acl_transport_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class thread_t
std::map<tAclGroupId, std::set<unsigned int>> group_id_filter_ids;
std::vector<std::vector<tAclGroupId>> transport_table_filter_id_group_ids;

common::acl::idp::acl_transport_table acl_transport_table;
common::acl::idp::transport_table acl_transport_table;

std::optional<std::exception_ptr> exception;
};
Expand Down
6 changes: 3 additions & 3 deletions controlplane/configconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1885,16 +1885,16 @@ void config_converter_t::buildAcl()
throw std::runtime_error("support multithread here");
}

globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_network_ipv4_source, std::move(result.acl_network_ipv4_source));
globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_network_ipv4_destination, std::move(result.acl_network_ipv4_destination));
globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_network_ipv6_source, std::move(result.acl_network_ipv6_source));
globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_network_ipv6_destination_ht, std::move(result.acl_network_ipv6_destination_ht));
globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_network_ipv6_destination, std::move(result.acl_network_ipv6_destination));
globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_network_table, std::move(result.acl_network_table));
globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_network_flags, std::move(result.acl_network_flags));
globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_transport_layers, std::move(result.acl_transport_layers));

acl_request = {std::move(result.acl_transport_tables[0]),
acl_request = {std::move(result.acl_network_ipv4_source),
std::move(result.acl_network_ipv4_destination),
std::move(result.acl_transport_tables[0]),
std::move(result.acl_total_table)};

globalbase.emplace_back(common::idp::updateGlobalBase::requestType::acl_values, std::move(result.acl_values));
Expand Down
67 changes: 52 additions & 15 deletions dataplane/acl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

using namespace dataplane::acl;

base::base(memory_manager* memory_manager,
const tSocketId socket_id) :
network_ipv4_source("acl.network.v4.source.lpm", memory_manager, socket_id),
network_ipv4_destination("acl.network.v4.destination.lpm", memory_manager, socket_id),
transport_table("acl.transport.ht", memory_manager, socket_id),
total_table("acl.total.ht", memory_manager, socket_id)
{
}

module::module() :
dataplane(nullptr)
{
Expand All @@ -18,10 +27,7 @@ eResult module::init(cDataPlane* dataplane)
generations.fill([&](acl::generation& generation) {
for (const auto socket_id : dataplane->get_socket_ids())
{
auto& base = generation.bases[socket_id];

base.transport_table_updater.init("acl.transport.ht", &dataplane->memory_manager, socket_id);
base.total_table_updater.init("acl.total.ht", &dataplane->memory_manager, socket_id);
generation.bases.try_emplace(socket_id, &dataplane->memory_manager, socket_id);
}
});

Expand All @@ -40,15 +46,27 @@ void module::update_worker_base(const std::vector<std::tuple<tSocketId, dataplan
{
const auto& base = generation.bases.find(socket_id)->second;

worker_base->acl_transport_table = base.transport_table_updater.get_pointer();
worker_base->acl_total_table = base.total_table_updater.get_pointer();
worker_base->acl_network_ipv4_source = base.network_ipv4_source.pointer;
worker_base->acl_network_ipv4_destination = base.network_ipv4_destination.pointer;
worker_base->acl_transport_table = base.transport_table.pointer;
worker_base->acl_total_table = base.total_table.pointer;
}
}

void module::report(nlohmann::json& json)
{
/// XXX
(void)json;
auto lock = generations.current_lock_guard();

const auto& generation = generations.current();
for (const auto socket_id : dataplane->get_socket_ids())
{
const auto& base = generation.bases.find(socket_id)->second;

base.network_ipv4_source.report(json["acl"]["network"]["ipv4"]["source"]);
base.network_ipv4_destination.report(json["acl"]["network"]["ipv4"]["destination"]);
base.transport_table.report(json["acl"]["transport_table"]);
base.total_table.report(json["acl"]["total_table"]);
}
}

void module::limits(common::idp::limits::response& response)
Expand All @@ -60,8 +78,10 @@ void module::limits(common::idp::limits::response& response)
{
const auto& base = generation.bases.find(socket_id)->second;

base.transport_table_updater.limits(response);
base.total_table_updater.limits(response);
base.network_ipv4_source.limits(response);
base.network_ipv4_destination.limits(response);
base.transport_table.limits(response);
base.total_table.limits(response);
}
}

Expand Down Expand Up @@ -122,8 +142,10 @@ void module::update_after(const common::idp::update::request& request)
{
auto& base = generation.bases.find(socket_id)->second;

base.transport_table_updater.free();
base.total_table_updater.free();
base.network_ipv4_source.free();
base.network_ipv4_destination.free();
base.transport_table.clear();
base.total_table.clear();
}

generations.next_unlock();
Expand All @@ -132,20 +154,35 @@ void module::update_after(const common::idp::update::request& request)
eResult module::acl_update(const common::acl::idp::request& request_acl)
{
eResult result = eResult::success;
const auto& [request_transport_table, request_total_table] = request_acl;
const auto& [request_network_ipv4_source,
request_network_ipv4_destination,
request_transport_table,
request_total_table] = request_acl;

auto& generation = generations.next();
for (const auto socket_id : dataplane->get_socket_ids())
{
auto& base = generation.bases.find(socket_id)->second;

result = base.transport_table_updater.update(request_transport_table);
result = base.network_ipv4_source.update(request_network_ipv4_source);
if (result != eResult::success)
{
return result;
}

result = base.network_ipv4_destination.update(request_network_ipv4_destination);
if (result != eResult::success)
{
return result;
}

result = base.transport_table.update(request_transport_table);
if (result != eResult::success)
{
return result;
}

result = base.total_table_updater.update(request_total_table);
result = base.total_table.update(request_total_table);
if (result != eResult::success)
{
return result;
Expand Down
12 changes: 10 additions & 2 deletions dataplane/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@
#include "common/generation.h"
#include "common/idp.h"

#include "lpm.h"
#include "type.h"
#include "updater.h"

namespace dataplane::acl
{

using network_ipv4_source = dataplane::updater_lpm4_24bit_8bit_id32;
using network_ipv4_destination = dataplane::updater_lpm4_24bit_8bit_id32;
using transport_table = dataplane::updater_hashtable_mod_id32<common::acl::transport_key_t, 16>;
using total_table = dataplane::updater_hashtable_mod_id32<common::acl::total_key_t, 16>;

class base
{
public:
acl::transport_table transport_table_updater;
acl::total_table total_table_updater;
base(dataplane::memory_manager* memory_manager, const tSocketId socket_id);

public:
acl::network_ipv4_source network_ipv4_source;
acl::network_ipv4_destination network_ipv4_destination;
acl::transport_table transport_table;
acl::total_table total_table;
};

class generation
Expand Down
8 changes: 5 additions & 3 deletions dataplane/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ class generation
}

dataplane::globalBase::generation* globalBase;
dataplane::neighbor::hashtable const* neighbor_hashtable;
dataplane::acl::transport_table::hashtable_t const* acl_transport_table;
dataplane::acl::total_table::hashtable_t const* acl_total_table;
const dataplane::neighbor::hashtable* neighbor_hashtable;
const dataplane::acl::network_ipv4_source::object_type* acl_network_ipv4_source;
const dataplane::acl::network_ipv4_destination::object_type* acl_network_ipv4_destination;
const dataplane::acl::transport_table::object_type* acl_transport_table;
const dataplane::acl::total_table::object_type* acl_total_table;
} __rte_aligned(2 * RTE_CACHE_LINE_SIZE);

}
4 changes: 2 additions & 2 deletions dataplane/controlplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,6 @@ common::idp::limits::response cControlPlane::limits()
YANET_CONFIG_ROUTE_TUNNEL_LPM6_EXTENDED_SIZE);

globalBase->updater.acl.network_table.limits(response, "acl.network.ht");
globalBase->updater.acl.network_ipv4_source.limits(response, "acl.network.v4.source.lpm");
globalBase->updater.acl.network_ipv4_destination.limits(response, "acl.network.v4.destination.lpm");
globalBase->updater.acl.network_ipv6_source.limits(response, "acl.network.v6.source.lpm");

/// globalBase->acl.network_ipv6_destination_ht is not critical
Expand All @@ -961,6 +959,8 @@ common::idp::limits::response cControlPlane::limits()
}

dregress.limits(response);
///XXX dataPlane->memory_manager.limits(response);
///XXX dataPlane->neighbor.limits(response);
dataPlane->acl_module.limits(response);

return response;
Expand Down
21 changes: 0 additions & 21 deletions dataplane/dataplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,30 +684,12 @@ eResult cDataPlane::initGlobalBases()
}

{
auto* acl_network_ipv4_source = hugepage_create_dynamic<dataplane::globalBase::acl::network_ipv4_source>(socket_id, getConfigValue(eConfigType::acl_network_lpm4_chunks_size), globalbase->updater.acl.network_ipv4_source);
if (!acl_network_ipv4_source)
{
return nullptr;
}

auto* acl_network_ipv4_destination = hugepage_create_dynamic<dataplane::globalBase::acl::network_ipv4_destination>(socket_id, getConfigValue(eConfigType::acl_network_lpm4_chunks_size), globalbase->updater.acl.network_ipv4_destination);
if (!acl_network_ipv4_destination)
{
return nullptr;
}

auto* acl_network_ipv6_source = hugepage_create_dynamic<dataplane::globalBase::acl::network_ipv6_source>(socket_id, getConfigValue(eConfigType::acl_network_source_lpm6_chunks_size), globalbase->updater.acl.network_ipv6_source);
if (!acl_network_ipv6_source)
{
return nullptr;
}

auto* acl_network_ipv6_destination_ht = hugepage_create_dynamic<dataplane::globalBase::acl::network_ipv6_destination_ht>(socket_id, getConfigValue(eConfigType::acl_network_destination_ht_size), globalbase->updater.acl.network_ipv6_destination_ht);
if (!acl_network_ipv6_destination_ht)
{
return nullptr;
}

auto* acl_network_ipv6_destination = hugepage_create_dynamic<dataplane::globalBase::acl::network_ipv6_destination>(socket_id, getConfigValue(eConfigType::acl_network_destination_lpm6_chunks_size), globalbase->updater.acl.network_ipv6_destination);
if (!acl_network_ipv6_destination)
{
Expand Down Expand Up @@ -753,10 +735,7 @@ eResult cDataPlane::initGlobalBases()
return nullptr;
}

globalbase->acl.network.ipv4.source = acl_network_ipv4_source;
globalbase->acl.network.ipv4.destination = acl_network_ipv4_destination;
globalbase->acl.network.ipv6.source = acl_network_ipv6_source;
globalbase->acl.network.ipv6.destination_ht = acl_network_ipv6_destination_ht;
globalbase->acl.network.ipv6.destination = acl_network_ipv6_destination;
globalbase->acl.network_table = acl_network_table;
globalbase->acl.transport_layers_mask = acl_transport_layers_size - 1;
Expand Down
Loading

0 comments on commit 04e6451

Please sign in to comment.