connection handler: support multiple addresses in listener#21521
connection handler: support multiple addresses in listener#21521adisuissa merged 21 commits intoenvoyproxy:mainfrom
Conversation
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>
|
@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>
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>
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
|
/retest |
|
Retrying Azure Pipelines: |
mattklein123
left a comment
There was a problem hiding this comment.
LGTM with small comment comment, thanks.
/wait
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
adisuissa
left a comment
There was a problem hiding this comment.
Overall LGTM, thanks!
Left a couple of small comments
mattklein123
left a comment
There was a problem hiding this comment.
LGTM thanks, will defer to @adisuissa for final review and merge.
adisuissa
left a comment
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
Should we have an assert here that the number of socket factories is 1?
| 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>(); |
There was a problem hiding this comment.
Where is this being used?
There was a problem hiding this comment.
Emm...it should be something I forget to remove when refactor the code
| // TODO(soulxu): support multiple internal addresses in listener in the future. | ||
| ASSERT(config.listenSocketFactories().size() == 1); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| // 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_) { |
There was a problem hiding this comment.
nit: can per_address_details be const?
There was a problem hiding this comment.
yes, it can be, let me update
|
|
||
| using ListenerMethodFn = std::function<void(Network::ConnectionHandler::ActiveListener&)>; | ||
|
|
||
| void invokeListenerMethod(ListenerMethodFn fn) { |
There was a problem hiding this comment.
Please add some comments to public methods (helps when looking with an IDE and trying to understand what this is doing)
| 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_) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Sorry, I forget to cherry-pick that commit. Let me append that to this PR
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>
adisuissa
left a comment
There was a problem hiding this comment.
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
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>
|
Thanks!
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 I will try to raise the coverage back after
I added two more tests for Internal Listener and Tcp listener in-place update with runtime flag 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. |
Using the azure-pipelines. See more details in doc. |
Thanks! |
…y#21521) Signed-off-by: He Jie Xu <hejie.xu@intel.com> Signed-off-by: Amila Senadheera <amila.15@cse.mrt.ac.lk>
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