From f946a2590aed2862d2a56a29dae2a0eb9b53ba00 Mon Sep 17 00:00:00 2001 From: Marco Hofstetter Date: Fri, 24 Jan 2025 12:51:33 +0100 Subject: [PATCH] bpf_metadata: align logging for restoration This commit aligns the logging for restoration of the local address for downstream & upstream socket by always logging the socket and the old & new local address. Signed-off-by: Marco Hofstetter --- cilium/bpf_metadata.h | 4 +++- cilium/socket_option_source_address.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cilium/bpf_metadata.h b/cilium/bpf_metadata.h index ae0c7d154..1f5e1454d 100644 --- a/cilium/bpf_metadata.h +++ b/cilium/bpf_metadata.h @@ -90,9 +90,11 @@ struct SocketMetadata : public Logger::Loggable { // Restoration of the original destination address lets the OriginalDstCluster know the // destination address that can be used. - ENVOY_LOG(trace, "cilium.bpf_metadata: restoreLocalAddress ({} -> {})", + ENVOY_LOG(trace, "cilium.bpf_metadata: restoreLocalAddress on socket {} ({} -> {})", + socket.ioHandle().fdDoNotUse(), socket.connectionInfoProvider().localAddress()->asString(), original_dest_address_->asString()); + socket.connectionInfoProvider().restoreLocalAddress(original_dest_address_); } diff --git a/cilium/socket_option_source_address.h b/cilium/socket_option_source_address.h index df7e38613..4b4b0b385 100644 --- a/cilium/socket_option_source_address.h +++ b/cilium/socket_option_source_address.h @@ -84,9 +84,11 @@ class SourceAddressSocketOption : public Network::Socket::Option, // Note: we don't expect this to change the behaviour of the socket. We expect it to be copied // into the upstream connection later. + ENVOY_LOG(trace, "Restoring local address (setLocalAddress) on socket: {} ({} -> {})", + socket.ioHandle().fdDoNotUse(), + socket.connectionInfoProvider().localAddress()->asString(), + source_address->asString()); socket.connectionInfoProvider().setLocalAddress(std::move(source_address)); - ENVOY_LOG(trace, "Successfully restored local address on socket: {}", - socket.ioHandle().fdDoNotUse()); return true; }