Skip to content

Commit

Permalink
remove self-check form icmp broadcast (list must be already filtered)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav00 authored and taitov committed Sep 21, 2023
1 parent 3e75227 commit 91198fb
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 138 deletions.
5 changes: 0 additions & 5 deletions common/idataplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ class dataPlane
return get<common::idp::requestType::unrdup_vip_to_balancers, common::idp::unrdup_vip_to_balancers::response>(request);
}

eResult update_interfaces_ips(const common::idp::update_interfaces_ips::request& request) const
{
return get<common::idp::requestType::update_interfaces_ips, common::idp::update_interfaces_ips::response>(request);
}

eResult update_vip_vport_proto(const common::idp::update_vip_vport_proto::request& request) const
{
return get<common::idp::requestType::update_vip_vport_proto, common::idp::update_vip_vport_proto::response>(request);
Expand Down
10 changes: 0 additions & 10 deletions common/idp.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ enum class requestType : uint32_t
samples,
debug_latch_update,
unrdup_vip_to_balancers,
update_interfaces_ips,
update_vip_vport_proto,
version,
get_counter_by_name,
Expand Down Expand Up @@ -804,14 +803,6 @@ namespace unrdup_vip_to_balancers
using response = eResult;
}

namespace update_interfaces_ips
{
using request = std::tuple<std::unordered_map<common::ipv4_address_t, std::string>,
std::unordered_map<common::ipv6_address_t, std::string>>;

using response = eResult;
}

namespace update_vip_vport_proto
{
using request = std::tuple<uint32_t, std::unordered_set<std::tuple<common::ip_address_t, uint16_t, uint8_t>>>;
Expand Down Expand Up @@ -890,7 +881,6 @@ using request = std::tuple<requestType,
balancer_connection::request,
debug_latch_update::request,
unrdup_vip_to_balancers::request,
update_interfaces_ips::request,
update_vip_vport_proto::request,
get_counter_by_name::request>>;

Expand Down
96 changes: 0 additions & 96 deletions controlplane/src/route.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,101 +799,6 @@ void route_t::compile_interface(common::idp::updateGlobalBase::request& globalba
}
}

void route_t::update_interfaces_ips(const route::generation_t& current_generation, const route::generation_t& next_generation)
{
bool changed = false;
std::unordered_map<common::ipv4_address_t, std::string> current_ipv4_addrs;
std::unordered_map<common::ipv6_address_t, std::string> current_ipv6_addrs;

for (const auto& [route_name, route] : current_generation.routes)
{
(void)route_name;

for (const auto& [interface_name, interface] : route.interfaces)
{
for (const auto &interface_ip : interface.ipAddresses)
{
if (interface_ip.is_ipv4())
{
current_ipv4_addrs[interface_ip.get_ipv4()] = interface_name;
}
else
{
current_ipv6_addrs[interface_ip.get_ipv6()] = interface_name;
}
}
}
}

std::unordered_map<common::ipv4_address_t, std::string> next_ipv4_addrs;
std::unordered_map<common::ipv6_address_t, std::string> next_ipv6_addrs;

for (const auto& [route_name, route] : next_generation.routes)
{
(void)route_name;

for (const auto& [interface_name, interface] : route.interfaces)
{
for (const auto &interface_ip : interface.ipAddresses)
{
if (interface_ip.is_ipv4())
{
next_ipv4_addrs[interface_ip.get_ipv4()] = interface_name;

if (current_ipv4_addrs.count(interface_ip.get_ipv4()) == 0)
{
changed = true;
}
}
else
{
next_ipv6_addrs[interface_ip.get_ipv6()] = interface_name;

if (current_ipv6_addrs.count(interface_ip.get_ipv6()) == 0)
{
changed = true;
}
}
}
}
}

if (!changed)
{
for (const auto& [current_iface_ipv4, current_iface_name] : current_ipv4_addrs)
{
(void)current_iface_name;

// if some interface ips from current maps are absent in new maps, reload is required
if (next_ipv4_addrs.count(current_iface_ipv4) == 0)
{
changed = true;
break;
}
}
}

if (!changed)
{
for (const auto& [current_iface_ipv6, current_iface_name] : current_ipv6_addrs)
{
(void)current_iface_name;

// if some interface ips from current maps are absent in new maps, reload is required
if (next_ipv6_addrs.count(current_iface_ipv6) == 0)
{
changed = true;
break;
}
}
}

if (changed)
{
dataplane.update_interfaces_ips(std::make_tuple(next_ipv4_addrs, next_ipv6_addrs));
}
}

