Skip to content

Commit

Permalink
Merge branch 'main' into dev/daiki/header_xdp
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-GS committed Nov 22, 2024
2 parents 87e5ca4 + c73f75a commit d527c4f
Show file tree
Hide file tree
Showing 29 changed files with 994 additions and 801 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
cmake --build . --target OpenSSL_Target
- name: Initialize CodeQL
uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd
uses: github/codeql-action/init@4f3212b61783c3c68e8309a0f18a699764811cda
with:
languages: cpp
config-file: ./.github/codeql/codeql-config.yml
Expand All @@ -62,4 +62,4 @@ jobs:
cmake --build .
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd
uses: github/codeql-action/analyze@4f3212b61783c3c68e8309a0f18a699764811cda
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ jobs:
dotnet-version: 6.0.x
- name: Run Lang Interop
shell: pwsh
run: scripts/DotNetTest.ps1 -Config Debug -Arch ${{ matrix.vec.arch }} -Tls ${{ matrix.vec.tls }}
run: scripts/DotNetTest.ps1 -Config Debug -Arch ${{ matrix.vec.arch }} -Tls ${{ matrix.vec.tls }} -DomainName "google.com"
2 changes: 1 addition & 1 deletion .github/workflows/netperf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Run NetPerf Workflow
timeout-minutes: 90
timeout-minutes: 120
shell: pwsh
run: |
$url = "https://raw.githubusercontent.com/microsoft/netperf/main/run-workflow.ps1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd
uses: github/codeql-action/upload-sarif@4f3212b61783c3c68e8309a0f18a699764811cda
with:
sarif_file: results.sarif
7 changes: 5 additions & 2 deletions scripts/DotNetTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ param (
[string]$Tls = "",

[Parameter(Mandatory = $false)]
[string]$ExtraArtifactDir = ""
[string]$ExtraArtifactDir = "",

[Parameter(Mandatory = $true)]
[string]$DomainName = ""
)

