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

Add QuicConnection.IsQuicSupported for runtime feature detection #31689

Merged
merged 4 commits into from
Feb 7, 2020

Conversation

scalablecory
Copy link
Contributor

Add QuicConnection.IsQuicSupported for runtime feature detection, update tests to use it, and add a QuicNotSupportedException.

@scalablecory scalablecory added this to the 5.0 milestone Feb 3, 2020
@scalablecory scalablecory added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 3, 2020
@scalablecory
Copy link
Contributor Author

no merge: found an issue; correction incoming.

@Wraith2
Copy link
Contributor

Wraith2 commented Feb 4, 2020

QuicNotSupportedException doesn't really seem to offer anything that you couldn't get from NotSupportedException other than being based on QuicException, is there compelling reason not to use the existing NotSupportedException?

// TODO: check using MsQuicOpen return value; but there doesn't seem to be a consistent error code for this yet.
OperatingSystem ver = Environment.OSVersion;

if (ver.Platform != PlatformID.Win32NT || ver.Version >= new Version(10, 0, 19041, 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should be checking this version of Windows here; technically, this OS version is for schannel support of TLS 1.3. There are other TLS implementation which would work on a lower windows version (I haven't tried but there are options for msquic).

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'd like to get rid of that version check all together. It is not something that MsQuicOpen currently checks, and will instead result in callbacks failing with unspecified platform-specific TLS errors.

The TODO is left to find a better way. It is unclear what exactly msquic requires from kernel to be successful. The recommendation I've got so far is that "latest is better". This version check will at least avoid loading MsQuic on versions of Windows we haven't tested it against.

My primary goal is to avoid needing to comment out source code to avoid breaking CI; that's fragile and we will have an embarrassing merge at some point.

{
try
{
new MsQuicApi().Dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of newing up a MsQuicApi, can you just create a new property (ex: IsLoaded) that would be set in the private constructor and check Api.IsLoaded

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 idea.

… update tests to use it.

Add QuicNotSupportedException.
@scalablecory scalablecory removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 4, 2020
uint status = Interop.MsQuic.MsQuicOpen(version: 1, out registration);
if (!MsQuicStatusHelper.SuccessfulStatusCode(status))
{
throw new QuicNotSupportedException();
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, if we can avoid this exception that would be nice. Just use NotSupportedException.

Copy link
Contributor

@jkotalik jkotalik left a comment

Choose a reason for hiding this comment

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

Pending some feedback and making it really clear that we should remove the OS check 😄

@@ -27,6 +27,7 @@ public sealed partial class QuicConnection : System.IDisposable
public System.Net.Security.SslApplicationProtocol NegotiatedApplicationProtocol => throw null;
public ValueTask CloseAsync(long errorCode, System.Threading.CancellationToken cancellationToken = default) => throw null;
public void Dispose() => throw null;
public static bool IsQuicSupported => throw null;
Copy link
Member

Choose a reason for hiding this comment

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

We're still operating in a "none of this has been reviewed yet and we won't ship these APIs until we do and revise them accordingly" mode, right? Is there a must-do issue tracking that to make sure it doesn't slip through the cracks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're still operating in a "none of this has been reviewed yet and we won't ship these APIs until we do and revise them accordingly" mode, right?

Yes.

Is there a must-do issue tracking that to make sure it doesn't slip through the cracks?

It's been in active discussion during QUIC syncs; I'm aiming for us to have that ironed out in the next couple weeks. #31709

@@ -57,8 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>

<data name="net_quic_notsupported" xml:space="preserve">
<value>QUIC is not supported on this platform. See http://aka.ms/dotnetquic</value>
Copy link
Member

Choose a reason for hiding this comment

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

The link redirects to https://github.com/dotnet/runtime
Is this intentional or is the redirect not setup right now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Intentional; Around release we'll have a docs page or blog post outlining how to play with HTTP/3 -- it'll get updated at that time.

@maryamariyan
Copy link
Member

Note regarding the new-api-needs-documentation label:

This PR is modifying a ref *.cs file. When adding/modifying a public API, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@scalablecory scalablecory merged commit 796d36a into dotnet:master Feb 7, 2020
@scalablecory scalablecory self-assigned this Feb 12, 2020
@scalablecory scalablecory deleted the quic-feature-detection branch July 29, 2020 16:06
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants