diff --git a/scripts/prepare-machine.ps1 b/scripts/prepare-machine.ps1 index 318648076d..5c79e5133d 100644 --- a/scripts/prepare-machine.ps1 +++ b/scripts/prepare-machine.ps1 @@ -230,9 +230,17 @@ function Install-SigningCertificates { # NB: XDP can be uninstalled via Uninstall-Xdp function Install-Xdp-Driver { if (!$IsWindows) { return } # Windows only + # Install VCRT. Not required for official XDP builds. + Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe" + Start-Process -FilePath "vc_redist.x64.exe" -ArgumentList "/install /quiet /norestart" -Wait -NoNewWindow + Write-Host "Downloading XDP msi" $MsiPath = Join-Path $ArtifactsPath "xdp.msi" Invoke-WebRequest -Uri (Get-Content (Join-Path $PSScriptRoot "xdp.json") | ConvertFrom-Json).installer -OutFile $MsiPath + $CertFileName = 'xdp.cer' + Get-AuthenticodeSignature $MsiPath | Select-Object -ExpandProperty SignerCertificate | Export-Certificate -Type CERT -FilePath $CertFileName + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\root' + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\trustedpublisher' Write-Host "Installing XDP driver" msiexec.exe /i $MsiPath /quiet | Out-Null } diff --git a/scripts/quic_callback.ps1 b/scripts/quic_callback.ps1 index 8351591237..378ccf83f3 100644 --- a/scripts/quic_callback.ps1 +++ b/scripts/quic_callback.ps1 @@ -67,10 +67,18 @@ if ($Command.Contains("/home/secnetperf/_work/quic/artifacts/bin/linux/x64_Relea ./artifacts/bin/windows/x64_Release_schannel/secnetperf -exec:$mode -io:$io -stats:$stats } elseif ($Command.Contains("Install_XDP")) { Write-Host "Executing command: Install_XDP" + # Install VCRT. Not required for official XDP builds. + Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe" + Start-Process -FilePath "vc_redist.x64.exe" -ArgumentList "/install /quiet /norestart" -Wait -NoNewWindow + Write-Host "(SERVER) Downloading XDP installer" $installerUri = $Command.Split(";")[1] $msiPath = Repo-Path "xdp.msi" Invoke-WebRequest -Uri $installerUri -OutFile $msiPath -UseBasicParsing + $CertFileName = 'xdp.cer' + Get-AuthenticodeSignature $msiPath | Select-Object -ExpandProperty SignerCertificate | Export-Certificate -Type CERT -FilePath $CertFileName + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\root' + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\trustedpublisher' Write-Host "(SERVER) Installing XDP. Msi path: $msiPath" msiexec.exe /i $msiPath /quiet | Out-Host Wait-DriverStarted "xdp" 10000 diff --git a/scripts/secnetperf-helpers.psm1 b/scripts/secnetperf-helpers.psm1 index 486d487cae..d1ac6d5d54 100644 --- a/scripts/secnetperf-helpers.psm1 +++ b/scripts/secnetperf-helpers.psm1 @@ -135,11 +135,19 @@ function Wait-DriverStarted { # Download and install XDP on both local and remote machines. function Install-XDP { param ($Session, $RemoteDir) + # Install VCRT. Not required for official XDP builds. + Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe" + Start-Process -FilePath "vc_redist.x64.exe" -ArgumentList "/install /quiet /norestart" -Wait -NoNewWindow + $installerUri = (Get-Content (Join-Path $PSScriptRoot "xdp.json") | ConvertFrom-Json).installer $msiPath = Repo-Path "artifacts/xdp.msi" Write-Host "Downloading XDP installer" whoami Invoke-WebRequest -Uri $installerUri -OutFile $msiPath -UseBasicParsing + $CertFileName = 'xdp.cer' + Get-AuthenticodeSignature $msiPath | Select-Object -ExpandProperty SignerCertificate | Export-Certificate -Type CERT -FilePath $CertFileName + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\root' + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\trustedpublisher' Write-Host "Installing XDP driver locally" msiexec.exe /i $msiPath /quiet | Out-Null $Size = Get-FileHash $msiPath @@ -157,6 +165,14 @@ function Install-XDP { Copy-Item -ToSession $Session $msiPath -Destination $remoteMsiPath $WaitDriverStartedStr = "${function:Wait-DriverStarted}" Invoke-Command -Session $Session -ScriptBlock { + # Install VCRT. Not required for official XDP builds. + Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe" + Start-Process -FilePath "vc_redist.x64.exe" -ArgumentList "/install /quiet /norestart" -Wait -NoNewWindow + + $CertFileName = 'xdp.cer' + Get-AuthenticodeSignature $Using:remoteMsiPath | Select-Object -ExpandProperty SignerCertificate | Export-Certificate -Type CERT -FilePath $CertFileName + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\root' + Import-Certificate -FilePath $CertFileName -CertStoreLocation 'cert:\localmachine\trustedpublisher' msiexec.exe /i $Using:remoteMsiPath /quiet | Out-Host $WaitDriverStarted = [scriptblock]::Create($Using:WaitDriverStartedStr) & $WaitDriverStarted xdp 10000 diff --git a/scripts/xdp.json b/scripts/xdp.json index 10371d3402..37b12ae295 100644 --- a/scripts/xdp.json +++ b/scripts/xdp.json @@ -1,3 +1,3 @@ { - "installer": "https://github.com/microsoft/xdp-for-windows/releases/download/v1.0.1/xdp-for-windows.1.0.1.msi" + "installer": "https://github.com/microsoft/xdp-for-windows/releases/download/v1.1.0%2B2ca1655c/xdp-for-windows.x64.1.1.0.msi" } diff --git a/src/platform/datapath_raw_win.c b/src/platform/datapath_raw_win.c index c5aa8b18bb..e1c3fd5b77 100644 --- a/src/platform/datapath_raw_win.c +++ b/src/platform/datapath_raw_win.c @@ -176,6 +176,10 @@ RawSocketCreateUdp( return Status; } +// +// Change some real code, too. +// + CXPLAT_THREAD_CALLBACK(CxPlatRouteResolutionWorkerThread, Context) { CXPLAT_ROUTE_RESOLUTION_WORKER* Worker = (CXPLAT_ROUTE_RESOLUTION_WORKER*)Context; diff --git a/src/platform/datapath_raw_xdp_win.c b/src/platform/datapath_raw_xdp_win.c index f8d7810f1c..361c23c4de 100644 --- a/src/platform/datapath_raw_xdp_win.c +++ b/src/platform/datapath_raw_xdp_win.c @@ -942,6 +942,40 @@ CxPlatDpRawInitialize( return QUIC_STATUS_INVALID_PARAMETER; } + { + QuicTraceLogVerbose( + XdpInitialize, + "[ xdp][%p] XDP loading library", + Xdp); + + HMODULE Lib = LoadLibraryA("xdpapi.dll"); + if (Lib == NULL) { + QuicTraceLogError( + XdpInitialize, + "[ xdp][%p] XDP loading library error %u", + Xdp, GetLastError()); + } else { + QuicTraceLogVerbose( + XdpInitialize, + "[ xdp][%p] XDP resolving XdpOpenApi", + Xdp); + + if (GetProcAddress(Lib, "XdpOpenApi") == NULL) { + QuicTraceLogError( + XdpInitialize, + "[ xdp][%p] XDP resolving XdpOpenApi error %u", + Xdp, GetLastError()); + } + + FreeLibrary(Lib); + + QuicTraceLogVerbose( + XdpInitialize, + "[ xdp][%p] XDP unloaded library", + Xdp); + } + } + CxPlatListInitializeHead(&Xdp->Interfaces); if (QUIC_FAILED(XdpLoadApi(XDP_API_VERSION_1, &Xdp->XdpApiLoadContext, &Xdp->XdpApi))) { Status = QUIC_STATUS_NOT_SUPPORTED;