Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions envoy/network/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ class Connection : public Event::DeferredDeletable,
virtual bool readEnabled() const PURE;

/**
* @return the address provider backing this connection.
* @return the connection info provider backing this connection.
*/
virtual const ConnectionInfoProvider& addressProvider() const PURE;
virtual ConnectionInfoProviderSharedPtr addressProviderSharedPtr() const PURE;
virtual const ConnectionInfoProvider& connectionInfoProvider() const PURE;
virtual ConnectionInfoProviderSharedPtr connectionInfoProviderSharedPtr() const PURE;

/**
* Credentials of the peer of a socket as decided by SO_PEERCRED.
Expand Down
8 changes: 4 additions & 4 deletions envoy/network/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ class Socket {
enum class Type { Stream, Datagram };

/**
* @return the address provider backing this socket.
* @return the connection info provider backing this socket.
*/
virtual ConnectionInfoSetter& addressProvider() PURE;
virtual const ConnectionInfoProvider& addressProvider() const PURE;
virtual ConnectionInfoProviderSharedPtr addressProviderSharedPtr() const PURE;
virtual ConnectionInfoSetter& connectionInfoProvider() PURE;
virtual const ConnectionInfoProvider& connectionInfoProvider() const PURE;
virtual ConnectionInfoProviderSharedPtr connectionInfoProviderSharedPtr() const PURE;

/**
* @return IoHandle for the underlying connection
Expand Down
2 changes: 1 addition & 1 deletion envoy/stream_info/stream_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class StreamInfo {
virtual void healthCheck(bool is_health_check) PURE;

/**
* @return the downstream address provider.
* @return the downstream connection info provider.
*/
virtual const Network::ConnectionInfoProvider& downstreamAddressProvider() const PURE;

Expand Down
6 changes: 3 additions & 3 deletions source/common/http/conn_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ void ConnectionManagerImpl::initializeReadFilterCallbacks(Network::ReadFilterCal
read_callbacks_->connection().streamInfo().filterState()->setData(
Network::ProxyProtocolFilterState::key(),
std::make_unique<Network::ProxyProtocolFilterState>(Network::ProxyProtocolData{
read_callbacks_->connection().addressProvider().remoteAddress(),
read_callbacks_->connection().addressProvider().localAddress()}),
read_callbacks_->connection().connectionInfoProvider().remoteAddress(),
read_callbacks_->connection().connectionInfoProvider().localAddress()}),
StreamInfo::FilterState::StateType::ReadOnly,
StreamInfo::FilterState::LifeSpan::Connection);
}
Expand Down Expand Up @@ -821,7 +821,7 @@ const Network::Connection* ConnectionManagerImpl::ActiveStream::connection() {
}

