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
1 change: 1 addition & 0 deletions source/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ envoy_cc_library(
"//include/envoy/network:listener_interface",
"//include/envoy/server:listener_manager_interface",
"//include/envoy/stats:timespan_interface",
"//source/common/common:assert_lib",
"//source/common/common:linked_object",
"//source/common/common:non_copyable",
"//source/common/common:safe_memcpy_lib",
Expand Down
19 changes: 14 additions & 5 deletions source/server/active_tcp_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "envoy/network/filter.h"
#include "envoy/stats/scope.h"

#include "common/common/assert.h"
#include "common/event/deferred_task.h"
#include "common/network/connection_impl.h"
#include "common/network/utility.h"
Expand Down Expand Up @@ -214,8 +215,9 @@ void ActiveTcpSocket::newConnection() {

void ActiveTcpListener::onAccept(Network::ConnectionSocketPtr&& socket) {
if (listenerConnectionLimitReached()) {
ENVOY_LOG(trace, "closing connection: listener connection limit reached for {}",
config_->name());
RELEASE_ASSERT(socket->addressProvider().remoteAddress() != nullptr, "");
ENVOY_LOG(trace, "closing connection from {}: listener connection limit reached for {}",
socket->addressProvider().remoteAddress()->asString(), config_->name());
socket->close();
stats_.downstream_cx_overflow_.inc();
return;
Expand Down Expand Up @@ -292,7 +294,9 @@ void ActiveTcpListener::newConnection(Network::ConnectionSocketPtr&& socket,
// Find matching filter chain.
const auto filter_chain = config_->filterChainManager().findFilterChain(*socket);
if (filter_chain == nullptr) {
ENVOY_LOG(debug, "closing connection: no matching filter chain found");
RELEASE_ASSERT(socket->addressProvider().remoteAddress() != nullptr, "");
ENVOY_LOG(debug, "closing connection from {}: no matching filter chain found",
socket->addressProvider().remoteAddress()->asString());
stats_.no_filter_chain_match_.inc();
stream_info->setResponseFlag(StreamInfo::ResponseFlag::NoRouteFound);
stream_info->setResponseCodeDetails(StreamInfo::ResponseCodeDetails::get().FilterChainNotFound);
Expand All @@ -311,21 +315,26 @@ void ActiveTcpListener::newConnection(Network::ConnectionSocketPtr&& socket,
timeout != std::chrono::milliseconds::zero()) {
server_conn_ptr->setTransportSocketConnectTimeout(timeout);
}

ActiveTcpConnectionPtr active_connection(
new ActiveTcpConnection(active_connections, std::move(server_conn_ptr),
parent_.dispatcher().timeSource(), std::move(stream_info)));
active_connection->connection_->setBufferLimits(config_->perConnectionBufferLimitBytes());

RELEASE_ASSERT(active_connection->connection_->addressProvider().remoteAddress() != nullptr, "");

const bool empty_filter_chain = !config_->filterChainFactory().createNetworkFilterChain(
*active_connection->connection_, filter_chain->networkFilterFactories());
if (empty_filter_chain) {
ENVOY_CONN_LOG(debug, "closing connection: no filters", *active_connection->connection_);
ENVOY_CONN_LOG(debug, "closing connection from {}: no filters", *active_connection->connection_,
active_connection->connection_->addressProvider().remoteAddress()->asString());
active_connection->connection_->close(Network::ConnectionCloseType::NoFlush);
}

// If the connection is already closed, we can just let this connection immediately die.
if (active_connection->connection_->state() != Network::Connection::State::Closed) {
ENVOY_CONN_LOG(debug, "new connection", *active_connection->connection_);
ENVOY_CONN_LOG(debug, "new connection from {}", *active_connection->connection_,
active_connection->connection_->addressProvider().remoteAddress()->asString());
active_connection->connection_->addConnectionCallbacks(*active_connection);
LinkedList::moveIntoList(std::move(active_connection), active_connections.connections_);
}
Expand Down