Skip to content

Commit

Permalink
fix: record recovered local address (#13581)
Browse files Browse the repository at this point in the history
Signed-off-by: Kuat Yessenov <kuat@google.com>
  • Loading branch information
kyessenov authored Oct 19, 2020
1 parent 5c77372 commit 7915659
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions source/server/connection_handler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ void ConnectionHandlerImpl::ActiveTcpListener::resumeListening() {

void ConnectionHandlerImpl::ActiveTcpListener::newConnection(
Network::ConnectionSocketPtr&& socket, std::unique_ptr<StreamInfo::StreamInfo> stream_info) {
// Refresh local address in case it was restored by a listener filter like the original_dst
// filter.
stream_info->setDownstreamLocalAddress(socket->localAddress());

// Find matching filter chain.
const auto filter_chain = config_->filterChainManager().findFilterChain(*socket);
if (filter_chain == nullptr) {
Expand Down
7 changes: 6 additions & 1 deletion test/server/connection_handler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,12 @@ TEST_F(ConnectionHandlerTest, NormalRedirect) {
EXPECT_EQ(1UL, TestUtility::findCounter(stats_store_, "test.downstream_cx_total")->value());
EXPECT_EQ(1UL, TestUtility::findGauge(stats_store_, "test.downstream_cx_active")->value());

EXPECT_CALL(*access_log_, log(_, _, _, _)).Times(1);
EXPECT_CALL(*access_log_, log(_, _, _, _))
.WillOnce(
Invoke([&](const Http::RequestHeaderMap*, const Http::ResponseHeaderMap*,
const Http::ResponseTrailerMap*, const StreamInfo::StreamInfo& stream_info) {
EXPECT_EQ(alt_address, stream_info.downstreamLocalAddress());
}));
connection->close(Network::ConnectionCloseType::NoFlush);
dispatcher_.clearDeferredDeleteList();
EXPECT_EQ(0UL, TestUtility::findGauge(stats_store_, "downstream_cx_active")->value());
Expand Down

0 comments on commit 7915659

Please sign in to comment.