void route_t::limit(common::icp::limit_summary::response& limits) const
{
limit_insert(limits, "route.values", values.stats());
Expand Down Expand Up @@ -987,7 +892,6 @@ void route_t::reload(const controlplane::base_t& base_prev,

compile(globalbase, generations.next());
compile_interface(globalbase, generations.next(), generations_neighbors.next());
update_interfaces_ips(generations.current(), generations.next());

}

Expand Down
1 change: 0 additions & 1 deletion controlplane/src/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ class route_t : public module_t

void compile(common::idp::updateGlobalBase::request& globalbase, const route::generation_t& generation);
void compile_interface(common::idp::updateGlobalBase::request& globalbase, const route::generation_t& generation, route::generation_neighbors_t& generation_neighbors);
void update_interfaces_ips(const route::generation_t& current_generation, const route::generation_t& next_generation);

protected:
void prefix_flush_prefixes(common::idp::updateGlobalBase::request& globalbase);
Expand Down
4 changes: 0 additions & 4 deletions dataplane/src/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,6 @@ void cBus::clientThread(int clientSocket)
{
response = callWithResponse(&cControlPlane::unrdup_vip_to_balancers, request);
}
else if (type == common::idp::requestType::update_interfaces_ips)
{
response = callWithResponse(&cControlPlane::update_interfaces_ips, request);
}
else if (type == common::idp::requestType::update_vip_vport_proto)
{
response = callWithResponse(&cControlPlane::update_vip_vport_proto, request);
Expand Down
17 changes: 0 additions & 17 deletions dataplane/src/controlplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,16 +1156,6 @@ eResult cControlPlane::unrdup_vip_to_balancers(const common::idp::unrdup_vip_to_
return eResult::success;
}

eResult cControlPlane::update_interfaces_ips(const common::idp::update_interfaces_ips::request& request)
{
std::lock_guard<std::mutex> guard(interfaces_ips_mutex);

self_interfaces_ipv4s = std::get<0>(request);
self_interfaces_ipv6s = std::get<1>(request);

return eResult::success;
}

eResult cControlPlane::update_vip_vport_proto(const common::idp::update_vip_vport_proto::request& request)
{
std::lock_guard<std::mutex> guard(vip_vport_proto_mutex);
Expand Down Expand Up @@ -3087,13 +3077,6 @@ void cControlPlane::handlePacket_balancer_icmp_forward(rte_mbuf* mbuf)

for (const auto &neighbor_balancer : neighbor_balancers)
{
if ((neighbor_balancer.is_ipv4() && self_interfaces_ipv4s.count(neighbor_balancer.get_ipv4()))
|| (neighbor_balancer.is_ipv6() && self_interfaces_ipv6s.count(neighbor_balancer.get_ipv6())))
{
// no need to send to yourself
continue;
}

// will not send a cloned packet if source address in "balancer" section of controlplane.conf is absent
if (neighbor_balancer.is_ipv4() && !base.globalBase->balancers[metadata->flow.data.balancer.id].source_ipv4.address)
{
Expand Down
5 changes: 0 additions & 5 deletions dataplane/src/controlplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class cControlPlane ///< @todo: move to cDataPlane
common::idp::balancer_real_connections::response balancer_real_connections();
eResult debug_latch_update(const common::idp::debug_latch_update::request& request);
eResult unrdup_vip_to_balancers(const common::idp::unrdup_vip_to_balancers::request& request);
eResult update_interfaces_ips(const common::idp::update_interfaces_ips::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);
Expand Down Expand Up @@ -174,10 +173,6 @@ class cControlPlane ///< @todo: move to cDataPlane
std::vector<std::unordered_map<common::ip_address_t, std::unordered_set<common::ip_address_t>>> vip_to_balancers;
// check presence prior to cloning
std::vector<std::unordered_set<std::tuple<common::ip_address_t, uint16_t, uint8_t>>> vip_vport_proto;
/* taken from route section, interface subsection of controlplane.cfg,
used for excluding self from destination addresses when broadcasting cloned packets to neighbor balancers */
std::unordered_map<common::ipv4_address_t, std::string> self_interfaces_ipv4s;
std::unordered_map<common::ipv6_address_t, std::string> self_interfaces_ipv6s;

std::chrono::high_resolution_clock::time_point prevTimePointForSWRateLimiter;

Expand Down

0 comments on commit 91198fb

Please sign in to comment.