-
Notifications
You must be signed in to change notification settings - Fork 5.1k
listener: Add support for listener socket options. #2519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
listener: Add support for listener socket options. #2519
Conversation
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>
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_); |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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.
test/mocks/server/mocks.cc
Outdated
@@ -137,6 +137,10 @@ MockTransportSocketFactoryContext::MockTransportSocketFactoryContext() {} | |||
|
|||
MockTransportSocketFactoryContext::~MockTransportSocketFactoryContext() {} | |||
|
|||
MockListenerFactoryContext::MockListenerFactoryContext() {} | |||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicely done, thanks.
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
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