Skip to content

Commit

Permalink
bpf_metadata: align logging for restoration
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mhofstetter committed Jan 24, 2025
1 parent 7717128 commit f946a25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cilium/bpf_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ struct SocketMetadata : public Logger::Loggable<Logger::Id::filter> {

// 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_);
}

Expand Down
6 changes: 4 additions & 2 deletions cilium/socket_option_source_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f946a25

Please sign in to comment.