diff --git a/cilium/conntrack.cc b/cilium/conntrack.cc index 3b801ee48..55174b485 100644 --- a/cilium/conntrack.cc +++ b/cilium/conntrack.cc @@ -7,6 +7,7 @@ #include "envoy/common/platform.h" +#include "source/common/common/thread.h" #include "source/common/common/utility.h" #include "source/common/network/address_impl.h" @@ -149,7 +150,7 @@ CtMap::openMap6(const std::string& map_name) { } void CtMap::closeMaps(const std::shared_ptr>& to_be_closed) { - std::lock_guard guard(maps_mutex_); + std::lock_guard guard(maps_mutex_); for (const auto& name : *to_be_closed) { auto ct4 = ct_maps4_.find(name); @@ -213,7 +214,7 @@ uint32_t CtMap::lookupSrcIdentity(const std::string& map_name, const Network::Ad if (dip->version() == Network::Address::IpVersion::v4) { // Lock for the duration of the map lookup and conntrack lookup - std::lock_guard guard(maps_mutex_); + std::lock_guard guard(maps_mutex_); auto it = ct_maps4_.find(map_name); if (it == ct_maps4_.end()) { it = openMap4(map_name); @@ -231,7 +232,7 @@ uint32_t CtMap::lookupSrcIdentity(const std::string& map_name, const Network::Ad } } else { // Lock for the duration of the map lookup and conntrack lookup - std::lock_guard guard(maps_mutex_); + std::lock_guard guard(maps_mutex_); auto it = ct_maps6_.find(map_name); if (it == ct_maps6_.end()) { it = openMap6(map_name); diff --git a/cilium/conntrack.h b/cilium/conntrack.h index c7a2c8078..739699b12 100644 --- a/cilium/conntrack.h +++ b/cilium/conntrack.h @@ -8,6 +8,7 @@ #include "envoy/singleton/instance.h" #include "source/common/common/logger.h" +#include "source/common/common/thread.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" @@ -70,7 +71,7 @@ class CtMap : public Singleton::Instance, Logger::Loggable { // All known conntrack maps. Populated with the "global" maps at startup, // further maps are opened and inserted on demand. - std::mutex maps_mutex_; + Thread::MutexBasicLockable maps_mutex_; absl::flat_hash_map> ct_maps4_; absl::flat_hash_map> ct_maps6_; std::string bpf_root_;