uint32_t ConnectionManagerImpl::ActiveStream::localPort() {
auto ip = connection()->addressProvider().localAddress()->ip();
auto ip = connection()->connectionInfoProvider().localAddress()->ip();
if (ip == nullptr) {
return 0;
}
Expand Down
11 changes: 6 additions & 5 deletions source/common/http/conn_manager_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,14 @@ ConnectionManagerUtility::MutateRequestHeadersResult ConnectionManagerUtility::m
// are but they didn't populate XFF properly, the trusted client address is the
// source address of the immediate downstream's connection to us.
if (final_remote_address == nullptr) {
final_remote_address = connection.addressProvider().remoteAddress();
final_remote_address = connection.connectionInfoProvider().remoteAddress();
}
if (!config.skipXffAppend()) {
if (Network::Utility::isLoopbackAddress(*connection.addressProvider().remoteAddress())) {
if (Network::Utility::isLoopbackAddress(
*connection.connectionInfoProvider().remoteAddress())) {
Utility::appendXff(request_headers, config.localAddress());
} else {
Utility::appendXff(request_headers, *connection.addressProvider().remoteAddress());
Utility::appendXff(request_headers, *connection.connectionInfoProvider().remoteAddress());
}
}
// If the prior hop is not a trusted proxy, overwrite any x-forwarded-proto value it set as
Expand All @@ -155,7 +156,7 @@ ConnectionManagerUtility::MutateRequestHeadersResult ConnectionManagerUtility::m
// If we find one, it will be used as the downstream address for logging. It may or may not be
// used for determining internal/external status (see below).
OriginalIPDetectionParams params = {request_headers,
connection.addressProvider().remoteAddress()};
connection.connectionInfoProvider().remoteAddress()};
for (const auto& detection_extension : config.originalIpDetectionExtensions()) {
const auto result = detection_extension->detect(params);

Expand Down Expand Up @@ -208,7 +209,7 @@ ConnectionManagerUtility::MutateRequestHeadersResult ConnectionManagerUtility::m
// After determining internal request status, if there is no final remote address, due to no XFF,
// busted XFF, etc., use the direct connection remote address for logging.
if (final_remote_address == nullptr) {
final_remote_address = connection.addressProvider().remoteAddress();
final_remote_address = connection.connectionInfoProvider().remoteAddress();
}

// Edge request is the request from external clients to front Envoy.
Expand Down
8 changes: 4 additions & 4 deletions source/common/http/filter_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ class FilterManagerCallbacks {

/**
* This class allows the remote address to be overridden for HTTP stream info. This is used for
* XFF handling. This is required to avoid providing stream info with a non-const address provider.
* Private inheritance from ConnectionInfoProvider is used to make sure users get the address
* provider via the normal getter.
* XFF handling. This is required to avoid providing stream info with a non-const connection info
* provider. Private inheritance from ConnectionInfoProvider is used to make sure users get the
* address provider via the normal getter.
*/
class OverridableRemoteConnectionInfoSetterStreamInfo : public StreamInfo::StreamInfoImpl,
private Network::ConnectionInfoProvider {
Expand Down Expand Up @@ -667,7 +667,7 @@ class FilterManager : public ScopeTrackedObject,
connection_(connection), stream_id_(stream_id), account_(std::move(account)),
proxy_100_continue_(proxy_100_continue), buffer_limit_(buffer_limit),
filter_chain_factory_(filter_chain_factory), local_reply_(local_reply),
stream_info_(protocol, time_source, connection.addressProviderSharedPtr(),
stream_info_(protocol, time_source, connection.connectionInfoProviderSharedPtr(),
parent_filter_state, filter_state_life_span) {}
~FilterManager() override {
ASSERT(state_.destroyed_);
Expand Down
2 changes: 1 addition & 1 deletion source/common/http/http1/codec_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void StreamEncoderImpl::readDisable(bool disable) {
uint32_t StreamEncoderImpl::bufferLimit() { return connection_.bufferLimit(); }

const Network::Address::InstanceConstSharedPtr& StreamEncoderImpl::connectionLocalAddress() {
return connection_.connection().addressProvider().localAddress();
return connection_.connection().connectionInfoProvider().localAddress();
}

static const char RESPONSE_PREFIX[] = "HTTP/1.1 ";
Expand Down
2 changes: 1 addition & 1 deletion source/common/http/http2/codec_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class ConnectionImpl : public virtual Connection,
void readDisable(bool disable) override;
uint32_t bufferLimit() override { return pending_recv_data_->highWatermark(); }
const Network::Address::InstanceConstSharedPtr& connectionLocalAddress() override {
return parent_.connection_.addressProvider().localAddress();
return parent_.connection_.connectionInfoProvider().localAddress();
}
absl::string_view responseDetails() override { return details_; }
void setAccount(Buffer::BufferMemoryAccountSharedPtr account) override;
Expand Down
4 changes: 2 additions & 2 deletions source/common/network/base_listener_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespace Network {

BaseListenerImpl::BaseListenerImpl(Event::DispatcherImpl& dispatcher, SocketSharedPtr socket)
: local_address_(nullptr), dispatcher_(dispatcher), socket_(std::move(socket)) {
const auto ip = socket_->addressProvider().localAddress()->ip();
const auto ip = socket_->connectionInfoProvider().localAddress()->ip();

// Only use the listen socket's local address for new connections if it is not the all hosts
// address (e.g., 0.0.0.0 for IPv4).
if (!(ip && ip->isAnyAddress())) {
local_address_ = socket_->addressProvider().localAddress();
local_address_ = socket_->connectionInfoProvider().localAddress();
}
}

Expand Down
15 changes: 8 additions & 7 deletions source/common/network/connection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ ConnectionImpl::ConnectionImpl(Event::Dispatcher& dispatcher, ConnectionSocketPt

// TODO(soulxu): generate the connection id inside the addressProvider directly,
// then we don't need a setter or any of the optional stuff.
socket_->addressProvider().setConnectionID(id());
socket_->addressProvider().setSslConnection(transport_socket_->ssl());
socket_->connectionInfoProvider().setConnectionID(id());
socket_->connectionInfoProvider().setSslConnection(transport_socket_->ssl());
}

ConnectionImpl::~ConnectionImpl() {
Expand Down Expand Up @@ -836,7 +836,7 @@ ClientConnectionImpl::ClientConnectionImpl(
const Network::ConnectionSocket::OptionsSharedPtr& options)
: ConnectionImpl(dispatcher, std::make_unique<ClientSocketImpl>(remote_address, options),
std::move(transport_socket), stream_info_, false),
stream_info_(dispatcher.timeSource(), socket_->addressProviderSharedPtr()) {
stream_info_(dispatcher.timeSource(), socket_->connectionInfoProviderSharedPtr()) {
// There are no meaningful socket options or source address semantics for
// non-IP sockets, so skip.
if (remote_address->ip() == nullptr) {
Expand All @@ -854,8 +854,8 @@ ClientConnectionImpl::ClientConnectionImpl(

const Network::Address::InstanceConstSharedPtr* source = &source_address;

if (socket_->addressProvider().localAddress()) {
source = &socket_->addressProvider().localAddress();
if (socket_->connectionInfoProvider().localAddress()) {
source = &socket_->connectionInfoProvider().localAddress();
}

if (*source != nullptr) {
Expand All @@ -877,8 +877,9 @@ ClientConnectionImpl::ClientConnectionImpl(

void ClientConnectionImpl::connect() {
ENVOY_CONN_LOG(debug, "connecting to {}", *this,
socket_->addressProvider().remoteAddress()->asString());
const Api::SysCallIntResult result = socket_->connect(socket_->addressProvider().remoteAddress());
socket_->connectionInfoProvider().remoteAddress()->asString());
const Api::SysCallIntResult result =
socket_->connect(socket_->connectionInfoProvider().remoteAddress());
if (result.return_value_ == 0) {
// write will become ready.
ASSERT(connecting_);
Expand Down
8 changes: 4 additions & 4 deletions source/common/network/connection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class ConnectionImpl : public ConnectionImplBase, public TransportSocketCallback
void readDisable(bool disable) override;
void detectEarlyCloseWhenReadDisabled(bool value) override { detect_early_close_ = value; }
bool readEnabled() const override;
const ConnectionInfoProvider& addressProvider() const override {
return socket_->addressProvider();
const ConnectionInfoProvider& connectionInfoProvider() const override {
return socket_->connectionInfoProvider();
}
ConnectionInfoProviderSharedPtr addressProviderSharedPtr() const override {
return socket_->addressProviderSharedPtr();
ConnectionInfoProviderSharedPtr connectionInfoProviderSharedPtr() const override {
return socket_->connectionInfoProviderSharedPtr();
}
absl::optional<UnixDomainSocketPeerCredentials> unixSocketPeerCredentials() const override;
Ssl::ConnectionInfoConstSharedPtr ssl() const override { return transport_socket_->ssl(); }
Expand Down
2 changes: 1 addition & 1 deletion source/common/network/filter_matcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ListenerFilterDstPortMatcher final : public ListenerFilterMatcher {
explicit ListenerFilterDstPortMatcher(const ::envoy::type::v3::Int32Range& range)
: start_(range.start()), end_(range.end()) {}
bool matches(ListenerFilterCallbacks& cb) const override {
const auto& address = cb.socket().addressProvider().localAddress();
const auto& address = cb.socket().connectionInfoProvider().localAddress();
// Match on destination port (only for IP addresses).
if (address->type() == Address::Type::Ip) {
const auto port = address->ip()->port();
Expand Down
9 changes: 5 additions & 4 deletions source/common/network/happy_eyeballs_connection_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ bool HappyEyeballsConnectionImpl::readEnabled() const {
return connections_[0]->readEnabled();
}

const ConnectionInfoProvider& HappyEyeballsConnectionImpl::addressProvider() const {
return connections_[0]->addressProvider();
const ConnectionInfoProvider& HappyEyeballsConnectionImpl::connectionInfoProvider() const {
return connections_[0]->connectionInfoProvider();
}

ConnectionInfoProviderSharedPtr HappyEyeballsConnectionImpl::addressProviderSharedPtr() const {
return connections_[0]->addressProviderSharedPtr();
ConnectionInfoProviderSharedPtr
HappyEyeballsConnectionImpl::connectionInfoProviderSharedPtr() const {
return connections_[0]->connectionInfoProviderSharedPtr();
}

absl::optional<Connection::UnixDomainSocketPeerCredentials>
Expand Down
4 changes: 2 additions & 2 deletions source/common/network/happy_eyeballs_connection_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class HappyEyeballsConnectionImpl : public ClientConnection {
bool isHalfCloseEnabled() override;
std::string nextProtocol() const override;
// Note, this might change before connect finishes.
const ConnectionInfoProvider& addressProvider() const override;
const ConnectionInfoProvider& connectionInfoProvider() const override;
// Note, this might change before connect finishes.
ConnectionInfoProviderSharedPtr addressProviderSharedPtr() const override;
ConnectionInfoProviderSharedPtr connectionInfoProviderSharedPtr() const override;
// Note, this might change before connect finishes.
absl::optional<UnixDomainSocketPeerCredentials> unixSocketPeerCredentials() const override;
// Note, this might change before connect finishes.
Expand Down
4 changes: 2 additions & 2 deletions source/common/network/listen_socket_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ class ConnectionSocketImpl : public SocketImpl, public ConnectionSocket {

void setRequestedServerName(absl::string_view server_name) override {
// Always keep the server_name_ as lower case.
addressProvider().setRequestedServerName(absl::AsciiStrToLower(server_name));
connectionInfoProvider().setRequestedServerName(absl::AsciiStrToLower(server_name));
}
absl::string_view requestedServerName() const override {
return addressProvider().requestedServerName();
return connectionInfoProvider().requestedServerName();
}

absl::optional<std::chrono::milliseconds> lastRoundTripTime() override {
Expand Down
8 changes: 5 additions & 3 deletions source/common/network/socket_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ class SocketImpl : public virtual Socket {
const Address::InstanceConstSharedPtr& remote_address);

// Network::Socket
ConnectionInfoSetter& addressProvider() override { return *address_provider_; }
const ConnectionInfoProvider& addressProvider() const override { return *address_provider_; }
ConnectionInfoProviderSharedPtr addressProviderSharedPtr() const override {
ConnectionInfoSetter& connectionInfoProvider() override { return *address_provider_; }
const ConnectionInfoProvider& connectionInfoProvider() const override {
return *address_provider_;
}
ConnectionInfoProviderSharedPtr connectionInfoProviderSharedPtr() const override {
return address_provider_;
}
SocketPtr duplicate() override {
Expand Down
4 changes: 2 additions & 2 deletions source/common/network/udp_listener_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void UdpListenerImpl::handleReadCallback() {
ENVOY_UDP_LOG(trace, "handleReadCallback");
cb_.onReadReady();
const Api::IoErrorPtr result = Utility::readPacketsFromSocket(
socket_->ioHandle(), *socket_->addressProvider().localAddress(), *this, time_source_,
socket_->ioHandle(), *socket_->connectionInfoProvider().localAddress(), *this, time_source_,
config_.prefer_gro_, packets_dropped_);
if (result == nullptr) {
// No error. The number of reads was limited by read rate. There are more packets to read.
Expand Down Expand Up @@ -102,7 +102,7 @@ void UdpListenerImpl::handleWriteCallback() {
Event::Dispatcher& UdpListenerImpl::dispatcher() { return dispatcher_; }

const Address::InstanceConstSharedPtr& UdpListenerImpl::localAddress() const {
return socket_->addressProvider().localAddress();
return socket_->connectionInfoProvider().localAddress();
}

Api::IoCallUint64Result UdpListenerImpl::send(const UdpSendData& send_data) {
Expand Down
4 changes: 2 additions & 2 deletions source/common/network/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ bool Utility::isSameIpOrLoopback(const ConnectionSocket& socket) {
// - Pipes
// - Sockets to a loopback address
// - Sockets where the local and remote address (ignoring port) are the same
const auto& remote_address = socket.addressProvider().remoteAddress();
const auto& remote_address = socket.connectionInfoProvider().remoteAddress();
if (remote_address->type() == Address::Type::Pipe || isLoopbackAddress(*remote_address)) {
return true;
}
const auto local_ip = socket.addressProvider().localAddress()->ip();
const auto local_ip = socket.connectionInfoProvider().localAddress()->ip();
const auto remote_ip = remote_address->ip();
if (remote_ip != nullptr && local_ip != nullptr &&
remote_ip->addressAsString() == local_ip->addressAsString()) {
Expand Down
15 changes: 8 additions & 7 deletions source/common/quic/envoy_quic_client_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ EnvoyQuicClientConnection::EnvoyQuicClientConnection(
Network::ConnectionSocketPtr&& connection_socket)
: quic::QuicConnection(server_connection_id, quic::QuicSocketAddress(),
envoyIpAddressToQuicSocketAddress(
connection_socket->addressProvider().remoteAddress()->ip()),
connection_socket->connectionInfoProvider().remoteAddress()->ip()),
&helper, &alarm_factory, writer, owns_writer,
quic::Perspective::IS_CLIENT, supported_versions),
QuicNetworkConnection(std::move(connection_socket)), dispatcher_(dispatcher) {}
Expand Down Expand Up @@ -95,10 +95,10 @@ void EnvoyQuicClientConnection::switchConnectionSocket(
Network::ConnectionSocketPtr&& connection_socket) {
auto writer = std::make_unique<EnvoyQuicPacketWriter>(
std::make_unique<Network::UdpDefaultWriter>(connection_socket->ioHandle()));
quic::QuicSocketAddress self_address =
envoyIpAddressToQuicSocketAddress(connection_socket->addressProvider().localAddress()->ip());
quic::QuicSocketAddress peer_address =
envoyIpAddressToQuicSocketAddress(connection_socket->addressProvider().remoteAddress()->ip());
quic::QuicSocketAddress self_address = envoyIpAddressToQuicSocketAddress(
connection_socket->connectionInfoProvider().localAddress()->ip());
quic::QuicSocketAddress peer_address = envoyIpAddressToQuicSocketAddress(
connection_socket->connectionInfoProvider().remoteAddress()->ip());

// The old socket is closed in this call.
setConnectionSocket(std::move(connection_socket));
Expand All @@ -124,8 +124,9 @@ void EnvoyQuicClientConnection::onFileEvent(uint32_t events) {
// right default for QUIC. Determine whether this should be configurable or not.
if (connected() && (events & Event::FileReadyType::Read)) {
Api::IoErrorPtr err = Network::Utility::readPacketsFromSocket(
connectionSocket()->ioHandle(), *connectionSocket()->addressProvider().localAddress(),
*this, dispatcher_.timeSource(), true, packets_dropped_);
connectionSocket()->ioHandle(),
*connectionSocket()->connectionInfoProvider().localAddress(), *this,
dispatcher_.timeSource(), true, packets_dropped_);
if (err == nullptr) {
connectionSocket()->ioHandle().activateFileEvents(Event::FileReadyType::Read);
return;
Expand Down
2 changes: 1 addition & 1 deletion source/common/quic/envoy_quic_server_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool EnvoyQuicServerConnection::OnPacketHeader(const quic::QuicPacketHeader& hea
}
// Update local address if QUICHE has updated the self address.
ASSERT(self_address().IsInitialized());
connectionSocket()->addressProvider().setLocalAddress(
connectionSocket()->connectionInfoProvider().setLocalAddress(
quicAddressToEnvoyAddressInstance(self_address()));

return true;
Expand Down
2 changes: 1 addition & 1 deletion source/common/quic/envoy_quic_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class EnvoyQuicStream : public virtual Http::StreamEncoder,
}
uint32_t bufferLimit() override { return send_buffer_simulation_.highWatermark(); }
const Network::Address::InstanceConstSharedPtr& connectionLocalAddress() override {
return connection()->addressProvider().localAddress();
return connection()->connectionInfoProvider().localAddress();
}

void setAccount(Buffer::BufferMemoryAccountSharedPtr account) override {
Expand Down
Loading