-
Notifications
You must be signed in to change notification settings - Fork 5.5k
listener: create internal listener #18104
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
Merged
Merged
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
d712a58
socket: add get sockopt for connect
lambdai 1217008
add inteneral listener
lambdai b673747
add inteneral listener
lambdai bc6e8a3
Merge branch 'main' into ilisteneronconnect
lambdai 0361f4a
merge master
lambdai c5e1131
clean up
lambdai 713efa5
Merge branch 'main' into ilisteneronconnect
lambdai da47f12
revert stub for advanced integration test
lambdai 427efc1
cleanup
lambdai d17804a
Merge branch 'main' into ilisteneronconnect
lambdai a6aca89
more
lambdai 6361da0
add new listen socket type for internal listener
lambdai 6d50f2a
WIP: listener address mutated to ip
lambdai 254a12f
add integration test
lambdai 131eaa9
listener: fix duplicate and isOpen of the listener socket
lambdai cb8f53d
add integration test
lambdai dc4116e
stash
lambdai f5692cf
add new test that destroy listener when connections are alive
lambdai 09d023c
add test coverage
lambdai 84300f3
clear duplicated runtime value
lambdai 1b7d26b
sanitize dep
lambdai c58e7d1
few dep
lambdai f8379de
improve coverage
lambdai a77afb0
Merge branch 'main' into ilisteneronconnect
lambdai f6c8fd8
merge fix
lambdai 7af21cf
Merge remote-tracking branch 'me/ilisteneronconnect' into ilisteneron…
lambdai a9d5891
fix format
lambdai d565405
another try windows release assert
lambdai 1605a0d
testcov
lambdai e7f0e50
another death at windows try
lambdai 46d97f5
Merge branch 'main' into ilisteneronconnect
lambdai c4b74e8
ASSERT to ASSERT_TRUE in test
lambdai 41401f4
typo
lambdai 178b70e
revert a test config
lambdai 3f6407b
address comment
lambdai 18a4d07
add test case and address naming
lambdai f5efb17
more validation
lambdai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #include "source/server/active_internal_listener.h" | ||
|
|
||
| #include "envoy/network/filter.h" | ||
| #include "envoy/stats/scope.h" | ||
|
|
||
| #include "source/common/network/address_impl.h" | ||
| #include "source/common/stats/timespan_impl.h" | ||
|
|
||
| #include "active_stream_listener_base.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Server { | ||
|
|
||
| ActiveInternalListener::ActiveInternalListener(Network::ConnectionHandler& conn_handler, | ||
| Event::Dispatcher& dispatcher, | ||
| Network::ListenerConfig& config) | ||
| : OwnedActiveStreamListenerBase( | ||
| conn_handler, dispatcher, | ||
| std::make_unique<ActiveInternalListener::NetworkInternalListener>(), config) {} | ||
|
|
||
| ActiveInternalListener::ActiveInternalListener(Network::ConnectionHandler& conn_handler, | ||
| Event::Dispatcher& dispatcher, | ||
| Network::ListenerPtr listener, | ||
| Network::ListenerConfig& config) | ||
| : OwnedActiveStreamListenerBase(conn_handler, dispatcher, std::move(listener), config) {} | ||
|
|
||
| ActiveInternalListener::~ActiveInternalListener() { | ||
| is_deleting_ = true; | ||
| // Purge sockets that have not progressed to connections. This should only happen when | ||
| // a listener filter stops iteration and never resumes. | ||
| while (!sockets_.empty()) { | ||
| auto removed = sockets_.front()->removeFromList(sockets_); | ||
| dispatcher().deferredDelete(std::move(removed)); | ||
| } | ||
|
|
||
| for (auto& [chain, active_connections] : connections_by_context_) { | ||
| ASSERT(active_connections != nullptr); | ||
| auto& connections = active_connections->connections_; | ||
| while (!connections.empty()) { | ||
| connections.front()->connection_->close(Network::ConnectionCloseType::NoFlush); | ||
| } | ||
|
lambdai marked this conversation as resolved.
|
||
| } | ||
| dispatcher().clearDeferredDeleteList(); | ||
| } | ||
|
|
||
| void ActiveInternalListener::updateListenerConfig(Network::ListenerConfig& config) { | ||
| ENVOY_LOG(trace, "replacing listener ", config_->listenerTag(), " by ", config.listenerTag()); | ||
| config_ = &config; | ||
| } | ||
|
|
||
| void ActiveInternalListener::onAccept(Network::ConnectionSocketPtr&& socket) { | ||
| // Unlike tcp listener, no rebalancer is applied and won't call pickTargetHandler to account | ||
| // connections. | ||
| incNumConnections(); | ||
|
|
||
| auto active_socket = std::make_unique<ActiveTcpSocket>( | ||
| *this, std::move(socket), false /* do not handle off at internal listener */); | ||
|
lambdai marked this conversation as resolved.
Outdated
|
||
|
|
||
| onSocketAccepted(std::move(active_socket)); | ||
| } | ||
|
|
||
| void ActiveInternalListener::newActiveConnection( | ||
| const Network::FilterChain& filter_chain, Network::ServerConnectionPtr server_conn_ptr, | ||
| std::unique_ptr<StreamInfo::StreamInfo> stream_info) { | ||
| auto& active_connections = getOrCreateActiveConnections(filter_chain); | ||
| auto active_connection = | ||
| std::make_unique<ActiveTcpConnection>(active_connections, std::move(server_conn_ptr), | ||
| dispatcher().timeSource(), std::move(stream_info)); | ||
| // If the connection is already closed, we can just let this connection immediately die. | ||
| if (active_connection->connection_->state() != Network::Connection::State::Closed) { | ||
| ENVOY_CONN_LOG( | ||
| debug, "new connection from {}", *active_connection->connection_, | ||
| active_connection->connection_->connectionInfoProvider().remoteAddress()->asString()); | ||
| active_connection->connection_->addConnectionCallbacks(*active_connection); | ||
| LinkedList::moveIntoList(std::move(active_connection), active_connections.connections_); | ||
| } | ||
| } | ||
| } // namespace Server | ||
| } // namespace Envoy | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like this isn't used yet for anything. Delete until it's needed?
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.
This is used by the ConnectionHandler to determine if the listener type is Internal.
I feel this is cleaner than find the listen address and query the address type then dispatch by the address type.
In fact I almost make the ConnectionHandler not relying on the address type.