From 6a6af73d3ce6d91c35713568e1ef6f19f568aee8 Mon Sep 17 00:00:00 2001 From: Aleksandr Stepanov Date: Sun, 15 Sep 2024 22:52:02 +0300 Subject: [PATCH] The interface for receiving basic counters via bus has been removed --- common/idataplane.h | 20 ------- common/idp.h | 35 ------------- dataplane/bus.cpp | 16 ------ dataplane/controlplane.cpp | 105 ------------------------------------- dataplane/controlplane.h | 4 -- dataplane/dataplane.cpp | 22 -------- dataplane/dataplane.h | 5 -- dataplane/worker.cpp | 67 ----------------------- dataplane/worker.h | 1 - dataplane/worker_gc.cpp | 15 ------ dataplane/worker_gc.h | 1 - 11 files changed, 291 deletions(-) diff --git a/common/idataplane.h b/common/idataplane.h index 5e1c40b9..53e3919d 100644 --- a/common/idataplane.h +++ b/common/idataplane.h @@ -103,26 +103,11 @@ class dataPlane return get(); } - common::idp::getAclCounters::response getAclCounters() const - { - return get(); - } - common::idp::getPortStatsEx::response getPortStatsEx() const { return get(); } - common::idp::getCounters::response getCounters(const common::idp::getCounters::request& request) const - { - return get(request); - } - - common::idp::getOtherStats::response getOtherStats() const - { - return get(); - } - common::idp::getConfig::response getConfig() const { return get(); @@ -193,11 +178,6 @@ class dataPlane return get(); } - auto get_counter_by_name(const common::idp::get_counter_by_name::request& request) const - { - return get(request); - } - auto get_shm_info() const { return get(); diff --git a/common/idp.h b/common/idp.h index 5fff9294..19eca0d8 100644 --- a/common/idp.h +++ b/common/idp.h @@ -48,13 +48,10 @@ enum class requestType : uint32_t get_ports_stats_extended, getControlPlanePortStats, getPortStatsEx, - getCounters, getFragmentationStats, getFWState, getFWStateStats, clearFWState, - getAclCounters, - getOtherStats, getConfig, getErrors, getReport, @@ -70,7 +67,6 @@ enum class requestType : uint32_t unrdup_vip_to_balancers, update_vip_vport_proto, version, - get_counter_by_name, get_shm_info, get_shm_tsc_info, set_shm_tsc_state, @@ -663,13 +659,6 @@ namespace getPortStatsEx using response = ::common::getPortStatsEx::response; } -namespace getCounters -{ -using request = std::vector; - -using response = std::vector; -} - namespace getFragmentationStats { using response = fragmentation::stats_t; @@ -703,18 +692,6 @@ namespace getFWStateStats using response = fwstate::stats_t; } -namespace getAclCounters -{ -using response = std::vector; -} - -namespace getOtherStats -{ -using worker = std::tuple>; ///< bursts - -using response = std::tuple>; -} - namespace getConfig { enum class value_type ///< @todo: delete @@ -863,13 +840,6 @@ using response = std::tuple; ///< custom } -namespace get_counter_by_name -{ -using request = std::tuple>; - -using response = std::map; -} - namespace get_shm_info { using dump_meta = std::tuple, get_ports_stats::response, ///< + getControlPlanePortStats::response get_ports_stats_extended::response, getPortStatsEx::response, - getOtherStats::response, getFragmentationStats::response, getFWState::response, getFWStateStats::response, - getAclCounters::response, ///< + getCounters::response getConfig::response, getErrors::response, getReport::response, @@ -1044,7 +1010,6 @@ using response = std::variant, version::response, limits::response, samples::response, - get_counter_by_name::response, get_shm_info::response, get_shm_tsc_info::response, neighbor_show::response, diff --git a/dataplane/bus.cpp b/dataplane/bus.cpp index ac58a5ac..69df3bbf 100644 --- a/dataplane/bus.cpp +++ b/dataplane/bus.cpp @@ -269,14 +269,6 @@ void cBus::clientThread(int clientSocket) { response = callWithResponse(&cControlPlane::clearFWState, request); } - else if (type == common::idp::requestType::getCounters) - { - response = callWithResponse(&cControlPlane::getCounters, request); - } - else if (type == common::idp::requestType::getOtherStats) - { - response = callWithResponse(&cControlPlane::getOtherStats, request); - } else if (type == common::idp::requestType::getConfig) { response = callWithResponse(&cControlPlane::getConfig, request); @@ -301,10 +293,6 @@ void cBus::clientThread(int clientSocket) { response = callWithResponse(&cControlPlane::limits, request); } - else if (type == common::idp::requestType::getAclCounters) - { - response = callWithResponse(&cControlPlane::getAclCounters, request); - } else if (type == common::idp::requestType::balancer_connection) { response = callWithResponse(&cControlPlane::balancer_connection, request); @@ -337,10 +325,6 @@ void cBus::clientThread(int clientSocket) { response = callWithResponse(&cControlPlane::version, request); } - else if (type == common::idp::requestType::get_counter_by_name) - { - response = callWithResponse(&cControlPlane::get_counter_by_name, request); - } else if (type == common::idp::requestType::nat64stateful_state) { response = callWithResponse(&cControlPlane::nat64stateful_state, request); diff --git a/dataplane/controlplane.cpp b/dataplane/controlplane.cpp index 894d0a6b..525bfa4f 100644 --- a/dataplane/controlplane.cpp +++ b/dataplane/controlplane.cpp @@ -176,25 +176,6 @@ common::idp::getGlobalBase::response cControlPlane::getGlobalBase(const common:: return response; } -common::idp::getOtherStats::response cControlPlane::getOtherStats() -{ - common::idp::getOtherStats::response response; - auto& [response_workers] = response; - - /// workers - { - for (const cWorker* worker : dataPlane->workers_vector) - { - std::array bursts; - memcpy(&bursts[0], worker->bursts, (CONFIG_YADECAP_MBUFS_BURST_SIZE + 1) * sizeof(uint64_t)); - - response_workers[worker->coreId] = {bursts}; - } - } - - return response; -} - common::idp::getWorkerStats::response cControlPlane::getWorkerStats(const common::idp::getWorkerStats::request& request) { /// unsafe @@ -572,24 +553,6 @@ eResult cControlPlane::clearFWState() return common::result_e::success; } -common::idp::getAclCounters::response cControlPlane::getAclCounters() -{ - std::lock_guard guard(mutex); - - common::idp::getAclCounters::response response; - - response.resize(YANET_CONFIG_ACL_COUNTERS_SIZE); - for (const cWorker* worker : dataPlane->workers_vector) - { - for (size_t i = 0; i < YANET_CONFIG_ACL_COUNTERS_SIZE; i++) - { - response[i] += worker->aclCounters[i]; - } - } - - return response; -} - common::idp::getPortStatsEx::response cControlPlane::getPortStatsEx() { common::idp::getPortStatsEx::response response; @@ -625,33 +588,6 @@ common::idp::getPortStatsEx::response cControlPlane::getPortStatsEx() return response; } -common::idp::getCounters::response cControlPlane::getCounters(const common::idp::getCounters::request& request) -{ - common::idp::getCounters::response response; - response.resize(request.size()); - - for (size_t i = 0; - i < request.size(); - i++) - { - const auto& counter_id = request[i]; - - if (counter_id >= YANET_CONFIG_COUNTERS_SIZE) - { - std::lock_guard guard(mutex); - ++errors["getCounters: invalid counterId"]; - continue; - } - - response[i] = accumulateWorkerStats( - [counter_id](cWorker* worker) { - return worker->counters[counter_id]; - }); - } - - return response; -} - common::idp::getConfig::response cControlPlane::getConfig() const { common::idp::getConfig::response response; @@ -1092,47 +1028,6 @@ common::idp::version::response cControlPlane::version() version_custom()}; } -common::idp::get_counter_by_name::response cControlPlane::get_counter_by_name(const common::idp::get_counter_by_name::request& request) -{ - common::idp::get_counter_by_name::response response; - - const auto& [counter_name, optional_core_id] = request; - - if (optional_core_id.has_value()) - { - std::optional counter_val = dataPlane->getCounterValueByName(counter_name, optional_core_id.value()); - if (counter_val.has_value()) - { - response[optional_core_id.value()] = counter_val.value(); - } - - // if counter with provided name does not exist, empty map will be returned, and its emptiness should be checked on another end - return response; - } - - // core_id was not specified, return counter for each core_id - for (const cWorker* worker : dataPlane->workers_vector) - { - std::optional counter_val = dataPlane->getCounterValueByName(counter_name, worker->coreId); - if (counter_val.has_value()) - { - response[worker->coreId] = counter_val.value(); - } - } - - for (const auto& [core_id, worker_gc] : dataPlane->worker_gcs) - { - (void)worker_gc; - std::optional counter_val = dataPlane->getCounterValueByName(counter_name, core_id); - if (counter_val.has_value()) - { - response[core_id] = counter_val.value(); - } - } - - return response; -} - common::idp::get_shm_info::response cControlPlane::get_shm_info() { common::idp::get_shm_info::response response; diff --git a/dataplane/controlplane.h b/dataplane/controlplane.h index b8cd44b0..182aa590 100644 --- a/dataplane/controlplane.h +++ b/dataplane/controlplane.h @@ -67,9 +67,6 @@ class cControlPlane ///< @todo: move to cDataPlane common::idp::getFWState::response getFWState(); common::idp::getFWStateStats::response getFWStateStats(); eResult clearFWState(); - common::idp::getAclCounters::response getAclCounters(); - common::idp::getCounters::response getCounters(const common::idp::getCounters::request& request); - common::idp::getOtherStats::response getOtherStats(); common::idp::getConfig::response getConfig() const; common::idp::getErrors::response getErrors(); common::idp::getReport::response getReport(); @@ -84,7 +81,6 @@ class cControlPlane ///< @todo: move to cDataPlane eResult unrdup_vip_to_balancers(const common::idp::unrdup_vip_to_balancers::request& request); eResult update_vip_vport_proto(const common::idp::update_vip_vport_proto::request& request); common::idp::version::response version(); - common::idp::get_counter_by_name::response get_counter_by_name(const common::idp::get_counter_by_name::request& request); common::idp::nat64stateful_state::response nat64stateful_state(const common::idp::nat64stateful_state::request& request); common::idp::get_shm_info::response get_shm_info(); common::idp::get_shm_tsc_info::response get_shm_tsc_info(); diff --git a/dataplane/dataplane.cpp b/dataplane/dataplane.cpp index f1487649..b443d3e7 100644 --- a/dataplane/dataplane.cpp +++ b/dataplane/dataplane.cpp @@ -994,7 +994,6 @@ eResult cDataPlane::initWorkers() return result; } - worker->fillStatsNamesToAddrsTable(coreId_to_stats_tables[coreId]); workers[coreId] = worker; workers_vector.emplace_back(worker); @@ -1095,7 +1094,6 @@ eResult cDataPlane::initWorkers() return result; } - worker->fillStatsNamesToAddrsTable(coreId_to_stats_tables[core_id]); worker_gcs[core_id] = worker; socket_worker_gcs[socket_id] = worker; } @@ -1141,8 +1139,6 @@ eResult cDataPlane::InitSlowWorker(const tCoreId core, const CPlaneWorkerConfig& return result; } - worker->fillStatsNamesToAddrsTable(coreId_to_stats_tables[core]); - workers_vector.emplace_back(worker); std::vector kni_bundleconf; @@ -1238,24 +1234,6 @@ eResult cDataPlane::InitSlowWorkers() return eResult::success; } -std::optional cDataPlane::getCounterValueByName(const std::string& counter_name, uint32_t coreId) -{ - if (coreId_to_stats_tables.count(coreId) == 0) - { - return std::optional(); - } - - const auto& specific_core_table = coreId_to_stats_tables[coreId]; - - if (specific_core_table.count(counter_name) == 0) - { - return std::optional(); - } - - uint64_t counter_value = *(specific_core_table.at(counter_name)); - return std::optional(counter_value); -} - eResult cDataPlane::InitTxQueues() { for (const auto& portIter : ports) diff --git a/dataplane/dataplane.h b/dataplane/dataplane.h index e72d3af4..453a8cec 100644 --- a/dataplane/dataplane.h +++ b/dataplane/dataplane.h @@ -159,7 +159,6 @@ class cDataPlane eResult allocateSharedMemory(); eResult splitSharedMemoryPerWorkers(); - std::optional getCounterValueByName(const std::string& counter_name, uint32_t coreId); common::idp::get_shm_info::response getShmInfo(); common::idp::get_shm_tsc_info::response getShmTscInfo(); @@ -171,7 +170,6 @@ class cDataPlane friend class cWorker; friend class cReport; friend class cControlPlane; - friend class cBus; friend class dataplane::globalBase::generation; friend class worker_gc_t; @@ -226,9 +224,6 @@ class cDataPlane common::idp::get_shm_tsc_info::response tscs_meta; - // array instead of the table - how many coreIds can be there? - std::unordered_map> coreId_to_stats_tables; - std::map> shm_by_socket_id; std::set socket_ids; diff --git a/dataplane/worker.cpp b/dataplane/worker.cpp index 98fe32b2..aa5b09ce 100644 --- a/dataplane/worker.cpp +++ b/dataplane/worker.cpp @@ -258,73 +258,6 @@ void cWorker::start() mainThread(); } -void cWorker::fillStatsNamesToAddrsTable(std::unordered_map& table) -{ - table["brokenPackets"] = &stats->brokenPackets; - table["dropPackets"] = &stats->dropPackets; - table["ring_highPriority_drops"] = &stats->ring_highPriority_drops; - table["ring_normalPriority_drops"] = &stats->ring_normalPriority_drops; - table["ring_lowPriority_drops"] = &stats->ring_lowPriority_drops; - table["ring_highPriority_packets"] = &stats->ring_highPriority_packets; - table["ring_normalPriority_packets"] = &stats->ring_normalPriority_packets; - table["ring_lowPriority_packets"] = &stats->ring_lowPriority_packets; - table["decap_packets"] = &stats->decap_packets; - table["decap_fragments"] = &stats->decap_fragments; - table["decap_unknownExtensions"] = &stats->decap_unknownExtensions; - table["interface_lookupMisses"] = &stats->interface_lookupMisses; - table["interface_hopLimits"] = &stats->interface_hopLimits; - table["interface_neighbor_invalid"] = &stats->interface_neighbor_invalid; - table["nat64stateless_ingressPackets"] = &stats->nat64stateless_ingressPackets; - table["nat64stateless_ingressFragments"] = &stats->nat64stateless_ingressFragments; - table["nat64stateless_ingressUnknownICMP"] = &stats->nat64stateless_ingressUnknownICMP; - table["nat64stateless_egressPackets"] = &stats->nat64stateless_egressPackets; - table["nat64stateless_egressFragments"] = &stats->nat64stateless_egressFragments; - table["nat64stateless_egressUnknownICMP"] = &stats->nat64stateless_egressUnknownICMP; - table["balancer_invalid_reals_count"] = &stats->balancer_invalid_reals_count; - table["fwsync_multicast_egress_drops"] = &stats->fwsync_multicast_egress_drops; - table["fwsync_multicast_egress_packets"] = &stats->fwsync_multicast_egress_packets; - table["fwsync_multicast_egress_imm_packets"] = &stats->fwsync_multicast_egress_imm_packets; - table["fwsync_no_config_drops"] = &stats->fwsync_no_config_drops; - table["fwsync_unicast_egress_drops"] = &stats->fwsync_unicast_egress_drops; - table["fwsync_unicast_egress_packets"] = &stats->fwsync_unicast_egress_packets; - table["acl_ingress_dropPackets"] = &stats->acl_ingress_dropPackets; - table["acl_egress_dropPackets"] = &stats->acl_egress_dropPackets; - table["repeat_ttl"] = &stats->repeat_ttl; - table["leakedMbufs"] = &stats->leakedMbufs; - table["logs_packets"] = &stats->logs_packets; - table["logs_drops"] = &stats->logs_drops; - - table["balancer_state_insert_failed"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_state_insert_failed]; - table["balancer_state_insert_done"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_state_insert_done]; - table["balancer_icmp_generated_echo_reply_ipv4"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_generated_echo_reply_ipv4]; - table["balancer_icmp_generated_echo_reply_ipv6"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_generated_echo_reply_ipv6]; - table["balancer_icmp_drop_icmpv4_payload_too_short_ip"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_icmpv4_payload_too_short_ip]; - table["balancer_icmp_drop_icmpv4_payload_too_short_port"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_icmpv4_payload_too_short_port]; - table["balancer_icmp_drop_icmpv6_payload_too_short_ip"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_icmpv6_payload_too_short_ip]; - table["balancer_icmp_drop_icmpv6_payload_too_short_port"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_icmpv6_payload_too_short_port]; - table["balancer_icmp_unmatching_src_from_original_ipv4"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_unmatching_src_from_original_ipv4]; - table["balancer_icmp_unmatching_src_from_original_ipv6"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_unmatching_src_from_original_ipv6]; - table["balancer_icmp_drop_real_disabled"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_real_disabled]; - table["balancer_icmp_no_balancer_src_ipv4"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_no_balancer_src_ipv4]; - table["balancer_icmp_no_balancer_src_ipv6"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_no_balancer_src_ipv6]; - table["balancer_icmp_drop_already_cloned"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_already_cloned]; - table["balancer_icmp_drop_no_unrdup_table_for_balancer_id"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_no_unrdup_table_for_balancer_id]; - table["balancer_icmp_drop_unrdup_vip_not_found"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_unrdup_vip_not_found]; - table["balancer_icmp_drop_no_vip_vport_proto_table_for_balancer_id"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_no_vip_vport_proto_table_for_balancer_id]; - table["balancer_icmp_drop_unexpected_transport_protocol"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_unexpected_transport_protocol]; - table["balancer_icmp_drop_unknown_service"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_drop_unknown_service]; - table["balancer_icmp_failed_to_clone"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_failed_to_clone]; - table["balancer_icmp_clone_forwarded"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_clone_forwarded]; - table["balancer_icmp_sent_to_real"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_sent_to_real]; - table["balancer_icmp_out_rate_limit_reached"] = &counters[(uint32_t)common::globalBase::static_counter_type::balancer_icmp_out_rate_limit_reached]; - table["slow_worker_normal_priority_rate_limit_exceeded"] = &counters[(uint32_t)common::globalBase::static_counter_type::slow_worker_normal_priority_rate_limit_exceeded]; - - table["acl_ingress_v4_broken_packet"] = &counters[(uint32_t)common::globalBase::static_counter_type::acl_ingress_v4_broken_packet]; - table["acl_ingress_v6_broken_packet"] = &counters[(uint32_t)common::globalBase::static_counter_type::acl_ingress_v6_broken_packet]; - table["acl_egress_v4_broken_packet"] = &counters[(uint32_t)common::globalBase::static_counter_type::acl_egress_v4_broken_packet]; - table["acl_egress_v6_broken_packet"] = &counters[(uint32_t)common::globalBase::static_counter_type::acl_egress_v6_broken_packet]; -} - void cWorker::FillMetadataWorkerCounters(common::sdp::MetadataWorker& metadata) { metadata.size = 0; diff --git a/dataplane/worker.h b/dataplane/worker.h index 455e2972..8595206c 100644 --- a/dataplane/worker.h +++ b/dataplane/worker.h @@ -70,7 +70,6 @@ class cWorker eResult init(const tCoreId& coreId, const dataplane::base::permanently& basePermanently, const dataplane::base::generation& base); void start(); - void fillStatsNamesToAddrsTable(std::unordered_map& table); static void FillMetadataWorkerCounters(common::sdp::MetadataWorker& metadata); void SetBufferForCounters(void* buffer, const common::sdp::MetadataWorker& metadata); diff --git a/dataplane/worker_gc.cpp b/dataplane/worker_gc.cpp index 9517dcf0..832f18cb 100644 --- a/dataplane/worker_gc.cpp +++ b/dataplane/worker_gc.cpp @@ -153,21 +153,6 @@ void worker_gc_t::limits(common::idp::limits::response& response) const globalbase_atomic->updater.fw6_state.limits(response, "acl.state.v6.ht"); } -void worker_gc_t::fillStatsNamesToAddrsTable(std::unordered_map& table) -{ - table["broken_packets"] = &stats->broken_packets; - table["drop_packets"] = &stats->drop_packets; - table["ring_to_slowworker_packets"] = &stats->ring_to_slowworker_packets; - table["ring_to_slowworker_drops"] = &stats->ring_to_slowworker_drops; - table["fwsync_multicast_egress_packets"] = &stats->fwsync_multicast_egress_packets; - table["fwsync_multicast_egress_drops"] = &stats->fwsync_multicast_egress_drops; - table["fwsync_unicast_egress_packets"] = &stats->fwsync_unicast_egress_packets; - table["fwsync_unicast_egress_drops"] = &stats->fwsync_unicast_egress_drops; - table["drop_samples"] = &stats->drop_samples; - table["balancer_state_insert_failed"] = &stats->balancer_state_insert_failed; - table["balancer_state_insert_done"] = &stats->balancer_state_insert_done; -} - void worker_gc_t::FillMetadataWorkerCounters(common::sdp::MetadataWorkerGc& metadata) { metadata.size = 0; diff --git a/dataplane/worker_gc.h b/dataplane/worker_gc.h index ba6b7bae..a74c56c9 100644 --- a/dataplane/worker_gc.h +++ b/dataplane/worker_gc.h @@ -31,7 +31,6 @@ class worker_gc_t void limits(common::idp::limits::response& response) const; - void fillStatsNamesToAddrsTable(std::unordered_map& table); static void FillMetadataWorkerCounters(common::sdp::MetadataWorkerGc& metadata); void SetBufferForCounters(void* buffer, const common::sdp::MetadataWorkerGc& metadata);