Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Klein <mklein@lyft.com>
  • Loading branch information
mattklein123 committed Jan 6, 2021
1 parent 69248a8 commit 0ed22d8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/common/network/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ envoy_cc_library(
"//include/envoy/network:socket_interface_interface",
"//source/common/api:os_sys_calls_lib",
"//source/common/common:assert_lib",
"//source/common/common:dump_state_utils",
"//source/common/common:utility_lib",
],
)
Expand All @@ -248,7 +249,6 @@ envoy_cc_library(
"//include/envoy/network:exception_interface",
"//include/envoy/network:listen_socket_interface",
"//source/common/common:assert_lib",
"//source/common/common:dump_state_utils",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
],
)
Expand Down
8 changes: 3 additions & 5 deletions source/common/network/listen_socket_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ class ConnectionSocketImpl : public SocketImpl, public ConnectionSocket {

void dumpState(std::ostream& os, int indent_level) const override {
const char* spaces = spacesForLevel(indent_level);
os << spaces << "ListenSocketImpl " << this
<< DUMP_NULLABLE_MEMBER(remote_address_, remote_address_->asStringView())
<< DUMP_NULLABLE_MEMBER(direct_remote_address_, direct_remote_address_->asStringView())
<< DUMP_NULLABLE_MEMBER(local_address_, local_address_->asStringView())
<< DUMP_MEMBER(transport_protocol_) << DUMP_MEMBER(server_name_) << "\n";
os << spaces << "ListenSocketImpl " << this << DUMP_MEMBER(transport_protocol_)
<< DUMP_MEMBER(server_name_) << "\n";
DUMP_DETAILS(address_provider_);
}

protected:
Expand Down
11 changes: 10 additions & 1 deletion source/common/network/socket_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "envoy/network/socket.h"

#include "common/common/assert.h"
#include "common/common/dump_state_utils.h"

namespace Envoy {
namespace Network {
Expand All @@ -18,6 +19,14 @@ class SocketAddressSetterImpl : public SocketAddressSetter {
direct_remote_address_ = direct_remote_address;
}

void dumpState(std::ostream& os, int indent_level) const {
const char* spaces = spacesForLevel(indent_level);
os << spaces << "SocketAddressSetterImpl " << this
<< DUMP_NULLABLE_MEMBER(remote_address_, remote_address_->asStringView())
<< DUMP_NULLABLE_MEMBER(direct_remote_address_, direct_remote_address_->asStringView())
<< DUMP_NULLABLE_MEMBER(local_address_, local_address_->asStringView()) << "\n";
}

// SocketAddressSetter
const Address::InstanceConstSharedPtr& localAddress() const override { return local_address_; }
void setLocalAddress(const Address::InstanceConstSharedPtr& local_address) override {
Expand Down Expand Up @@ -101,7 +110,7 @@ class SocketImpl : public virtual Socket {
const Address::InstanceConstSharedPtr& remote_address);

const IoHandlePtr io_handle_;
const SocketAddressSetterSharedPtr address_provider_;
const std::shared_ptr<SocketAddressSetterImpl> address_provider_;
OptionsSharedPtr options_;
Socket::Type sock_type_;
Address::Type addr_type_;
Expand Down
13 changes: 8 additions & 5 deletions test/common/network/connection_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1886,18 +1886,21 @@ TEST_P(ConnectionImplTest, NetworkSocketDumpsWithoutAllocatingMemory) {
EXPECT_EQ(memory_test.consumedBytes(), 0);

// Check socket dump
EXPECT_THAT(ostream.contents(), HasSubstr("ListenSocketImpl"));
const auto contents = ostream.contents();
EXPECT_THAT(contents, HasSubstr("ListenSocketImpl"));
EXPECT_THAT(contents, HasSubstr("transport_protocol_: , server_name_: envoyproxy.io"));
EXPECT_THAT(contents, HasSubstr("SocketAddressSetterImpl"));
if (GetParam() == Network::Address::IpVersion::v4) {
EXPECT_THAT(
ostream.contents(),
contents,
HasSubstr(
"remote_address_: 1.1.1.1:80, direct_remote_address_: 1.1.1.1:80, local_address_: "
"1.2.3.4:56789, transport_protocol_: , server_name_: envoyproxy.io"));
"1.2.3.4:56789"));
} else {
EXPECT_THAT(
ostream.contents(),
contents,
HasSubstr("remote_address_: [::1]:80, direct_remote_address_: [::1]:80, local_address_: "
"[::1:2:3:4]:56789, transport_protocol_: , server_name_: envoyproxy.io"));
"[::1:2:3:4]:56789"));
}
}

Expand Down

0 comments on commit 0ed22d8

Please sign in to comment.