-
Notifications
You must be signed in to change notification settings - Fork 5.1k
listener: keep ListenerFactoryContext small #7528
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
Conversation
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@klarose @jrajahalme @mattklein123 |
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.
Thanks, LGTM with some questions.
/wait
@@ -2686,30 +2686,12 @@ class OriginalDstTestFilter : public Extensions::ListenerFilters::OriginalDst::O | |||
}; | |||
|
|||
TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstTestFilter) { | |||
// Static scope required for the io_handle to be in scope for the lambda below |
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.
I'm a little concerned that we are losing some test coverage that matters here. Are you positive that this is not being used by existing listener filters? I'm not convinced. Can you see who added these tests and ask them?
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.
I remove the two functions from ListenerFactoryContext
and the build is successful. That's the proof that no listener filter in the code tree is using it. Unfortunately I can never verify if private code is using ... and that is the linked issue for
@@ -2686,30 +2686,12 @@ class OriginalDstTestFilter : public Extensions::ListenerFilters::OriginalDst::O | |||
}; | |||
|
|||
TEST_F(ListenerManagerImplWithRealFiltersTest, OriginalDstTestFilter) { | |||
// Static scope required for the io_handle to be in scope for the lambda below |
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.
I remove the two functions from ListenerFactoryContext
and the build is successful. That's the proof that no listener filter in the code tree is using it. Unfortunately I can never verify if private code is using ... and that is the linked issue for
fd = socket.ioHandle().fd(); | ||
return true; | ||
})); | ||
context.addListenSocketOption(std::move(option)); |
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.
@mattklein123 The tricky test is verifying if createFilterFactoryFromProto
is called but delegating it to ListenerFactoryContext::addListenSocketOption
. This might be reasonable in the past but is not appropriate at this moment.
BTW I think
envoy/source/server/listener_manager_impl.cc
Lines 208 to 217 in 1ca1d13
if (config.has_transparent()) { | |
addListenSocketOptions(Network::SocketOptionFactory::buildIpTransparentOptions()); | |
} | |
if (config.has_freebind()) { | |
addListenSocketOptions(Network::SocketOptionFactory::buildIpFreebindOptions()); | |
} | |
if (!config.socket_options().empty()) { | |
addListenSocketOptions( | |
Network::SocketOptionFactory::buildLiteralOptions(config.socket_options())); | |
} |
ListenerFactoryContext
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.
I'm still concerned that people may have private listener filters that are using this and won't be able to now. Can you see who added the tests that you changed and ask them?
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@jrajahalme The initial socket option changes in original dst listener filter was initiated by you in #2519 Could you confirm that it is not needed at the current code base? |
As noted in #7528 the newly added sanity checking of possibly sensitive file paths prevents legitimate usage of passing bootstrap via a non-CLOEXEC file descriptor from a generator helper that execs Envoy. This PR relaxes the validation such that any path resolving to a canonical path with the prefix /dev/fd/ is considered valid. Risk Level: Low Testing: Unit test case is added that was failing before the change and passes afterwards. In addition I've manually verified that the old behaviour of allowing /dev/fd/ paths works with my dev binary. Fixes #7258 Signed-off-by: Paul Banks <banks@banksco.de>
@jrajahalme Sorry to involve you in this PR. It's would be nice to have your confirm. Thanks! |
@silentdai Thanks for the heads-up! Unfortunately we currently depend on the functionality being removed here in the Cilium proxy (github.com/cilium/proxy) :-( It will take some time for me to figure out how to replace it with the listener config proto. I think it should be doable, as the option and the value are derived from the listener filter configuration. To expedite this, maybe you could give a hint how to set the Linux SO_MARK (socket mark option) using the listener config proto? |
OK, I looked through the |
@silentdai Changed Cilium to set the option in listener config instead (cilium/cilium/pull/8581), so I'm fine with this PR being merged :-) |
@jrajahalme Thanks! Will take a look at https://github.com/cilium/proxy/tree/master/cilium as well when I make further changes. |
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, thank you!
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@lambdai @mattklein123 This change is now coming to haunt me... I need to add a listen socket option that has a non-standard implementation, so that the current Listener config options are not enough. Would there be any appetite for reverting this change? |
Signed-off-by: Yuchen Dai silentdai@gmail.com
Description:
ListenerFactoryContext
is mainly used byNetworkFilter
andListenerFilter
to accessListener
.Code base evolved and there is no use case to add listen socket options.
Instead, listener options should be added by Listener config proto
The existing usage are left in listener test to inject failure, probably fit the code in the past but should never seen in current code flow.
Risk Level: LOW
Testing: Modified tests
Fixes #7467