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

Basic NMR integration for MsQuic #3961

Merged
merged 11 commits into from
Nov 22, 2023
Merged

Basic NMR integration for MsQuic #3961

merged 11 commits into from
Nov 22, 2023

Conversation

csujedihy
Copy link
Contributor

Description

The PR adds an NMR interface (NMR provider) for kernel mode msquic. The MsQuic provide only exposes 2 interfaces, MsQuicOpenVersion and MsQuicClose, which are the same as what are exposed in msquic.sys. This PR does not remove the exports.

Currently, only QUIC tests are hooked up with NMR.

Testing

CI

@csujedihy csujedihy requested a review from a team as a code owner November 17, 2023 19:01
src/inc/msquic.h Outdated Show resolved Hide resolved
goto Error;
}

MsQuic =
Copy link
Contributor

Choose a reason for hiding this comment

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

Verify the ProviderDispatch version first? Though I suppose since its version is currently set to zero, I think your check would be impossible to fail 😄

Copy link
Contributor Author

@csujedihy csujedihy Nov 17, 2023

Choose a reason for hiding this comment

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

I am not exactly sure how to use all the version fields in NMR. There's also a version field in the NPI_REGISTRATION_INSTANCE passed in the attach callback. MsQuic's entry function also has an argument for version.

Would it make sense to just defer the version related stuff to MsQuicOpenVersion and assume there are always and only MsQuicOpenVersion and MsQuicClose in the provider dispatch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(the NMR doc just says for network modules set version to 0??)

@@ -24,6 +24,7 @@
#include <minwindef.h>
#include <ntstatus.h>
#include <basetsd.h>
#include <netioddk.h>
Copy link
Member

Choose a reason for hiding this comment

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

This is the "public" header that external clients consume. Is there any risk of this breaking their builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might if their code conflicts with the definitions or something in the header but netioddk.h is a public header file published in DDK. I don't know what we can do to reduce the risk. Are there really external KM consumers?

Copy link
Member

Choose a reason for hiding this comment

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

We don't have external KM customers. I'm just worried about an ingest PR possibly breaking Windows build.

src/inc/msquic.h Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ed6ac58) 87.27% compared to head (3007b10) 87.16%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3961      +/-   ##
==========================================
- Coverage   87.27%   87.16%   -0.11%     
==========================================
  Files          56       56              
  Lines       16958    16958              
==========================================
- Hits        14800    14782      -18     
- Misses       2158     2176      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

_In_ const void *ClientDispatch,
_Out_ void **ProviderBindingContext,
_Out_ const void **ProviderDispatch
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
)
)

src/bin/winkernel/nmrprovider.c Show resolved Hide resolved
src/inc/msquic.h Show resolved Hide resolved
src/inc/msquic.hpp Outdated Show resolved Hide resolved
src/inc/msquic.hpp Outdated Show resolved Hide resolved
src/test/bin/winkernel/control.cpp Show resolved Hide resolved

if (NmrClient.NmrClientHandle) {
NTSTATUS Status = NmrDeregisterClient(NmrClient.NmrClientHandle);
CXPLAT_FRE_ASSERTMSG(Status == STATUS_PENDING, "client deregistration failed");
Copy link
Member

Choose a reason for hiding this comment

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

Should we really bugcheck if this fails? Can OOM trigger this failure? What then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NmrDeregisterClient strictly only returns STATUS_PENDING. This is sort of a dummy check.

Copy link
Member

@nibanks nibanks left a comment

Choose a reason for hiding this comment

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

LGTM. How can/should we test this more. For instance, any negative test cases?

@csujedihy
Copy link
Contributor Author

LGTM. How can/should we test this more. For instance, any negative test cases?

Test coverage for NMR itself should be added in os repo and is being added (nmrtest). The more interesting test coverage will be added when we add msquic specific loading logic to NMR. Right now, msquic as an NMR provider is too simple to have more test cases. It literally just returns SUCCESS and sets the dispatch table for the client.

@nibanks
Copy link
Member

nibanks commented Nov 22, 2023

LGTM. How can/should we test this more. For instance, any negative test cases?

Test coverage for NMR itself should be added in os repo and is being added (nmrtest). The more interesting test coverage will be added when we add msquic specific loading logic to NMR. Right now, msquic as an NMR provider is too simple to have more test cases. It literally just returns SUCCESS and sets the dispatch table for the client.

Sounds good. Ship it.

@csujedihy csujedihy merged commit ab10cd5 into main Nov 22, 2023
402 of 411 checks passed
@csujedihy csujedihy deleted the huanyi/quic-nmr branch November 22, 2023 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants