Skip to content

Commit

Permalink
tls_wrapper: use ENVOY_CONN_LOG instead of ENVOY_LOG_MISC
Browse files Browse the repository at this point in the history
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_CONN_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 <[email protected]>
  • Loading branch information
mhofstetter authored and jrajahalme committed Jan 30, 2025
1 parent eb93e33 commit f0d28a4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cilium/tls_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Logger::Id::config> {
class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable<Logger::Id::connection> {
public:
SslSocketWrapper(Extensions::TransportSockets::Tls::InitialState state,
const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options)
Expand Down Expand Up @@ -114,11 +114,11 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable<Logge
destination_port = dip->port();
destination_identity = policy_socket_option->resolvePolicyId(dip);
} else {
ENVOY_LOG_MISC(warn, "cilium.tls_wrapper: Non-IP destination address: {}",
ENVOY_CONN_LOG(warn, "cilium.tls_wrapper: Non-IP destination address: {}", conn,
dst_address->asString());
}
} else {
ENVOY_LOG_MISC(warn, "cilium.tls_wrapper: No destination address");
ENVOY_CONN_LOG(warn, "cilium.tls_wrapper: No destination address", conn);
}
}

Expand All @@ -144,7 +144,7 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable<Logge
// explicitly configure ssl connection with the latest configuration from the SSL socket.
callbacks_->connection().connectionInfoSetter().setSslConnection(socket_->ssl());
} else {
ENVOY_LOG_MISC(error, "Unable to create ssl socket {}",
ENVOY_CONN_LOG(error, "Unable to create ssl socket {}", conn,
status_or_socket.status().message());
}
} else if (config == nullptr && raw_socket_allowed) {
Expand Down Expand Up @@ -172,17 +172,19 @@ class SslSocketWrapper : public Network::TransportSocket, Logger::Loggable<Logge
ipStr = dip->addressAsString();
}
}
ENVOY_LOG_MISC(
ENVOY_CONN_LOG(
warn,
"cilium.tls_wrapper: Could not get {} TLS context for pod {} on {} IP {} (id {}) port "
"{} sni \"{}\" and raw socket is not allowed",
is_client ? "client" : "server", policy_socket_option->pod_ip_,
conn, is_client ? "client" : "server", policy_socket_option->pod_ip_,
policy_socket_option->ingress_ ? "source" : "destination", ipStr, remote_id,
destination_port, sni);
}
} else {
ENVOY_LOG_MISC(warn, "cilium.tls_wrapper: Can not correlate connection with Cilium Network "
"Policy (Cilium socket option not found)");
ENVOY_CONN_LOG(warn,
"cilium.tls_wrapper: Can not correlate connection with Cilium Network "
"Policy (Cilium socket option not found)",
conn);
}

if (socket_) {
Expand Down

0 comments on commit f0d28a4

Please sign in to comment.