Repository navigation
quic: make 0-RTT keys truly shared by extending persistent quic info life time - #19862
Conversation
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
I stopped reviewing part way through the PR because it appears to have the changes from #19860 mixed in. Can you dis-entangle the PRs?
Sorry, this PR fails tests without changes in #19860 because this one truly generates 0-RTT connect signal. I should have noted in this PR about the dependency. But I'd like to send it out to gather comments about moving around those objects while waiting on #19860. |
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
|
Looks like the tests are failing? Should the "main" branch be changed to reference your 425 PR? |
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
This change has nothing to do with router filter changes. I think the failure probably caused by the newly merged srtt caching change. Sync'ed with upstream now. |
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
I created danzh2010#221 with diff base from #19860. We can iterate there. |
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
alyssawilk
left a comment
There was a problem hiding this comment.
This looks so much cleaner now, thanks for diving into the larger refactor!
| Upstream::ClusterConnectivityState& state, TimeSource& time_source, | ||
| AlternateProtocolsCacheSharedPtr alternate_protocols, ConnectivityOptions connectivity_options, | ||
| Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope) | ||
| Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope, Http::PersistentQuicInfo& quic_info) |
There was a problem hiding this comment.
So now you've done all the plumbing I go and ask the inconvenient questions, but given we agree this is persistent info for the cluster, should we expose it via the cluster API rather than pass it in separately?
host_->cluster()->quicInfo or some such?
There was a problem hiding this comment.
Does this mean the quic info should live in ClusterInfoImpl object? I might be wrong but it seems to be shared across the workers. QUIC objects like alarm factory are not thread safe.
There was a problem hiding this comment.
I think we'd get thread local cluster, but given we'd still have to cast from the interface I can go either way here.
| // Returns the most recent crypto config from host_; | ||
| std::shared_ptr<quic::QuicCryptoClientConfig> cryptoConfig(); | ||
|
|
||
| // Store quic helpers which can be shared between connections and must live |
There was a problem hiding this comment.
Should the comment be updated? Maybe just call out we're latching quic helpers shared across the cluster?
|
|
||
| protected: | ||
| // fallback_factory_ will update the context. | ||
| void onSecretUpdated() override {} |
There was a problem hiding this comment.
can't we update here by implementing onSecretUpdated, instead of latching and comparing pointers?
There was a problem hiding this comment.
I think we used the lazy update because it was a bit tricky to add onSecretUpdated() to the callback list. Because fallback_factory_ provides the sslCtx object. We need to register this callback after the fallback_factory_ registered itself, which is during its construction, to ensure when onSecretUpdated() is triggered there is an updated sslCtx from the fallback_factory_ to use. But because fallback_factory_ owns the config object. After its construction, there is no non-const handle to the config object for this class to register onSecretUpdated().
I could have added a member variable to point to config object before passing it to fallback_factory_, but such handle short-lives the base class. So it's not a good model.
|
also check tidy? |
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: Dan Zhang <[email protected]>
alyssawilk
left a comment
There was a problem hiding this comment.
Tossing over to Greg for cluster refactors
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Looks great to me, Dan!
|
Ping @ggreenway |
Signed-off-by: Dan Zhang <[email protected]>
8b2359a
ggreenway
left a comment
There was a problem hiding this comment.
Cluster refactor LGTM. I'll leave final approval to other reviewers.
|
/retest |
|
Retrying Azure Pipelines: |
|
@alyssawilk for merge |
…life time (envoyproxy#19862) Commit Message: Move Quic::PersistentQuicInfoImpl instance into ClusterEntry to extends its life time. Risk Level: low, quic connection pool only Testing: existing tests pass Fixes envoyproxy#19861 Part of envoyproxy#18715 Signed-off-by: Dan Zhang <[email protected]>
…7893) Commit Message: http3: keep the persistent QUIC info alive while its pools use it Additional Description: Removing an HTTP/3 upstream cluster while it has requests in flight can crash Envoy with a use-after-free in the QUIC client connection (SIGSEGV/SIGBUS in `quic::QuicConnection::OnCanWrite` → `CanWrite`, reached from `EnvoyQuicClientConnection::onFileEvent`, or from an alarm). `Quic::PersistentQuicInfoImpl` holds the QUIC helpers shared by a cluster's HTTP/3 connections: the connection helper with its `EnvoyQuicClock`, the alarm factory, the QUIC config, the crypto stream factory and the writer factory. Since #19862 it is owned by the thread-local `ClusterEntry` (`quic_info_`, a `unique_ptr`), `Http3ConnPoolImpl` and `ConnectivityGrid` hold it by reference, and every upstream QUIC connection keeps raw pointers into it (`QuicConnection::clock_`, each alarm's clock). When CDS removes the cluster, the worker erases the thread-local cluster and `~ClusterEntry` calls `drainConnPools()` with `DrainAndDelete`, which lets busy clients finish their streams, and then destroys its members, including the info. The pools live on in `host_http_conn_pool_map_` until their streams end, with connections pointing into freed memory; the next write-ready event or alarm reads the freed clock. It needs streams in flight at the removal, so it is intermittent. `Http3ConnPoolImpl`'s destructor already makes sure connections are torn down before the pool drops the info; the cluster entry's ordering was the gap. Fix: `PersistentQuicInfoPtr` becomes a `shared_ptr`, and `Http3ConnPoolImpl`, `Http3::allocateConnPool` and `ConnectivityGrid` take and hold it instead of a reference. The cluster keeps creating and holding the info and passes its pointer to the pools, so the info lives until the last pool using it is gone (a pool destroys its connections first). `createQuicNetworkConnection` still takes a reference; it is only called by a pool that holds the info. No behavior change on a healthy path. Testing: `Http3ConnPoolImplTest.PoolKeepsPersistentQuicInfoAliveAfterItsCreatorReleasesIt` creates the info as the cluster manager does, builds a pool on it and releases the creator's reference: the info must stay alive while the pool exists and be freed with it (fails without the fix: freed at release). The HTTP/3 pool, connection grid, cluster manager and QUIC client connection factory tests and the QUIC HTTP and multiplexed integration tests pass. Found through a crash on a deployment that removed HTTP/3 clusters under load; the fault was symbolized to the clock read in `QuicConnection::CanWrite`. Verified on main (after #47806): the new test and the HTTP/3 pool and grid tests pass, and CI is green. Risk Level: low Testing: unit test (new), existing HTTP/3 pool, grid, cluster manager and QUIC integration tests Docs Changes: N/A Release Notes: bug_fixes Platform Specific Features: N/A --------- Signed-off-by: Bruno Palermo <[email protected]>
Commit Message: Move Quic::PersistentQuicInfoImpl instance into ClusterEntry to extends its life time.
Risk Level: low, quic connection pool only
Testing: existing tests pass
Fixes #19861
Part of #18715