From 9b9b1c483b3ebd2f512e4371ebb207499d4278b8 Mon Sep 17 00:00:00 2001 From: Marco Hofstetter Date: Thu, 30 Jan 2025 17:35:09 +0100 Subject: [PATCH] tls_wrapper: use ENVOY_LOG instead of ENVOY_LOG_MISC ENVOY_LOG_MISC should be used where no logger ID is available. The SslSocketWrapper uses a logger ID and should make use of this by using `ENVOY_LOG`. This helps when filtering log messages by logger IDs. In addition, this commit changes the current logger instance `config` to `connection` - which is also used by the upstream Envoy TransportSocket implementations. Signed-off-by: Marco Hofstetter --- cilium/tls_wrapper.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cilium/tls_wrapper.cc b/cilium/tls_wrapper.cc index 2a90e38f2..00b32c78a 100644 --- a/cilium/tls_wrapper.cc +++ b/cilium/tls_wrapper.cc @@ -40,7 +40,7 @@ constexpr absl::string_view NotReadyReason{"TLS error: Secret is not supplied by // This SslSocketWrapper wraps a real SslSocket and hooks it up with // TLS configuration derived from Cilium Network Policy. -class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable { +class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable { public: SslSocketWrapper(Extensions::TransportSockets::Tls::InitialState state, const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options) @@ -114,11 +114,11 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::Loggableport(); destination_identity = policy_socket_option->resolvePolicyId(dip); } else { - ENVOY_LOG_MISC(warn, "cilium.tls_wrapper: Non-IP destination address: {}", - dst_address->asString()); + ENVOY_LOG(warn, "cilium.tls_wrapper: Non-IP destination address: {}", + dst_address->asString()); } } else { - ENVOY_LOG_MISC(warn, "cilium.tls_wrapper: No destination address"); + ENVOY_LOG(warn, "cilium.tls_wrapper: No destination address"); } } @@ -144,8 +144,7 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::Loggableconnection().connectionInfoSetter().setSslConnection(socket_->ssl()); } else { - ENVOY_LOG_MISC(error, "Unable to create ssl socket {}", - status_or_socket.status().message()); + ENVOY_LOG(error, "Unable to create ssl socket {}", status_or_socket.status().message()); } } else if (config == nullptr && raw_socket_allowed) { // Use RawBufferSocket when policy allows without TLS. @@ -172,7 +171,7 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::LoggableaddressAsString(); } } - ENVOY_LOG_MISC( + ENVOY_LOG( warn, "cilium.tls_wrapper: Could not get {} TLS context for pod {} on {} IP {} (id {}) port " "{} sni \"{}\" and raw socket is not allowed", @@ -181,8 +180,8 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable