Skip to content
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

feat(s2n-quic): unstable dc provider #2210

Merged
merged 5 commits into from
May 15, 2024
Merged

Conversation

WesleyRosenblum
Copy link
Contributor

Description of changes:

This change adds an unstable dc provider for configuring dc functionality. The provider will not actually be used until subsequent PRs.

Call-outs:

I've implemented Path for Option<P> as I was planning to have the dc::Manager operate on an Option<Path> rather than just Path. This is because dc can end up disabled for a path in 2 ways:

  1. by not configuring a provider, in which case the Disabled provider is used (which has an associated type of DisabledPath)
  2. by not being able to negotiate a dc version. In this case, the associated Path type of the dc provider is used but shouldn't actually do anything.

I didn't want the implementor of the provider to have to handle when no dc version is negotiated, so instead I'll have the dc::Manager handle that case.

Testing:

Will add tests after further integration of the provider

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


/// Returns the stateless reset tokens to include in a `DC_STATELESS_RESET_TOKENS`
/// frame sent to the peer.
fn stateless_reset_tokens(&mut self) -> &[stateless_reset::Token];
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to decide if this is going to be an issue if we're making the provider own the tokens (since they're being borrowed out of this function).

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'm not sure, but I think we can get a little further in the integration and revisit

Copy link
Contributor

Choose a reason for hiding this comment

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

works for me

@@ -0,0 +1,146 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been preferring moving away from mod.rs and using the actual name, since it gets annoying having a million mod.rs files in the project.

pub struct DisabledPath(());

impl Path for DisabledPath {
fn on_path_secrets_ready(&mut self, _session: &impl TlsSession) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Will any of these methods actually get called? Might be a good idea to put an unimplemented!() or at the very least a debug_assert!(false).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I make new_path return Option, then I can just have the disabled endpoint return None, in which case these will not be called

@@ -52,6 +52,15 @@ cfg_if!(
}
);

cfg_if!(
if #[cfg(any(test, feature = "unstable-provider-dc"))] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you wanting to add this feature in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

knew I was forgetting something :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also needed to add the provider to the server and client builders

type Path: Path;

/// Called when a dc version has been negotiated for the given `ConnectionInfo`
fn new_path(&mut self, connection_info: &ConnectionInfo) -> Self::Path;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to have this return an Option<Self::Path>?

Copy link
Contributor Author

@WesleyRosenblum WesleyRosenblum May 15, 2024

Choose a reason for hiding this comment

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

I was planning on not calling it at all if no dc version was negotiated, so it didn't seem necessary. But I guess it might still be useful to give the provider the opportunity to not use dc even if a dc version was negotiated if it was running in some mixed dc/non-dc environment.

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

use s2n_quic_core::dc::{Disabled, Endpoint};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this is missing re-exports for the s2n-quic-core internals? Not sure how much it will matter but historically it has been painful to maintain those versions (since every bump requires bump toml or being hit with build failures, even though you may not be directly affected by the changes in the bump).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, it wasn't intentional, I'll add the re-exports

@WesleyRosenblum WesleyRosenblum merged commit 02a47b7 into main May 15, 2024
129 of 130 checks passed
@WesleyRosenblum WesleyRosenblum deleted the WesleyRosenblum/dcprovider branch May 15, 2024 20:57
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.

3 participants