Set-StrictMode -Version 'Latest'
Expand All @@ -43,4 +46,4 @@ if ($IsWindows) {
$RootDir = Split-Path $PSScriptRoot -Parent

dotnet build (Join-Path $RootDir src cs)
dotnet run --project (Join-Path $RootDir src cs tool) -- (Join-Path $RootArtifactDir $LibName)
dotnet run --project (Join-Path $RootDir src cs tool) -- $DomainName (Join-Path $RootArtifactDir $LibName)
7 changes: 7 additions & 0 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -5638,6 +5638,9 @@ QuicConnRecvDatagrams(

if (!IsDeferred) {
Connection->Stats.Recv.TotalBytes += Packet->BufferLength;
if (Connection->Stats.Handshake.HandshakeHopLimitTTL == 0) {
Connection->Stats.Handshake.HandshakeHopLimitTTL = Packet->HopLimitTTL;
}
QuicConnLogInFlowStats(Connection);

if (!CurrentPath->IsPeerValidated) {
Expand Down Expand Up @@ -6823,6 +6826,10 @@ QuicConnGetV2Statistics(
Stats->SendEcnCongestionCount = Connection->Stats.Send.EcnCongestionCount;
}

if (STATISTICS_HAS_FIELD(*StatsLength, HandshakeHopLimitTTL)) {
Stats->HandshakeHopLimitTTL = Connection->Stats.Handshake.HandshakeHopLimitTTL;
}

*StatsLength = CXPLAT_MIN(*StatsLength, sizeof(QUIC_STATISTICS_V2));

return QUIC_STATUS_SUCCESS;
Expand Down
1 change: 1 addition & 0 deletions src/core/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ typedef struct QUIC_CONN_STATS {
uint32_t ClientFlight1Bytes; // Sum of TLS payloads
uint32_t ServerFlight1Bytes; // Sum of TLS payloads
uint32_t ClientFlight2Bytes; // Sum of TLS payloads
uint8_t HandshakeHopLimitTTL; // TTL value in the initial packet of the handshake.
} Handshake;

struct {
Expand Down
3 changes: 3 additions & 0 deletions src/cs/lib/msquic_generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,9 @@ internal uint RESERVED

[NativeTypeName("uint32_t")]
internal uint SendEcnCongestionCount;

[NativeTypeName("uint8_t")]
internal byte HandshakeHopLimitTTL;
}

internal partial struct QUIC_LISTENER_STATISTICS
Expand Down
26 changes: 23 additions & 3 deletions src/cs/tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,32 @@ static unsafe void Main(string[] args)
{
// This code lets us pass in an argument of where to search for the library at.
// Very helpful for testing
if (args.Length > 0)
if (args.Length == 0)
{
Console.WriteLine("Usage: MsQuicTool <DomainName> [PathToMsQuic]");
return;
}

string DomainName = args[0];

if (string.IsNullOrWhiteSpace(DomainName))
{
Console.WriteLine("DomainName cannot be empty.");
return;
}

if (DomainName.Length > 253)
{
Console.WriteLine("DomainName is too long.");
return;
}

if (args.Length > 1)
{
NativeLibrary.SetDllImportResolver(typeof(MsQuic).Assembly, (libraryName, assembly, searchPath) =>
{
if (libraryName != "msquic") return IntPtr.Zero;
if (NativeLibrary.TryLoad(args[0], out var ptr))
if (NativeLibrary.TryLoad(args[1], out var ptr))
{
return ptr;
}
Expand Down Expand Up @@ -55,7 +75,7 @@ static unsafe void Main(string[] args)
MsQuic.ThrowIfFailure(ApiTable->ConfigurationLoadCredential(configuration, &config));
MsQuic.ThrowIfFailure(ApiTable->ConnectionOpen(registration, &NativeCallback, ApiTable, &connection));
sbyte* google = stackalloc sbyte[50];
int written = Encoding.UTF8.GetBytes("google.com", new Span<byte>(google, 50));
int written = Encoding.UTF8.GetBytes(DomainName, new Span<byte>(google, 50));
google[written] = 0;
MsQuic.ThrowIfFailure(ApiTable->ConnectionStart(connection, configuration, 0, google, 443));
Thread.Sleep(1000);
Expand Down
42 changes: 42 additions & 0 deletions src/generated/linux/datapath_winuser.c.clog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#define _clog_MACRO_QuicTraceLogVerbose 1
#define QuicTraceLogVerbose(a, ...) _clog_CAT(_clog_ARGN_SELECTOR(__VA_ARGS__), _clog_CAT(_,a(#a, __VA_ARGS__)))
#endif
#ifndef _clog_MACRO_QuicTraceLogError
#define _clog_MACRO_QuicTraceLogError 1
#define QuicTraceLogError(a, ...) _clog_CAT(_clog_ARGN_SELECTOR(__VA_ARGS__), _clog_CAT(_,a(#a, __VA_ARGS__)))
#endif
#ifndef _clog_MACRO_QuicTraceEvent
#define _clog_MACRO_QuicTraceEvent 1
#define QuicTraceEvent(a, ...) _clog_CAT(_clog_ARGN_SELECTOR(__VA_ARGS__), _clog_CAT(_,a(#a, __VA_ARGS__)))
Expand Down Expand Up @@ -251,6 +255,26 @@ tracepoint(CLOG_DATAPATH_WINUSER_C, DatapathTooLarge , arg2, arg3_len, arg3);\



/*----------------------------------------------------------
// Decoder Ring for DatapathResolveHostNameFailed
// [%p] Couldn't resolve hostname '%s' to an IP address
// QuicTraceLogError(
DatapathResolveHostNameFailed,
"[%p] Couldn't resolve hostname '%s' to an IP address",
Datapath,
HostName);
// arg2 = arg2 = Datapath = arg2
// arg3 = arg3 = HostName = arg3
----------------------------------------------------------*/
#ifndef _clog_4_ARGS_TRACE_DatapathResolveHostNameFailed
#define _clog_4_ARGS_TRACE_DatapathResolveHostNameFailed(uniqueId, encoded_arg_string, arg2, arg3)\
tracepoint(CLOG_DATAPATH_WINUSER_C, DatapathResolveHostNameFailed , arg2, arg3);\

#endif




/*----------------------------------------------------------
// Decoder Ring for LibraryErrorStatus
// [ lib] ERROR, %u, %s.
Expand Down Expand Up @@ -291,6 +315,24 @@ tracepoint(CLOG_DATAPATH_WINUSER_C, AllocFailure , arg2, arg3);\



/*----------------------------------------------------------
// Decoder Ring for LibraryError
// [ lib] ERROR, %s.
// QuicTraceEvent(
LibraryError,
"[ lib] ERROR, %s.",
"No local unicast addresses found");
// arg2 = arg2 = "No local unicast addresses found" = arg2
----------------------------------------------------------*/
#ifndef _clog_3_ARGS_TRACE_LibraryError
#define _clog_3_ARGS_TRACE_LibraryError(uniqueId, encoded_arg_string, arg2)\
tracepoint(CLOG_DATAPATH_WINUSER_C, LibraryError , arg2);\

#endif




/*----------------------------------------------------------
// Decoder Ring for DatapathErrorStatus
// [data][%p] ERROR, %u, %s.
Expand Down
42 changes: 42 additions & 0 deletions src/generated/linux/datapath_winuser.c.clog.h.lttng.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,29 @@ TRACEPOINT_EVENT(CLOG_DATAPATH_WINUSER_C, DatapathTooLarge,



/*----------------------------------------------------------
// Decoder Ring for DatapathResolveHostNameFailed
// [%p] Couldn't resolve hostname '%s' to an IP address
// QuicTraceLogError(
DatapathResolveHostNameFailed,
"[%p] Couldn't resolve hostname '%s' to an IP address",
Datapath,
HostName);
// arg2 = arg2 = Datapath = arg2
// arg3 = arg3 = HostName = arg3
----------------------------------------------------------*/
TRACEPOINT_EVENT(CLOG_DATAPATH_WINUSER_C, DatapathResolveHostNameFailed,
TP_ARGS(
const void *, arg2,
const char *, arg3),
TP_FIELDS(
ctf_integer_hex(uint64_t, arg2, (uint64_t)arg2)
ctf_string(arg3, arg3)
)
)



/*----------------------------------------------------------
// Decoder Ring for LibraryErrorStatus
// [ lib] ERROR, %u, %s.
Expand Down Expand Up @@ -291,6 +314,25 @@ TRACEPOINT_EVENT(CLOG_DATAPATH_WINUSER_C, AllocFailure,



/*----------------------------------------------------------
// Decoder Ring for LibraryError
// [ lib] ERROR, %s.
// QuicTraceEvent(
LibraryError,
"[ lib] ERROR, %s.",
"No local unicast addresses found");
// arg2 = arg2 = "No local unicast addresses found" = arg2
----------------------------------------------------------*/
TRACEPOINT_EVENT(CLOG_DATAPATH_WINUSER_C, LibraryError,
TP_ARGS(
const char *, arg2),
TP_FIELDS(
ctf_string(arg2, arg2)
)
)



/*----------------------------------------------------------
// Decoder Ring for DatapathErrorStatus
// [data][%p] ERROR, %u, %s.
Expand Down
2 changes: 2 additions & 0 deletions src/inc/msquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ typedef struct QUIC_STATISTICS_V2 {

uint32_t SendEcnCongestionCount; // Number of congestion events caused by ECN.

uint8_t HandshakeHopLimitTTL; // The TTL value in the initial packet of the handshake.

// N.B. New fields must be appended to end

} QUIC_STATISTICS_V2;
Expand Down
6 changes: 6 additions & 0 deletions src/inc/quic_datapath.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ typedef struct CXPLAT_RECV_DATA {
//
uint8_t TypeOfService;

//
// TTL Hoplimit field of the IP header of the received packet on handshake.
//
uint8_t HopLimitTTL;

//
// Flags.
//
Expand Down Expand Up @@ -438,6 +443,7 @@ CxPlatDataPathUpdateConfig(
#define CXPLAT_DATAPATH_FEATURE_PORT_RESERVATIONS 0x0010
#define CXPLAT_DATAPATH_FEATURE_TCP 0x0020
#define CXPLAT_DATAPATH_FEATURE_RAW 0x0040
#define CXPLAT_DATAPATH_FEATURE_TTL 0x0080

//
// Queries the currently supported features of the datapath.
Expand Down
Loading

0 comments on commit d527c4f

Please sign in to comment.