Skip to content

Conversation

lambdai
Copy link
Contributor

@lambdai lambdai commented Jul 10, 2019

Signed-off-by: Yuchen Dai silentdai@gmail.com

Description:
ListenerFactoryContext is mainly used by NetworkFilter and ListenerFilterto access Listener.
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

Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@lambdai
Copy link
Contributor Author

lambdai commented Jul 10, 2019

@klarose @jrajahalme @mattklein123
Also CC @htuch who introduced addListenSocketOptions in #2922 to support IP_FREEBIND

@lambdai lambdai marked this pull request as ready for review July 10, 2019 23:58
@mattklein123 mattklein123 self-assigned this Jul 11, 2019
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.

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
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Contributor Author

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));
Copy link
Contributor Author

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

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()));
}
is why OriginalDstListenerFilter(as well as other ListenerFilters) no longer need addListenSocketOption in ListenerFactoryContext

Copy link
Member

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>
@lambdai
Copy link
Contributor Author

lambdai commented Jul 11, 2019

@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?

htuch pushed a commit that referenced this pull request Jul 12, 2019
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>
@lambdai
Copy link
Contributor Author

lambdai commented Jul 15, 2019

@jrajahalme Sorry to involve you in this PR. It's would be nice to have your confirm. Thanks!

@jrajahalme
Copy link
Contributor

@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?

@jrajahalme
Copy link
Contributor

OK, I looked through the core.SocketOption docs, and this looks pretty straightforward. Will try this out.

@jrajahalme
Copy link
Contributor

@silentdai Changed Cilium to set the option in listener config instead (cilium/cilium/pull/8581), so I'm fine with this PR being merged :-)

@lambdai
Copy link
Contributor Author

lambdai commented Jul 17, 2019

@jrajahalme Thanks! Will take a look at https://github.com/cilium/proxy/tree/master/cilium as well when I make further changes.
@mattklein123 Do you have other concerns?

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, thank you!

@mattklein123 mattklein123 merged commit 170c89e into envoyproxy:master Jul 18, 2019
TAOXUY pushed a commit to TAOXUY/envoy that referenced this pull request Jul 22, 2019
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
@jrajahalme
Copy link
Contributor

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does any filter need addListenSocketOption[s]?
3 participants