Skip to content

Conversation

jrajahalme
Copy link
Contributor

@jrajahalme jrajahalme commented Feb 2, 2018

Allow listener filters to set socket options to be set on the
listening socket.

To be able to set the options at the right time in the listener life cycle,
a setListenSocketOptions() call is added to listener factory context.

Instead of replicating more of the Network::ConnectionSocket
functionality in the Network::ListenSocket, Network::ListenSocket is
renamed as Network::Socket and used as the base class of
Network::ConnectionSocket.

Signed-off-by: Jarno Rajahalme jarno@covalent.io
Risk Level: Low

Allow listener filters to set socket options to be set on the
listening socket.

Instead of replicating more of the Network::ConnectionSocket
functionality in the Network::ListenSocket, Network::ListenSocket is
renamed as Network::Socket and used as the base class of
Network::ConnectionSocket.

Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks. Few small comments.

remove(uds_path.c_str());
local_address_.reset(new Address::PipeInstance(uds_path));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old code this was done after remove and now it's done before. Does that matter? Or does remove only need to be done before bind potentially?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PipeInstance constructor does not issue any syscalls, so IMO remove() just has to be done before bind().

public:
~ListenSocketImpl() { close(); }
class SocketImpl : public virtual Socket {
protected:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: protected goes below public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

ASSERT(!socket_);
socket_ = socket;
// Server config validation sets nullptr sockets.
if (socket_ && listen_socket_options_) {
bool ok = listen_socket_options_->setOptions(*socket_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this throw or fail in some way? This will also break NVLOG builds, so at minimum needs an UNREFERENCED_PARAMATER(ok);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callers of setSocket throw, so I'll add a throw here.

@@ -137,6 +137,10 @@ MockTransportSocketFactoryContext::MockTransportSocketFactoryContext() {}

MockTransportSocketFactoryContext::~MockTransportSocketFactoryContext() {}

MockListenerFactoryContext::MockListenerFactoryContext() {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: del newline, same at 137

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
ENVOY_LOG(debug, "{}: Setting socket options {}", name_, ok ? "succeeded" : "failed");
const std::string message =
fmt::format("{}: Setting socket options {}", name_, ok ? "succeeded" : "failed");
if (!ok) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have test coverage for both of these cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not, I'll make sure I do. Sorry to make you ask for coverage again...

Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely done, thanks.

@mattklein123 mattklein123 merged commit 8be6ad5 into envoyproxy:master Feb 3, 2018
@jrajahalme jrajahalme deleted the listener-socket-mark branch February 5, 2018 18:15
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants