Skip to content

connection handler: support multiple addresses in listener#21521

Merged
adisuissa merged 21 commits intoenvoyproxy:mainfrom
soulxu:multi_addresses_conn_handler
Jun 18, 2022
Merged

connection handler: support multiple addresses in listener#21521
adisuissa merged 21 commits intoenvoyproxy:mainfrom
soulxu:multi_addresses_conn_handler

Conversation

@soulxu
Copy link
Copy Markdown
Member

@soulxu soulxu commented Jun 1, 2022

Commit Message: connection handler: support multiple addresses in listener
Additional Description:
This PR adds new interface listenSocketFactories() to the ListenerConfig. Since when the Listener supports multiple addresses, there will be multiple socket factories.

The ConnectionHandlerImpl will create an active listener for each socket in the listener, and manipulate all the active listeners belonging to the same listener together.

For the full picture, please reference #19367, this PR is primarily separated from this commit 7fa7666

Risk Level: high
Testing: unittest
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: no
Part of Fixes: #11184

soulxu added 8 commits June 1, 2022 01:28
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>

quic: remove useless constructor

Signed-off-by: He Jie Xu <hejie.xu@intel.com>

udp: remove useless constructor

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Jun 1, 2022

@adisuissa @ggreenway @mattklein123 I changed the ListenerConfig's interface, then it touch more files. I can separate that out also if you think that is better for review.

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@mattklein123 mattklein123 self-assigned this Jun 2, 2022
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Comment thread test/per_file_coverage.sh Outdated
soulxu added 3 commits June 6, 2022 01:16
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu soulxu requested a review from adisuissa as a code owner June 6, 2022 06:48
@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Jun 6, 2022

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #21521 (comment) was created by @soulxu.

see: more, trace.

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Jun 9, 2022

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #21521 (comment) was created by @soulxu.

see: more, trace.

Copy link
Copy Markdown
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 with small comment comment, thanks.

/wait

Comment thread test/per_file_coverage.sh Outdated
Comment thread envoy/network/listener.h
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Overall LGTM, thanks!
Left a couple of small comments

Comment thread source/server/listener_impl.cc
Comment thread source/server/listener_impl.h
mattklein123
mattklein123 previously approved these changes Jun 15, 2022
Copy link
Copy Markdown
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, will defer to @adisuissa for final review and merge.

@mattklein123 mattklein123 removed their assignment Jun 15, 2022
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Mostly small nits.

Network::FilterChainFactory& filterChainFactory() override { return parent_; }
Network::ListenSocketFactory& listenSocketFactory() override {
return *parent_.socket_factory_;
return *parent_.socket_factories_[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we have an assert here that the number of socket factories is 1?

Copy link
Copy Markdown
Member Author

@soulxu soulxu Jun 17, 2022

Choose a reason for hiding this comment

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

yes, let me add one

auto details = std::make_shared<ActiveListenerDetails>();
auto details = std::make_unique<ActiveListenerDetails>();
if (config.internalListenerConfig().has_value()) {
auto pre_address_details = std::make_shared<PerAddressActiveListenerDetails>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is this being used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Emm...it should be something I forget to remove when refactor the code

Comment on lines +69 to +70
// TODO(soulxu): support multiple internal addresses in listener in the future.
ASSERT(config.listenSocketFactories().size() == 1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this assert true also before the enclosing if scope?
Seeing the else if statement on line 73 suggests that this is true, but not sure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is for the multiple addresses doesn't support internal address. In the late PR, the API will reject multiple internal addresses, so I have the assertion here.

tcp_listener_map_by_address_.insert_or_assign(v4_compatible_addr->asStringView(),
details);
for (auto& per_address_details : details->per_address_details_list_) {
// This map only store the new listener.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// This map only store the new listener.
// This map only stores the new listener.

} else if (absl::holds_alternative<std::reference_wrapper<Network::InternalListener>>(
per_address_details->typed_listener_)) {
internal_listener_map_by_address_.insert_or_assign(
per_address_details->address_->asStringView(), per_address_details);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note that the use of pre_address_details and per_address_details is somewhat tricky and makes the code harder to read, so if one can use a completely different name for one of these it would be better.

Copy link
Copy Markdown
Member Author

@soulxu soulxu Jun 17, 2022

Choose a reason for hiding this comment

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

oops, pre_address_details should be a typo, sorry about that. I will use per_address_details for item name. But let me know if this isn't what you pointed to.

// both "::FFFF:<ipv4-addr>" with ipv4_compat and "<ipv4-addr>" isn't valid case,
// remove the v4 compatible addr item directly.
tcp_listener_map_by_address_.erase(v4_compatible_addr->asStringView());
for (auto& per_address_details : listener_iter->second->per_address_details_list_) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: can per_address_details be const?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, it can be, let me update


using ListenerMethodFn = std::function<void(Network::ConnectionHandler::ActiveListener&)>;

void invokeListenerMethod(ListenerMethodFn fn) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add some comments to public methods (helps when looking with an IDE and trying to understand what this is doing)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

got it

if (v4_compatible_addr != nullptr) {
tcp_listener_map_by_address_.insert_or_assign(v4_compatible_addr->asStringView(),
details);
for (auto& per_address_details : details->per_address_details_list_) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I may have missed it, but is there a test that adds more than one listener?
Maybe this is planned as part of the next PRs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry, I forget to cherry-pick that commit. Let me append that to this PR

soulxu added 3 commits June 17, 2022 05:58
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Overall LGTM.
CI says admin.h coverage needs to be improved.

See if you may be able to improve connection_handler_impl.cc coverage. This may be deferred for a later PR.

/wait

soulxu added 3 commits June 17, 2022 23:27
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Jun 18, 2022

Thanks!

Overall LGTM. CI says admin.h coverage needs to be improved.

This is probably due to we adding one more assertion in the code, https://github.com/envoyproxy/envoy/pull/21521/files#diff-bdab5025c9978c2b063cc88f0ec2a1b7bf2efe9f24bd8a1ed1761d22cf27ddb5L392

I think there is no dependence on listenSocketFactory() method for admin API anymore, that is why the coverage becomes lower.

I will try to raise the coverage back after listenerSocketFactory method is gone https://github.com/envoyproxy/envoy/pull/21521/files#diff-0ac04ef31c616358d8234bd473469c1a233ecf37947a13475cce764e7f6c43ee

See if you may be able to improve connection_handler_impl.cc coverage. This may be deferred for a later PR.

I added two more tests for Internal Listener and Tcp listener in-place update with runtime flag envoy.reloadable_features.udp_listener_updates_filter_chain_in_place as false

May I ask where I can find the coverage report link? although I can modify the URL to get different PR, but I guess there should be an entry I didn't know.
I only find the main branch link https://storage.googleapis.com/envoy-postsubmit/main/coverage/index.html

@adisuissa
Copy link
Copy Markdown
Contributor

May I ask where I can find the coverage report link? although I can modify the URL to get different PR, but I guess there should be an entry I didn't know. I only find the main branch link https://storage.googleapis.com/envoy-postsubmit/main/coverage/index.html

Using the azure-pipelines. See more details in doc.

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa 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!

@adisuissa adisuissa merged commit d1d7d2d into envoyproxy:main Jun 18, 2022
@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Jun 18, 2022

May I ask where I can find the coverage report link? although I can modify the URL to get different PR, but I guess there should be an entry I didn't know. I only find the main branch link https://storage.googleapis.com/envoy-postsubmit/main/coverage/index.html

Using the azure-pipelines. See more details in doc.

Thanks!

Amila-Rukshan pushed a commit to Amila-Rukshan/envoy that referenced this pull request Jun 28, 2022
…y#21521)

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: Amila Senadheera <amila.15@cse.mrt.ac.lk>
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.

Support multiple addresses per listener

3 participants