├── .gitmodules
├── eng
├── common
│ ├── BuildConfiguration
│ │ └── build-configuration.json
│ ├── dotnet-install.cmd
│ ├── build.cmd
│ ├── CIBuild.cmd
│ ├── sdl
│ │ ├── packages.config
│ │ ├── NuGet.config
│ │ ├── sdl.ps1
│ │ ├── run-sdl.ps1
│ │ ├── trim-assets-version.ps1
│ │ ├── extract-artifact-archives.ps1
│ │ ├── init-sdl.ps1
│ │ └── extract-artifact-packages.ps1
│ ├── init-tools-native.cmd
│ ├── templates
│ │ ├── steps
│ │ │ ├── run-on-unix.yml
│ │ │ ├── run-on-windows.yml
│ │ │ ├── add-build-to-channel.yml
│ │ │ ├── build-reason.yml
│ │ │ ├── component-governance.yml
│ │ │ ├── run-script-ifequalelse.yml
│ │ │ ├── retain-build.yml
│ │ │ ├── execute-codeql.yml
│ │ │ ├── publish-logs.yml
│ │ │ ├── generate-sbom.yml
│ │ │ ├── execute-sdl.yml
│ │ │ └── telemetry-end.yml
│ │ ├── variables
│ │ │ ├── sdl-variables.yml
│ │ │ └── pool-providers.yml
│ │ ├── post-build
│ │ │ ├── trigger-subscription.yml
│ │ │ ├── common-variables.yml
│ │ │ └── setup-maestro-vars.yml
│ │ ├── jobs
│ │ │ ├── codeql-build.yml
│ │ │ ├── source-build.yml
│ │ │ └── jobs.yml
│ │ └── job
│ │ │ ├── source-index-stage1.yml
│ │ │ ├── source-build.yml
│ │ │ └── onelocbuild.yml
│ ├── internal
│ │ ├── Directory.Build.props
│ │ ├── NuGet.config
│ │ └── Tools.csproj
│ ├── templates-official
│ │ ├── variables
│ │ │ ├── sdl-variables.yml
│ │ │ └── pool-providers.yml
│ │ ├── steps
│ │ │ ├── add-build-to-channel.yml
│ │ │ ├── component-governance.yml
│ │ │ ├── retain-build.yml
│ │ │ ├── publish-logs.yml
│ │ │ └── generate-sbom.yml
│ │ ├── post-build
│ │ │ ├── trigger-subscription.yml
│ │ │ ├── common-variables.yml
│ │ │ └── setup-maestro-vars.yml
│ │ ├── jobs
│ │ │ ├── codeql-build.yml
│ │ │ └── source-build.yml
│ │ └── job
│ │ │ ├── source-index-stage1.yml
│ │ │ └── source-build.yml
│ ├── PSScriptAnalyzerSettings.psd1
│ ├── cibuild.sh
│ ├── enable-cross-org-publishing.ps1
│ ├── msbuild.ps1
│ ├── generate-sbom-prep.ps1
│ ├── dotnet-install.ps1
│ ├── helixpublish.proj
│ ├── post-build
│ │ ├── nuget-validation.ps1
│ │ ├── add-build-to-channel.ps1
│ │ ├── check-channel-consistency.ps1
│ │ ├── publish-using-darc.ps1
│ │ ├── trigger-subscriptions.ps1
│ │ ├── redact-logs.ps1
│ │ └── post-build-utils.ps1
│ ├── generate-sbom-prep.sh
│ ├── msbuild.sh
│ ├── README.md
│ ├── retain-build.ps1
│ ├── loc
│ │ └── P22DotNetHtmlLocalization.lss
│ ├── darc-init.ps1
│ ├── native
│ │ ├── init-os-and-arch.sh
│ │ ├── install-cmake.sh
│ │ └── install-cmake-test.sh
│ ├── dotnet-install.sh
│ ├── darc-init.sh
│ └── sdk-task.ps1
├── Tools.props
├── Version.Details.xml
├── Versions.props
└── addCmakeToPath.ps1
├── Directory.Build.targets
├── src
├── System.Net.MsQuic.Transport
│ ├── pkg
│ │ ├── runtime.osx-x64.runtime.native.System.Net.MsQuic.Transport.proj
│ │ ├── runtime.win-x64.runtime.native.System.Net.MsQuic.Transport.proj
│ │ ├── runtime.win-x86.runtime.native.System.Net.MsQuic.Transport.proj
│ │ ├── runtime.linux-arm.runtime.native.System.Net.MsQuic.Transport.proj
│ │ ├── runtime.linux-x64.runtime.native.System.Net.MsQuic.Transport.proj
│ │ ├── runtime.win-arm64.runtime.native.System.Net.MsQuic.Transport.proj
│ │ ├── runtime.linux-arm64.runtime.native.System.Net.MsQuic.Transport.proj
│ │ └── runtime.native.System.Net.MsQuic.Transport.props
│ └── System.Net.MsQuic.Transport.proj
├── xdp
│ └── include
│ │ ├── xdp
│ │ ├── guid.h
│ │ ├── driverapi.h
│ │ ├── details
│ │ │ ├── export.h
│ │ │ ├── extension.h
│ │ │ ├── interfaceconfig.h
│ │ │ └── datapath.h
│ │ ├── apiversion.h
│ │ ├── objectheader.h
│ │ ├── interfaceconfig.h
│ │ ├── ndis6.h
│ │ ├── dma.h
│ │ ├── extension.h
│ │ ├── queueinfo.h
│ │ ├── frameinterfacecontext.h
│ │ ├── bufferinterfacecontext.h
│ │ ├── buffermdl.h
│ │ ├── framefragment.h
│ │ ├── framerxaction.h
│ │ ├── hookid.h
│ │ ├── bufferlogicaladdress.h
│ │ ├── buffervirtualaddress.h
│ │ ├── txframecompletioncontext.h
│ │ ├── pollinfo.h
│ │ ├── extensioninfo.h
│ │ ├── rtl.h
│ │ ├── ndis6poll.h
│ │ ├── datapath.h
│ │ ├── program.h
│ │ └── rxqueueconfig.h
│ │ ├── xdpddi.h
│ │ ├── afxdp_experimental.h
│ │ ├── afxdp_helper.h
│ │ └── xdpapi.h
└── install-dependencies.ps1
├── CODE-OF-CONDUCT.md
├── global.json
├── .CodeQL.yml
├── README.md
├── NuGet.config
├── SECURITY.md
├── LICENSE.TXT
├── msquic-net.sln
├── .gitignore
└── FLOW.md
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "msquic"]
2 | path = src/msquic
3 | url = https://github.com/microsoft/msquic.git
4 |
--------------------------------------------------------------------------------
/eng/common/BuildConfiguration/build-configuration.json:
--------------------------------------------------------------------------------
1 | {
2 | "RetryCountLimit": 1,
3 | "RetryByAnyError": false
4 | }
5 |
--------------------------------------------------------------------------------
/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/eng/common/dotnet-install.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0dotnet-install.ps1""" %*"
--------------------------------------------------------------------------------
/eng/common/build.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0build.ps1""" %*"
3 | exit /b %ErrorLevel%
4 |
--------------------------------------------------------------------------------
/eng/common/CIBuild.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"
--------------------------------------------------------------------------------
/eng/common/sdl/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/eng/common/init-tools-native.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -NoProfile -NoLogo -ExecutionPolicy ByPass -command "& """%~dp0init-tools-native.ps1""" %*"
3 | exit /b %ErrorLevel%
--------------------------------------------------------------------------------
/eng/common/templates/steps/run-on-unix.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | agentOs: ''
3 | steps: []
4 |
5 | steps:
6 | - ${{ if ne(parameters.agentOs, 'Windows_NT') }}:
7 | - ${{ parameters.steps }}
8 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/run-on-windows.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | agentOs: ''
3 | steps: []
4 |
5 | steps:
6 | - ${{ if eq(parameters.agentOs, 'Windows_NT') }}:
7 | - ${{ parameters.steps }}
8 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.osx-x64.runtime.native.System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | osx-x64
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.win-x64.runtime.native.System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | win-x64
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.win-x86.runtime.native.System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | win-x86
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.linux-arm.runtime.native.System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | linux-arm
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.linux-x64.runtime.native.System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | linux-x64
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.win-arm64.runtime.native.System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | win-arm64
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/CODE-OF-CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | This project has adopted the code of conduct defined by the Contributor Covenant
4 | to clarify expected behavior in our community.
5 | For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
6 |
--------------------------------------------------------------------------------
/eng/common/internal/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.linux-arm64.runtime.native.System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 | linux-arm64
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/guid.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | _IRQL_requires_max_(PASSIVE_LEVEL)
11 | NTSTATUS
12 | XdpGuidCreate(
13 | _Out_ GUID *Guid
14 | );
15 |
16 | EXTERN_C_END
17 |
--------------------------------------------------------------------------------
/eng/common/internal/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/driverapi.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #define XDP_DRIVER_API_MAJOR_VER 0
11 | #define XDP_DRIVER_API_MINOR_VER 10
12 | #define XDP_DRIVER_API_PATCH_VER 0
13 |
14 | EXTERN_C_END
15 |
--------------------------------------------------------------------------------
/eng/common/templates/variables/sdl-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in
3 | # sync with the packages.config file.
4 | - name: DefaultGuardianVersion
5 | value: 0.109.0
6 | - name: GuardianPackagesConfigFile
7 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config
--------------------------------------------------------------------------------
/eng/common/templates-official/variables/sdl-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in
3 | # sync with the packages.config file.
4 | - name: DefaultGuardianVersion
5 | value: 0.109.0
6 | - name: GuardianPackagesConfigFile
7 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.100-preview.1.24101.2",
4 | "allowPrerelease": true,
5 | "rollForward": "major"
6 | },
7 | "tools": {
8 | "dotnet": "9.0.100-preview.1.24101.2"
9 | },
10 | "msbuild-sdks": {
11 | "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24179.6",
12 | "Microsoft.Build.NoTargets": "3.7.0"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/details/export.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDP_EXPORT_H
7 | #define XDP_EXPORT_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | #ifndef XDPEXPORT
14 | #define XDPEXPORT(X) X
15 | #endif
16 |
17 | #ifdef __cplusplus
18 | } // extern "C"
19 | #endif
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/eng/Tools.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | C#
5 |
6 |
7 |
9 |
11 |
12 |
--------------------------------------------------------------------------------
/eng/Version.Details.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | https://github.com/dotnet/arcade
8 | 986a55a9c7f1ef547bc705d6adada5e0c2217819
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/apiversion.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef APIVERSION_H
7 | #define APIVERSION_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | typedef struct _XDP_VERSION {
14 | UINT32 Major;
15 | UINT32 Minor;
16 | UINT32 Patch;
17 | } XDP_VERSION;
18 |
19 | #ifdef __cplusplus
20 | } // extern "C"
21 | #endif
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/objectheader.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDP_OBJECT_HEADER_H
7 | #define XDP_OBJECT_HEADER_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | typedef struct _XDP_OBJECT_HEADER {
14 | UINT32 Revision;
15 | UINT32 Size;
16 | } XDP_OBJECT_HEADER;
17 |
18 | #ifdef __cplusplus
19 | } // extern "C"
20 | #endif
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/.CodeQL.yml:
--------------------------------------------------------------------------------
1 | # This file configures CodeQL runs and TSA bug autofiling. For more information, see:
2 | # https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/codeql/troubleshooting/bugs/generated-library-code
3 | # (Access restricted to Microsoft employees only.)
4 |
5 | path_classifiers:
6 | submodules:
7 | # Submodules are analyzed within their primary repos and should not be analyzed
8 | # as part of building this repo.
9 | - src/msquic
10 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/interfaceconfig.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #include
11 | #include
12 |
13 | DECLARE_HANDLE(XDP_INTERFACE_CONFIG);
14 |
15 | CONST XDP_VERSION *
16 | XdpGetDriverApiVersion(
17 | _In_ XDP_INTERFACE_CONFIG InterfaceConfig
18 | );
19 |
20 | #include
21 |
22 | EXTERN_C_END
23 |
--------------------------------------------------------------------------------
/eng/Versions.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 9.0.0
5 |
6 | 9
7 | 0
8 | 0
9 | alpha
10 | 1
11 | false
12 |
13 |
14 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/add-build-to-channel.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | ChannelId: 0
3 |
4 | steps:
5 | - task: PowerShell@2
6 | displayName: Add Build to Channel
7 | inputs:
8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/add-build-to-channel.ps1
9 | arguments: -BuildId $(BARBuildId)
10 | -ChannelId ${{ parameters.ChannelId }}
11 | -MaestroApiAccessToken $(MaestroApiAccessToken)
12 | -MaestroApiEndPoint $(MaestroApiEndPoint)
13 | -MaestroApiVersion $(MaestroApiVersion)
14 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/add-build-to-channel.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | ChannelId: 0
3 |
4 | steps:
5 | - task: PowerShell@2
6 | displayName: Add Build to Channel
7 | inputs:
8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/add-build-to-channel.ps1
9 | arguments: -BuildId $(BARBuildId)
10 | -ChannelId ${{ parameters.ChannelId }}
11 | -MaestroApiAccessToken $(MaestroApiAccessToken)
12 | -MaestroApiEndPoint $(MaestroApiEndPoint)
13 | -MaestroApiVersion $(MaestroApiVersion)
14 |
--------------------------------------------------------------------------------
/eng/common/templates/post-build/trigger-subscription.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | ChannelId: 0
3 |
4 | steps:
5 | - task: PowerShell@2
6 | displayName: Triggering subscriptions
7 | inputs:
8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/trigger-subscriptions.ps1
9 | arguments: -SourceRepo $(Build.Repository.Uri)
10 | -ChannelId ${{ parameters.ChannelId }}
11 | -MaestroApiAccessToken $(MaestroAccessToken)
12 | -MaestroApiEndPoint $(MaestroApiEndPoint)
13 | -MaestroApiVersion $(MaestroApiVersion)
14 |
--------------------------------------------------------------------------------
/eng/common/PSScriptAnalyzerSettings.psd1:
--------------------------------------------------------------------------------
1 | @{
2 | IncludeRules=@('PSAvoidUsingCmdletAliases',
3 | 'PSAvoidUsingWMICmdlet',
4 | 'PSAvoidUsingPositionalParameters',
5 | 'PSAvoidUsingInvokeExpression',
6 | 'PSUseDeclaredVarsMoreThanAssignments',
7 | 'PSUseCmdletCorrectly',
8 | 'PSStandardDSCFunctionsInResource',
9 | 'PSUseIdenticalMandatoryParametersForDSC',
10 | 'PSUseIdenticalParametersForDSC')
11 | }
--------------------------------------------------------------------------------
/eng/common/templates-official/post-build/trigger-subscription.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | ChannelId: 0
3 |
4 | steps:
5 | - task: PowerShell@2
6 | displayName: Triggering subscriptions
7 | inputs:
8 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/trigger-subscriptions.ps1
9 | arguments: -SourceRepo $(Build.Repository.Uri)
10 | -ChannelId ${{ parameters.ChannelId }}
11 | -MaestroApiAccessToken $(MaestroAccessToken)
12 | -MaestroApiEndPoint $(MaestroApiEndPoint)
13 | -MaestroApiVersion $(MaestroApiVersion)
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MsQuic for .NET
2 |
3 | This repo contains sources for the MsQuic private transport package which lights up QUIC and HTTP/3 support in .NET.
4 |
5 | The package is only intended for _testing_ purposes, for the cases where official MsQuic package is not available.
6 |
7 | ## Building
8 |
9 | - Clone the repo recursively (`git clone --recursive`) or run `git submodule update --init --recursive` to get all the submodules.
10 | - Run `build.cmd`
11 |
12 | ## .NET Foundation
13 |
14 | .NET Runtime is a [.NET Foundation](https://www.dotnetfoundation.org/projects) project.
15 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/details/extension.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDP_EXTENSION_DETAILS_H
7 | #define XDP_EXTENSION_DETAILS_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | #include
14 |
15 | inline
16 | VOID *
17 | XdpGetExtensionData(
18 | _In_ VOID *Descriptor,
19 | _In_ XDP_EXTENSION *Extension
20 | )
21 | {
22 | return (VOID *)((UCHAR *)Descriptor + Extension->Reserved);
23 | }
24 |
25 | #ifdef __cplusplus
26 | } // extern "C"
27 | #endif
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/ndis6.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | //
11 | // Redefine NDIS6 OID in XDP headers until an updated DDK is released.
12 | //
13 |
14 | //
15 | // An XDP-capable NDIS6 interface must respond to OID_XDP_QUERY_CAPABILITIES by
16 | // providing the interface's registered XDP_CAPABILITIES structure. This OID is
17 | // an NDIS query OID.
18 | //
19 | #ifndef OID_XDP_QUERY_CAPABILITIES
20 | #define OID_XDP_QUERY_CAPABILITIES 0x00A00204
21 | #endif
22 |
23 | EXTERN_C_END
24 |
--------------------------------------------------------------------------------
/eng/common/cibuild.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 |
5 | # resolve $SOURCE until the file is no longer a symlink
6 | while [[ -h $source ]]; do
7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
8 | source="$(readlink "$source")"
9 |
10 | # if $source was a relative symlink, we need to resolve it relative to the path where
11 | # the symlink file was located
12 | [[ $source != /* ]] && source="$scriptroot/$source"
13 | done
14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
15 |
16 | . "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@
--------------------------------------------------------------------------------
/eng/common/templates/steps/build-reason.yml:
--------------------------------------------------------------------------------
1 | # build-reason.yml
2 | # Description: runs steps if build.reason condition is valid. conditions is a string of valid build reasons
3 | # to include steps (',' separated).
4 | parameters:
5 | conditions: ''
6 | steps: []
7 |
8 | steps:
9 | - ${{ if and( not(startsWith(parameters.conditions, 'not')), contains(parameters.conditions, variables['build.reason'])) }}:
10 | - ${{ parameters.steps }}
11 | - ${{ if and( startsWith(parameters.conditions, 'not'), not(contains(parameters.conditions, variables['build.reason']))) }}:
12 | - ${{ parameters.steps }}
13 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/component-governance.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | disableComponentGovernance: false
3 | componentGovernanceIgnoreDirectories: ''
4 |
5 | steps:
6 | - ${{ if eq(parameters.disableComponentGovernance, 'true') }}:
7 | - script: "echo ##vso[task.setvariable variable=skipComponentGovernanceDetection]true"
8 | displayName: Set skipComponentGovernanceDetection variable
9 | - ${{ if ne(parameters.disableComponentGovernance, 'true') }}:
10 | - task: ComponentGovernanceComponentDetection@0
11 | continueOnError: true
12 | inputs:
13 | ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/component-governance.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | disableComponentGovernance: false
3 | componentGovernanceIgnoreDirectories: ''
4 |
5 | steps:
6 | - ${{ if eq(parameters.disableComponentGovernance, 'true') }}:
7 | - script: "echo ##vso[task.setvariable variable=skipComponentGovernanceDetection]true"
8 | displayName: Set skipComponentGovernanceDetection variable
9 | - ${{ if ne(parameters.disableComponentGovernance, 'true') }}:
10 | - task: ComponentGovernanceComponentDetection@0
11 | continueOnError: true
12 | inputs:
13 | ignoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
--------------------------------------------------------------------------------
/eng/common/sdl/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/eng/common/enable-cross-org-publishing.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [string] $token
3 | )
4 |
5 |
6 | . $PSScriptRoot\pipeline-logging-functions.ps1
7 |
8 | # Write-PipelineSetVariable will no-op if a variable named $ci is not defined
9 | # Since this script is only ever called in AzDO builds, just universally set it
10 | $ci = $true
11 |
12 | Write-PipelineSetVariable -Name 'VSS_NUGET_ACCESSTOKEN' -Value $token -IsMultiJobVariable $false
13 | Write-PipelineSetVariable -Name 'VSS_NUGET_URI_PREFIXES' -Value 'https://dnceng.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/dnceng/;https://devdiv.pkgs.visualstudio.com/;https://pkgs.dev.azure.com/devdiv/' -IsMultiJobVariable $false
14 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/dma.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | typedef struct _XDP_DMA_CAPABILITIES {
11 | ULONG Size;
12 | DEVICE_OBJECT *PhysicalDeviceObject;
13 | } XDP_DMA_CAPABILITIES;
14 |
15 | inline
16 | VOID
17 | XdpInitializeDmaCapabilitiesPdo(
18 | _Out_ XDP_DMA_CAPABILITIES *Capabilities,
19 | _In_ DEVICE_OBJECT *PhysicalDeviceObject
20 | )
21 | {
22 | RtlZeroMemory(Capabilities, sizeof(*Capabilities));
23 | Capabilities->Size = sizeof(*Capabilities);
24 | Capabilities->PhysicalDeviceObject = PhysicalDeviceObject;
25 | }
26 |
27 | EXTERN_C_END
28 |
--------------------------------------------------------------------------------
/eng/common/msbuild.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(PositionalBinding=$false)]
2 | Param(
3 | [string] $verbosity = 'minimal',
4 | [bool] $warnAsError = $true,
5 | [bool] $nodeReuse = $true,
6 | [switch] $ci,
7 | [switch] $prepareMachine,
8 | [switch] $excludePrereleaseVS,
9 | [string] $msbuildEngine = $null,
10 | [Parameter(ValueFromRemainingArguments=$true)][String[]]$extraArgs
11 | )
12 |
13 | . $PSScriptRoot\tools.ps1
14 |
15 | try {
16 | if ($ci) {
17 | $nodeReuse = $false
18 | }
19 |
20 | MSBuild @extraArgs
21 | }
22 | catch {
23 | Write-Host $_.ScriptStackTrace
24 | Write-PipelineTelemetryError -Category 'Build' -Message $_
25 | ExitWithExitCode 1
26 | }
27 |
28 | ExitWithExitCode 0
--------------------------------------------------------------------------------
/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/extension.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDP_EXTENSION_H
7 | #define XDP_EXTENSION_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | #pragma warning(push)
14 | #pragma warning(default:4820) // warn if the compiler inserted padding
15 |
16 | typedef struct _XDP_EXTENSION {
17 | //
18 | // This field is reserved for XDP platform use.
19 | //
20 | UINT16 Reserved;
21 | } XDP_EXTENSION;
22 |
23 | C_ASSERT(sizeof(XDP_EXTENSION) == 2);
24 |
25 | #pragma warning(pop)
26 |
27 | #include
28 |
29 | #ifdef __cplusplus
30 | } // extern "C"
31 | #endif
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/queueinfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDP_QUEUE_INFO_H
7 | #define XDP_QUEUE_INFO_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | typedef enum _XDP_QUEUE_TYPE {
14 | XDP_QUEUE_TYPE_DEFAULT_RSS,
15 | } XDP_QUEUE_TYPE;
16 |
17 | typedef struct _XDP_QUEUE_INFO {
18 | XDP_OBJECT_HEADER Header;
19 | XDP_QUEUE_TYPE QueueType;
20 | UINT32 QueueId;
21 | } XDP_QUEUE_INFO;
22 |
23 | #define XDP_QUEUE_INFO_REVISION_1 1
24 |
25 | #define XDP_SIZEOF_QUEUE_INFO_REVISION_1 \
26 | RTL_SIZEOF_THROUGH_FIELD(XDP_QUEUE_INFO, QueueId)
27 |
28 | #ifdef __cplusplus
29 | } // extern "C"
30 | #endif
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/frameinterfacecontext.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | typedef VOID XDP_FRAME_INTERFACE_CONTEXT;
11 |
12 | #define XDP_FRAME_EXTENSION_INTERFACE_CONTEXT_NAME L"ms_frame_interface_context"
13 | #define XDP_FRAME_EXTENSION_INTERFACE_CONTEXT_VERSION_1 1U
14 |
15 | #include
16 | #include
17 |
18 | inline
19 | XDP_FRAME_INTERFACE_CONTEXT *
20 | XdpGetFrameInterfaceContextExtension(
21 | _In_ XDP_FRAME *Frame,
22 | _In_ XDP_EXTENSION *Extension
23 | )
24 | {
25 | return (XDP_FRAME_INTERFACE_CONTEXT *)XdpGetExtensionData(Frame, Extension);
26 | }
27 |
28 | EXTERN_C_END
29 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/bufferinterfacecontext.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | typedef VOID XDP_BUFFER_INTERFACE_CONTEXT;
11 |
12 | #define XDP_BUFFER_EXTENSION_INTERFACE_CONTEXT_NAME L"ms_buffer_interface_context"
13 | #define XDP_BUFFER_EXTENSION_INTERFACE_CONTEXT_VERSION_1 1U
14 |
15 | #include
16 | #include
17 |
18 | inline
19 | XDP_BUFFER_INTERFACE_CONTEXT *
20 | XdpGetBufferInterfaceContextExtension(
21 | _In_ XDP_BUFFER *Buffer,
22 | _In_ XDP_EXTENSION *Extension
23 | )
24 | {
25 | return (XDP_BUFFER_INTERFACE_CONTEXT *)XdpGetExtensionData(Buffer, Extension);
26 | }
27 |
28 | EXTERN_C_END
29 |
--------------------------------------------------------------------------------
/eng/common/templates/post-build/common-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | - group: Publish-Build-Assets
3 |
4 | # Whether the build is internal or not
5 | - name: IsInternalBuild
6 | value: ${{ and(ne(variables['System.TeamProject'], 'public'), contains(variables['Build.SourceBranch'], 'internal')) }}
7 |
8 | # Default Maestro++ API Endpoint and API Version
9 | - name: MaestroApiEndPoint
10 | value: "https://maestro.dot.net"
11 | - name: MaestroApiAccessToken
12 | value: $(MaestroAccessToken)
13 | - name: MaestroApiVersion
14 | value: "2020-02-20"
15 |
16 | - name: SourceLinkCLIVersion
17 | value: 3.0.0
18 | - name: SymbolToolVersion
19 | value: 1.0.1
20 | - name: BinlogToolVersion
21 | value: 1.0.11
22 |
23 | - name: runCodesignValidationInjection
24 | value: false
25 |
--------------------------------------------------------------------------------
/eng/common/templates-official/post-build/common-variables.yml:
--------------------------------------------------------------------------------
1 | variables:
2 | - group: Publish-Build-Assets
3 |
4 | # Whether the build is internal or not
5 | - name: IsInternalBuild
6 | value: ${{ and(ne(variables['System.TeamProject'], 'public'), contains(variables['Build.SourceBranch'], 'internal')) }}
7 |
8 | # Default Maestro++ API Endpoint and API Version
9 | - name: MaestroApiEndPoint
10 | value: "https://maestro.dot.net"
11 | - name: MaestroApiAccessToken
12 | value: $(MaestroAccessToken)
13 | - name: MaestroApiVersion
14 | value: "2020-02-20"
15 |
16 | - name: SourceLinkCLIVersion
17 | value: 3.0.0
18 | - name: SymbolToolVersion
19 | value: 1.0.1
20 | - name: BinlogToolVersion
21 | value: 1.0.11
22 |
23 | - name: runCodesignValidationInjection
24 | value: false
25 |
--------------------------------------------------------------------------------
/eng/common/generate-sbom-prep.ps1:
--------------------------------------------------------------------------------
1 | Param(
2 | [Parameter(Mandatory=$true)][string] $ManifestDirPath # Manifest directory where sbom will be placed
3 | )
4 |
5 | . $PSScriptRoot\pipeline-logging-functions.ps1
6 |
7 | Write-Host "Creating dir $ManifestDirPath"
8 | # create directory for sbom manifest to be placed
9 | if (!(Test-Path -path $ManifestDirPath))
10 | {
11 | New-Item -ItemType Directory -path $ManifestDirPath
12 | Write-Host "Successfully created directory $ManifestDirPath"
13 | }
14 | else{
15 | Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder."
16 | }
17 |
18 | Write-Host "Updating artifact name"
19 | $artifact_name = "${env:SYSTEM_STAGENAME}_${env:AGENT_JOBNAME}_SBOM" -replace '["/:<>\\|?@*"() ]', '_'
20 | Write-Host "Artifact name $artifact_name"
21 | Write-Host "##vso[task.setvariable variable=ARTIFACT_NAME]$artifact_name"
22 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/buffermdl.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #pragma warning(push)
11 | #pragma warning(default:4820) // warn if the compiler inserted padding
12 |
13 | typedef struct _XDP_BUFFER_MDL {
14 | MDL *Mdl;
15 | SIZE_T MdlOffset;
16 | } XDP_BUFFER_MDL;
17 |
18 | C_ASSERT(sizeof(XDP_BUFFER_MDL) == 2 * sizeof(VOID *));
19 |
20 | #pragma warning(pop)
21 |
22 | #define XDP_BUFFER_EXTENSION_MDL_NAME L"ms_buffer_mdl"
23 | #define XDP_BUFFER_EXTENSION_MDL_VERSION_1 1U
24 |
25 | #include
26 | #include
27 |
28 | inline
29 | XDP_BUFFER_MDL *
30 | XdpGetMdlExtension(
31 | _In_ XDP_BUFFER *Buffer,
32 | _In_ XDP_EXTENSION *Extension
33 | )
34 | {
35 | return (XDP_BUFFER_MDL *)XdpGetExtensionData(Buffer, Extension);
36 | }
37 |
38 | EXTERN_C_END
39 |
--------------------------------------------------------------------------------
/eng/common/dotnet-install.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(PositionalBinding=$false)]
2 | Param(
3 | [string] $verbosity = 'minimal',
4 | [string] $architecture = '',
5 | [string] $version = 'Latest',
6 | [string] $runtime = 'dotnet',
7 | [string] $RuntimeSourceFeed = '',
8 | [string] $RuntimeSourceFeedKey = ''
9 | )
10 |
11 | . $PSScriptRoot\tools.ps1
12 |
13 | $dotnetRoot = Join-Path $RepoRoot '.dotnet'
14 |
15 | $installdir = $dotnetRoot
16 | try {
17 | if ($architecture -and $architecture.Trim() -eq 'x86') {
18 | $installdir = Join-Path $installdir 'x86'
19 | }
20 | InstallDotNet $installdir $version $architecture $runtime $true -RuntimeSourceFeed $RuntimeSourceFeed -RuntimeSourceFeedKey $RuntimeSourceFeedKey
21 | }
22 | catch {
23 | Write-Host $_.ScriptStackTrace
24 | Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_
25 | ExitWithExitCode 1
26 | }
27 |
28 | ExitWithExitCode 0
29 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/framefragment.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #pragma warning(push)
11 | #pragma warning(default:4820) // warn if the compiler inserted padding
12 |
13 | typedef struct _XDP_FRAME_FRAGMENT {
14 | UINT8 FragmentBufferCount;
15 | } XDP_FRAME_FRAGMENT;
16 |
17 | C_ASSERT(sizeof(XDP_FRAME_FRAGMENT) == 1);
18 |
19 | #pragma warning(pop)
20 |
21 | #define XDP_FRAME_EXTENSION_FRAGMENT_NAME L"ms_frame_fragment"
22 | #define XDP_FRAME_EXTENSION_FRAGMENT_VERSION_1 1U
23 |
24 | #include
25 | #include
26 |
27 | inline
28 | XDP_FRAME_FRAGMENT *
29 | XdpGetFragmentExtension(
30 | _In_ XDP_FRAME *Frame,
31 | _In_ XDP_EXTENSION *Extension
32 | )
33 | {
34 | return (XDP_FRAME_FRAGMENT *)XdpGetExtensionData(Frame, Extension);
35 | }
36 |
37 | EXTERN_C_END
38 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/framerxaction.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #pragma warning(push)
11 | #pragma warning(default:4820) // warn if the compiler inserted padding
12 |
13 | typedef struct _XDP_FRAME_RX_ACTION {
14 | UINT8 RxAction;
15 | } XDP_FRAME_RX_ACTION;
16 |
17 | C_ASSERT(sizeof(XDP_FRAME_RX_ACTION) == 1);
18 |
19 | #pragma warning(pop)
20 |
21 | #define XDP_FRAME_EXTENSION_RX_ACTION_NAME L"ms_frame_rx_action"
22 | #define XDP_FRAME_EXTENSION_RX_ACTION_VERSION_1 1U
23 |
24 | #include
25 | #include
26 |
27 | inline
28 | XDP_FRAME_RX_ACTION *
29 | XdpGetRxActionExtension(
30 | _In_ XDP_FRAME *Frame,
31 | _In_ XDP_EXTENSION *Extension
32 | )
33 | {
34 | return (XDP_FRAME_RX_ACTION *)XdpGetExtensionData(Frame, Extension);
35 | }
36 |
37 | EXTERN_C_END
38 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/hookid.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef HOOKID_H
7 | #define HOOKID_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | typedef enum _XDP_HOOK_LAYER {
14 | XDP_HOOK_L2,
15 | } XDP_HOOK_LAYER;
16 |
17 | typedef enum _XDP_HOOK_DATAPATH_DIRECTION {
18 | XDP_HOOK_RX,
19 | XDP_HOOK_TX,
20 | } XDP_HOOK_DATAPATH_DIRECTION;
21 |
22 | typedef enum _XDP_HOOK_SUBLAYER {
23 | XDP_HOOK_INSPECT,
24 | XDP_HOOK_INJECT,
25 | } XDP_HOOK_SUBLAYER;
26 |
27 | typedef struct _XDP_HOOK_ID {
28 | XDP_HOOK_LAYER Layer;
29 | XDP_HOOK_DATAPATH_DIRECTION Direction;
30 | XDP_HOOK_SUBLAYER SubLayer;
31 | } XDP_HOOK_ID;
32 |
33 | C_ASSERT(
34 | sizeof(XDP_HOOK_ID) ==
35 | sizeof(XDP_HOOK_LAYER) +
36 | sizeof(XDP_HOOK_DATAPATH_DIRECTION) +
37 | sizeof(XDP_HOOK_SUBLAYER));
38 |
39 | #ifdef __cplusplus
40 | } // extern "C"
41 | #endif
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/bufferlogicaladdress.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #pragma warning(push)
11 | #pragma warning(default:4820) // warn if the compiler inserted padding
12 |
13 | typedef struct _XDP_BUFFER_LOGICAL_ADDRESS {
14 | UINT64 LogicalAddress;
15 | } XDP_BUFFER_LOGICAL_ADDRESS;
16 |
17 | C_ASSERT(sizeof(XDP_BUFFER_LOGICAL_ADDRESS) == sizeof(VOID *));
18 |
19 | #pragma warning(pop)
20 |
21 | #define XDP_BUFFER_EXTENSION_LOGICAL_ADDRESS_NAME L"ms_buffer_logical_address"
22 | #define XDP_BUFFER_EXTENSION_LOGICAL_ADDRESS_VERSION_1 1U
23 |
24 | #include
25 | #include
26 |
27 | inline
28 | XDP_BUFFER_LOGICAL_ADDRESS *
29 | XdpGetLogicalAddressExtension(
30 | _In_ XDP_BUFFER *Buffer,
31 | _In_ XDP_EXTENSION *Extension
32 | )
33 | {
34 | return (XDP_BUFFER_LOGICAL_ADDRESS *)XdpGetExtensionData(Buffer, Extension);
35 | }
36 |
37 | EXTERN_C_END
38 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/buffervirtualaddress.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #pragma warning(push)
11 | #pragma warning(default:4820) // warn if the compiler inserted padding
12 |
13 | typedef struct XDP_BUFFER_VIRTUAL_ADDRESS {
14 | UCHAR *VirtualAddress;
15 | } XDP_BUFFER_VIRTUAL_ADDRESS;
16 |
17 | C_ASSERT(sizeof(XDP_BUFFER_VIRTUAL_ADDRESS) == sizeof(VOID *));
18 |
19 | #pragma warning(pop)
20 |
21 | #define XDP_BUFFER_EXTENSION_VIRTUAL_ADDRESS_NAME L"ms_buffer_virtual_address"
22 | #define XDP_BUFFER_EXTENSION_VIRTUAL_ADDRESS_VERSION_1 1U
23 |
24 | #include
25 | #include
26 |
27 | inline
28 | XDP_BUFFER_VIRTUAL_ADDRESS *
29 | XdpGetVirtualAddressExtension(
30 | _In_ XDP_BUFFER *Buffer,
31 | _In_ XDP_EXTENSION *Extension
32 | )
33 | {
34 | return (XDP_BUFFER_VIRTUAL_ADDRESS *)XdpGetExtensionData(Buffer, Extension);
35 | }
36 |
37 | EXTERN_C_END
38 |
--------------------------------------------------------------------------------
/eng/common/helixpublish.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | msbuild
6 |
7 |
8 |
9 |
10 | %(Identity)
11 |
12 |
13 |
14 |
15 |
16 | $(WorkItemDirectory)
17 | $(WorkItemCommand)
18 | $(WorkItemTimeout)
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/eng/common/post-build/nuget-validation.ps1:
--------------------------------------------------------------------------------
1 | # This script validates NuGet package metadata information using this
2 | # tool: https://github.com/NuGet/NuGetGallery/tree/jver-verify/src/VerifyMicrosoftPackage
3 |
4 | param(
5 | [Parameter(Mandatory=$true)][string] $PackagesPath, # Path to where the packages to be validated are
6 | [Parameter(Mandatory=$true)][string] $ToolDestinationPath # Where the validation tool should be downloaded to
7 | )
8 |
9 | try {
10 | . $PSScriptRoot\post-build-utils.ps1
11 |
12 | $url = 'https://raw.githubusercontent.com/NuGet/NuGetGallery/3e25ad135146676bcab0050a516939d9958bfa5d/src/VerifyMicrosoftPackage/verify.ps1'
13 |
14 | New-Item -ItemType 'directory' -Path ${ToolDestinationPath} -Force
15 |
16 | Invoke-WebRequest $url -OutFile ${ToolDestinationPath}\verify.ps1
17 |
18 | & ${ToolDestinationPath}\verify.ps1 ${PackagesPath}\*.nupkg
19 | }
20 | catch {
21 | Write-Host $_.ScriptStackTrace
22 | Write-PipelineTelemetryError -Category 'NuGetValidation' -Message $_
23 | ExitWithExitCode 1
24 | }
25 |
--------------------------------------------------------------------------------
/src/xdp/include/xdpddi.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | //
9 | // This top-level header includes all XDP headers for driver developers.
10 | //
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | The .NET Core and ASP.NET Core support policy, including supported versions can be found at the [.NET Core Support Policy Page](https://dotnet.microsoft.com/platform/support/policy/dotnet-core).
6 |
7 | ## Reporting a Vulnerability
8 |
9 | Security issues and bugs should be reported privately to the Microsoft Security Response Center (MSRC), either by emailing secure@microsoft.com or via the portal at https://msrc.microsoft.com.
10 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your
11 | original message. Further information, including the MSRC PGP key, can be found in the [MSRC Report an Issue FAQ](https://www.microsoft.com/en-us/msrc/faqs-report-an-issue).
12 |
13 | Reports via MSRC may qualify for the .NET Core Bug Bounty. Details of the .NET Core Bug Bounty including terms and conditions are at [https://aka.ms/corebounty](https://aka.ms/corebounty).
14 |
15 | Please do not open issues for anything you think might have a security implication.
16 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/run-script-ifequalelse.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # if parameter1 equals parameter 2, run 'ifScript' command, else run 'elsescript' command
3 | parameter1: ''
4 | parameter2: ''
5 | ifScript: ''
6 | elseScript: ''
7 |
8 | # name of script step
9 | name: Script
10 |
11 | # display name of script step
12 | displayName: If-Equal-Else Script
13 |
14 | # environment
15 | env: {}
16 |
17 | # conditional expression for step execution
18 | condition: ''
19 |
20 | steps:
21 | - ${{ if and(ne(parameters.ifScript, ''), eq(parameters.parameter1, parameters.parameter2)) }}:
22 | - script: ${{ parameters.ifScript }}
23 | name: ${{ parameters.name }}
24 | displayName: ${{ parameters.displayName }}
25 | env: ${{ parameters.env }}
26 | condition: ${{ parameters.condition }}
27 |
28 | - ${{ if and(ne(parameters.elseScript, ''), ne(parameters.parameter1, parameters.parameter2)) }}:
29 | - script: ${{ parameters.elseScript }}
30 | name: ${{ parameters.name }}
31 | displayName: ${{ parameters.displayName }}
32 | env: ${{ parameters.env }}
33 | condition: ${{ parameters.condition }}
--------------------------------------------------------------------------------
/LICENSE.TXT:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) .NET Foundation and Contributors
4 |
5 | All rights reserved.
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 | SOFTWARE.
24 |
--------------------------------------------------------------------------------
/eng/common/templates/jobs/codeql-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md
3 | continueOnError: false
4 | # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job
5 | jobs: []
6 | # Optional: if specified, restore and use this version of Guardian instead of the default.
7 | overrideGuardianVersion: ''
8 |
9 | jobs:
10 | - template: /eng/common/templates/jobs/jobs.yml
11 | parameters:
12 | enableMicrobuild: false
13 | enablePublishBuildArtifacts: false
14 | enablePublishTestResults: false
15 | enablePublishBuildAssets: false
16 | enablePublishUsingPipelines: false
17 | enableTelemetry: true
18 |
19 | variables:
20 | - group: Publish-Build-Assets
21 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in
22 | # sync with the packages.config file.
23 | - name: DefaultGuardianVersion
24 | value: 0.109.0
25 | - name: GuardianPackagesConfigFile
26 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config
27 | - name: GuardianVersion
28 | value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }}
29 |
30 | jobs: ${{ parameters.jobs }}
31 |
32 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/retain-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # Optional azure devops PAT with build execute permissions for the build's organization,
3 | # only needed if the build that should be retained ran on a different organization than
4 | # the pipeline where this template is executing from
5 | Token: ''
6 | # Optional BuildId to retain, defaults to the current running build
7 | BuildId: ''
8 | # Azure devops Organization URI for the build in the https://dev.azure.com/ format.
9 | # Defaults to the organization the current pipeline is running on
10 | AzdoOrgUri: '$(System.CollectionUri)'
11 | # Azure devops project for the build. Defaults to the project the current pipeline is running on
12 | AzdoProject: '$(System.TeamProject)'
13 |
14 | steps:
15 | - task: powershell@2
16 | inputs:
17 | targetType: 'filePath'
18 | filePath: eng/common/retain-build.ps1
19 | pwsh: true
20 | arguments: >
21 | -AzdoOrgUri: ${{parameters.AzdoOrgUri}}
22 | -AzdoProject ${{parameters.AzdoProject}}
23 | -Token ${{coalesce(parameters.Token, '$env:SYSTEM_ACCESSTOKEN') }}
24 | -BuildId ${{coalesce(parameters.BuildId, '$env:BUILD_ID')}}
25 | displayName: Enable permanent build retention
26 | env:
27 | SYSTEM_ACCESSTOKEN: $(System.AccessToken)
28 | BUILD_ID: $(Build.BuildId)
--------------------------------------------------------------------------------
/src/xdp/include/xdp/txframecompletioncontext.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #pragma warning(push)
11 | #pragma warning(default:4820) // warn if the compiler inserted padding
12 |
13 | typedef struct _XDP_TX_FRAME_COMPLETION_CONTEXT {
14 | VOID *Context;
15 | } XDP_TX_FRAME_COMPLETION_CONTEXT;
16 |
17 | C_ASSERT(sizeof(XDP_TX_FRAME_COMPLETION_CONTEXT) == sizeof(VOID *));
18 |
19 | #pragma warning(pop)
20 |
21 | #define XDP_TX_FRAME_COMPLETION_CONTEXT_EXTENSION_NAME L"ms_tx_frame_completion_context"
22 | #define XDP_TX_FRAME_COMPLETION_CONTEXT_EXTENSION_VERSION_1 1U
23 |
24 | #include
25 | #include
26 |
27 | inline
28 | XDP_TX_FRAME_COMPLETION_CONTEXT *
29 | XdpGetFrameTxCompletionContextExtension(
30 | _In_ XDP_FRAME *Frame,
31 | _In_ XDP_EXTENSION *Extension
32 | )
33 | {
34 | return (XDP_TX_FRAME_COMPLETION_CONTEXT *)XdpGetExtensionData(Frame, Extension);
35 | }
36 |
37 | inline
38 | XDP_TX_FRAME_COMPLETION_CONTEXT *
39 | XdpGetTxCompletionContextExtension(
40 | _In_ XDP_TX_FRAME_COMPLETION *Completion,
41 | _In_ XDP_EXTENSION *Extension
42 | )
43 | {
44 | return (XDP_TX_FRAME_COMPLETION_CONTEXT *)XdpGetExtensionData(Completion, Extension);
45 | }
46 |
47 | EXTERN_C_END
48 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/retain-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # Optional azure devops PAT with build execute permissions for the build's organization,
3 | # only needed if the build that should be retained ran on a different organization than
4 | # the pipeline where this template is executing from
5 | Token: ''
6 | # Optional BuildId to retain, defaults to the current running build
7 | BuildId: ''
8 | # Azure devops Organization URI for the build in the https://dev.azure.com/ format.
9 | # Defaults to the organization the current pipeline is running on
10 | AzdoOrgUri: '$(System.CollectionUri)'
11 | # Azure devops project for the build. Defaults to the project the current pipeline is running on
12 | AzdoProject: '$(System.TeamProject)'
13 |
14 | steps:
15 | - task: powershell@2
16 | inputs:
17 | targetType: 'filePath'
18 | filePath: eng/common/retain-build.ps1
19 | pwsh: true
20 | arguments: >
21 | -AzdoOrgUri: ${{parameters.AzdoOrgUri}}
22 | -AzdoProject ${{parameters.AzdoProject}}
23 | -Token ${{coalesce(parameters.Token, '$env:SYSTEM_ACCESSTOKEN') }}
24 | -BuildId ${{coalesce(parameters.BuildId, '$env:BUILD_ID')}}
25 | displayName: Enable permanent build retention
26 | env:
27 | SYSTEM_ACCESSTOKEN: $(System.AccessToken)
28 | BUILD_ID: $(Build.BuildId)
--------------------------------------------------------------------------------
/eng/common/generate-sbom-prep.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 |
5 | # resolve $SOURCE until the file is no longer a symlink
6 | while [[ -h $source ]]; do
7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
8 | source="$(readlink "$source")"
9 |
10 | # if $source was a relative symlink, we need to resolve it relative to the path where the
11 | # symlink file was located
12 | [[ $source != /* ]] && source="$scriptroot/$source"
13 | done
14 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
15 | . $scriptroot/pipeline-logging-functions.sh
16 |
17 | manifest_dir=$1
18 |
19 | if [ ! -d "$manifest_dir" ] ; then
20 | mkdir -p "$manifest_dir"
21 | echo "Sbom directory created." $manifest_dir
22 | else
23 | Write-PipelineTelemetryError -category 'Build' "Unable to create sbom folder."
24 | fi
25 |
26 | artifact_name=$SYSTEM_STAGENAME"_"$AGENT_JOBNAME"_SBOM"
27 | echo "Artifact name before : "$artifact_name
28 | # replace all special characters with _, some builds use special characters like : in Agent.Jobname, that is not a permissible name while uploading artifacts.
29 | safe_artifact_name="${artifact_name//["/:<>\\|?@*$" ]/_}"
30 | echo "Artifact name after : "$safe_artifact_name
31 | export ARTIFACT_NAME=$safe_artifact_name
32 | echo "##vso[task.setvariable variable=ARTIFACT_NAME]$safe_artifact_name"
33 |
34 | exit 0
35 |
--------------------------------------------------------------------------------
/eng/common/templates-official/jobs/codeql-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md
3 | continueOnError: false
4 | # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job
5 | jobs: []
6 | # Optional: if specified, restore and use this version of Guardian instead of the default.
7 | overrideGuardianVersion: ''
8 |
9 | jobs:
10 | - template: /eng/common/templates-official/jobs/jobs.yml
11 | parameters:
12 | enableMicrobuild: false
13 | enablePublishBuildArtifacts: false
14 | enablePublishTestResults: false
15 | enablePublishBuildAssets: false
16 | enablePublishUsingPipelines: false
17 | enableTelemetry: true
18 |
19 | variables:
20 | - group: Publish-Build-Assets
21 | # The Guardian version specified in 'eng/common/sdl/packages.config'. This value must be kept in
22 | # sync with the packages.config file.
23 | - name: DefaultGuardianVersion
24 | value: 0.109.0
25 | - name: GuardianPackagesConfigFile
26 | value: $(Build.SourcesDirectory)\eng\common\sdl\packages.config
27 | - name: GuardianVersion
28 | value: ${{ coalesce(parameters.overrideGuardianVersion, '$(DefaultGuardianVersion)') }}
29 |
30 | jobs: ${{ parameters.jobs }}
31 |
32 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/details/interfaceconfig.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | typedef
16 | CONST XDP_VERSION *
17 | XDP_GET_DRIVER_API_VERSION(
18 | _In_ XDP_INTERFACE_CONFIG InterfaceConfig
19 | );
20 |
21 | typedef struct _XDP_INTERFACE_CONFIG_DISPATCH {
22 | XDP_OBJECT_HEADER Header;
23 | XDP_GET_DRIVER_API_VERSION *GetDriverApiVersion;
24 | } XDP_INTERFACE_CONFIG_DISPATCH;
25 |
26 | #define XDP_INTERFACE_CONFIG_DISPATCH_REVISION_1 1
27 |
28 | #define XDP_SIZEOF_INTERFACE_CONFIG_DISPATCH_REVISION_1 \
29 | RTL_SIZEOF_THROUGH_FIELD(XDP_INTERFACE_CONFIG_DISPATCH, GetDriverApiVersion)
30 |
31 | typedef struct _XDP_INTERFACE_CONFIG_DETAILS {
32 | CONST XDP_INTERFACE_CONFIG_DISPATCH *Dispatch;
33 | } XDP_INTERFACE_CONFIG_DETAILS;
34 |
35 | inline
36 | CONST XDP_VERSION *
37 | XDPEXPORT(XdpGetDriverApiVersion)(
38 | _In_ XDP_INTERFACE_CONFIG InterfaceConfig
39 | )
40 | {
41 | XDP_INTERFACE_CONFIG_DETAILS *Details =
42 | (XDP_INTERFACE_CONFIG_DETAILS *)InterfaceConfig;
43 | return Details->Dispatch->GetDriverApiVersion(InterfaceConfig);
44 | }
45 |
46 | EXTERN_C_END
47 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/pollinfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #include
11 |
12 | typedef struct _XDP_POLL_INFO {
13 | XDP_OBJECT_HEADER Header;
14 | NDIS_HANDLE PollHandle;
15 | BOOLEAN Shared;
16 | } XDP_POLL_INFO;
17 |
18 | #define XDP_POLL_INFO_REVISION_1 1
19 |
20 | #define XDP_SIZEOF_POLL_INFO_REVISION_1 \
21 | RTL_SIZEOF_THROUGH_FIELD(XDP_POLL_INFO, Shared)
22 |
23 | inline
24 | VOID
25 | XdpInitializeSharedPollInfo(
26 | _Out_ XDP_POLL_INFO *PollInfo,
27 | _In_ NDIS_HANDLE PollHandle
28 | )
29 | {
30 | RtlZeroMemory(PollInfo, sizeof(*PollInfo));
31 | PollInfo->Header.Revision = XDP_POLL_INFO_REVISION_1;
32 | PollInfo->Header.Size = XDP_SIZEOF_POLL_INFO_REVISION_1;
33 |
34 | PollInfo->PollHandle = PollHandle;
35 | PollInfo->Shared = TRUE;
36 | }
37 |
38 | inline
39 | VOID
40 | XdpInitializeExclusivePollInfo(
41 | _Out_ XDP_POLL_INFO *PollInfo,
42 | _In_ NDIS_HANDLE PollHandle
43 | )
44 | {
45 | RtlZeroMemory(PollInfo, sizeof(*PollInfo));
46 | PollInfo->Header.Revision = XDP_POLL_INFO_REVISION_1;
47 | PollInfo->Header.Size = XDP_SIZEOF_POLL_INFO_REVISION_1;
48 |
49 | PollInfo->PollHandle = PollHandle;
50 | PollInfo->Shared = FALSE;
51 | }
52 |
53 | EXTERN_C_END
54 |
--------------------------------------------------------------------------------
/eng/common/sdl/sdl.ps1:
--------------------------------------------------------------------------------
1 |
2 | function Install-Gdn {
3 | param(
4 | [Parameter(Mandatory=$true)]
5 | [string]$Path,
6 |
7 | # If omitted, install the latest version of Guardian, otherwise install that specific version.
8 | [string]$Version
9 | )
10 |
11 | $ErrorActionPreference = 'Stop'
12 | Set-StrictMode -Version 2.0
13 | $disableConfigureToolsetImport = $true
14 | $global:LASTEXITCODE = 0
15 |
16 | # `tools.ps1` checks $ci to perform some actions. Since the SDL
17 | # scripts don't necessarily execute in the same agent that run the
18 | # build.ps1/sh script this variable isn't automatically set.
19 | $ci = $true
20 | . $PSScriptRoot\..\tools.ps1
21 |
22 | $argumentList = @("install", "Microsoft.Guardian.Cli", "-Source https://securitytools.pkgs.visualstudio.com/_packaging/Guardian/nuget/v3/index.json", "-OutputDirectory $Path", "-NonInteractive", "-NoCache")
23 |
24 | if ($Version) {
25 | $argumentList += "-Version $Version"
26 | }
27 |
28 | Start-Process nuget -Verbose -ArgumentList $argumentList -NoNewWindow -Wait
29 |
30 | $gdnCliPath = Get-ChildItem -Filter guardian.cmd -Recurse -Path $Path
31 |
32 | if (!$gdnCliPath)
33 | {
34 | Write-PipelineTelemetryError -Category 'Sdl' -Message 'Failure installing Guardian'
35 | }
36 |
37 | return $gdnCliPath.FullName
38 | }
--------------------------------------------------------------------------------
/eng/common/msbuild.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 |
5 | # resolve $source until the file is no longer a symlink
6 | while [[ -h "$source" ]]; do
7 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
8 | source="$(readlink "$source")"
9 | # if $source was a relative symlink, we need to resolve it relative to the path where the
10 | # symlink file was located
11 | [[ $source != /* ]] && source="$scriptroot/$source"
12 | done
13 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
14 |
15 | verbosity='minimal'
16 | warn_as_error=true
17 | node_reuse=true
18 | prepare_machine=false
19 | extra_args=''
20 |
21 | while (($# > 0)); do
22 | lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
23 | case $lowerI in
24 | --verbosity)
25 | verbosity=$2
26 | shift 2
27 | ;;
28 | --warnaserror)
29 | warn_as_error=$2
30 | shift 2
31 | ;;
32 | --nodereuse)
33 | node_reuse=$2
34 | shift 2
35 | ;;
36 | --ci)
37 | ci=true
38 | shift 1
39 | ;;
40 | --preparemachine)
41 | prepare_machine=true
42 | shift 1
43 | ;;
44 | *)
45 | extra_args="$extra_args $1"
46 | shift 1
47 | ;;
48 | esac
49 | done
50 |
51 | . "$scriptroot/tools.sh"
52 |
53 | if [[ "$ci" == true ]]; then
54 | node_reuse=false
55 | fi
56 |
57 | MSBuild $extra_args
58 | ExitWithExitCode 0
59 |
--------------------------------------------------------------------------------
/eng/common/README.md:
--------------------------------------------------------------------------------
1 | # Don't touch this folder
2 |
3 | uuuuuuuuuuuuuuuuuuuu
4 | u" uuuuuuuuuuuuuuuuuu "u
5 | u" u$$$$$$$$$$$$$$$$$$$$u "u
6 | u" u$$$$$$$$$$$$$$$$$$$$$$$$u "u
7 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
8 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
9 | u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
10 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
11 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
12 | $ $$$" ... "$... ...$" ... "$$$ ... "$$$ $
13 | $ $$$u `"$$$$$$$ $$$ $$$$$ $$ $$$ $$$ $
14 | $ $$$$$$uu "$$$$ $$$ $$$$$ $$ """ u$$$ $
15 | $ $$$""$$$ $$$$ $$$u "$$$" u$$ $$$$$$$$ $
16 | $ $$$$....,$$$$$..$$$$$....,$$$$..$$$$$$$$ $
17 | $ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
18 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
19 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
20 | "u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
21 | "u "$$$$$$$$$$$$$$$$$$$$$$$$" u"
22 | "u "$$$$$$$$$$$$$$$$$$$$" u"
23 | "u """""""""""""""""" u"
24 | """"""""""""""""""""
25 |
26 | !!! Changes made in this directory are subject to being overwritten by automation !!!
27 |
28 | The files in this directory are shared by all Arcade repos and managed by automation. If you need to make changes to these files, open an issue or submit a pull request to https://github.com/dotnet/arcade first.
29 |
--------------------------------------------------------------------------------
/eng/common/retain-build.ps1:
--------------------------------------------------------------------------------
1 |
2 | Param(
3 | [Parameter(Mandatory=$true)][int] $buildId,
4 | [Parameter(Mandatory=$true)][string] $azdoOrgUri,
5 | [Parameter(Mandatory=$true)][string] $azdoProject,
6 | [Parameter(Mandatory=$true)][string] $token
7 | )
8 |
9 | $ErrorActionPreference = 'Stop'
10 | Set-StrictMode -Version 2.0
11 |
12 | function Get-AzDOHeaders(
13 | [string] $token)
14 | {
15 | $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":${token}"))
16 | $headers = @{"Authorization"="Basic $base64AuthInfo"}
17 | return $headers
18 | }
19 |
20 | function Update-BuildRetention(
21 | [string] $azdoOrgUri,
22 | [string] $azdoProject,
23 | [int] $buildId,
24 | [string] $token)
25 | {
26 | $headers = Get-AzDOHeaders -token $token
27 | $requestBody = "{
28 | `"keepForever`": `"true`"
29 | }"
30 |
31 | $requestUri = "${azdoOrgUri}/${azdoProject}/_apis/build/builds/${buildId}?api-version=6.0"
32 | write-Host "Attempting to retain build using the following URI: ${requestUri} ..."
33 |
34 | try {
35 | Invoke-RestMethod -Uri $requestUri -Method Patch -Body $requestBody -Header $headers -contentType "application/json"
36 | Write-Host "Updated retention settings for build ${buildId}."
37 | }
38 | catch {
39 | Write-Error "Failed to update retention settings for build: $_.Exception.Response.StatusDescription"
40 | exit 1
41 | }
42 | }
43 |
44 | Update-BuildRetention -azdoOrgUri $azdoOrgUri -azdoProject $azdoProject -buildId $buildId -token $token
45 | exit 0
46 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/extensioninfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDP_EXTENSION_INFO_H
7 | #define XDP_EXTENSION_INFO_H
8 |
9 | #include
10 |
11 | #ifdef __cplusplus
12 | extern "C" {
13 | #endif
14 |
15 | typedef enum _XDP_EXTENSION_TYPE {
16 | XDP_EXTENSION_TYPE_FRAME,
17 | XDP_EXTENSION_TYPE_BUFFER,
18 | XDP_EXTENSION_TYPE_TX_FRAME_COMPLETION,
19 | } XDP_EXTENSION_TYPE;
20 |
21 | typedef struct _XDP_EXTENSION_INFO {
22 | XDP_OBJECT_HEADER Header;
23 | _Null_terminated_ CONST WCHAR *ExtensionName;
24 | UINT32 ExtensionVersion;
25 | XDP_EXTENSION_TYPE ExtensionType;
26 | } XDP_EXTENSION_INFO;
27 |
28 | #define XDP_EXTENSION_INFO_REVISION_1 1
29 |
30 | #define XDP_SIZEOF_EXTENSION_INFO_REVISION_1 \
31 | RTL_SIZEOF_THROUGH_FIELD(XDP_EXTENSION_INFO, ExtensionType)
32 |
33 | inline
34 | VOID
35 | XdpInitializeExtensionInfo(
36 | _Out_ XDP_EXTENSION_INFO *ExtensionInfo,
37 | _In_z_ CONST WCHAR *ExtensionName,
38 | _In_ UINT32 ExtensionVersion,
39 | _In_ XDP_EXTENSION_TYPE ExtensionType
40 | )
41 | {
42 | RtlZeroMemory(ExtensionInfo, sizeof(*ExtensionInfo));
43 | ExtensionInfo->Header.Revision = XDP_EXTENSION_INFO_REVISION_1;
44 | ExtensionInfo->Header.Size = XDP_SIZEOF_EXTENSION_INFO_REVISION_1;
45 |
46 | ExtensionInfo->ExtensionName = ExtensionName;
47 | ExtensionInfo->ExtensionVersion = ExtensionVersion;
48 | ExtensionInfo->ExtensionType = ExtensionType;
49 | }
50 |
51 | #ifdef __cplusplus
52 | } // extern "C"
53 | #endif
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/eng/common/sdl/run-sdl.ps1:
--------------------------------------------------------------------------------
1 | Param(
2 | [string] $GuardianCliLocation,
3 | [string] $WorkingDirectory,
4 | [string] $GdnFolder,
5 | [string] $UpdateBaseline,
6 | [string] $GuardianLoggerLevel='Standard'
7 | )
8 |
9 | $ErrorActionPreference = 'Stop'
10 | Set-StrictMode -Version 2.0
11 | $disableConfigureToolsetImport = $true
12 | $global:LASTEXITCODE = 0
13 |
14 | try {
15 | # `tools.ps1` checks $ci to perform some actions. Since the SDL
16 | # scripts don't necessarily execute in the same agent that run the
17 | # build.ps1/sh script this variable isn't automatically set.
18 | $ci = $true
19 | . $PSScriptRoot\..\tools.ps1
20 |
21 | # We store config files in the r directory of .gdn
22 | $gdnConfigPath = Join-Path $GdnFolder 'r'
23 | $ValidPath = Test-Path $GuardianCliLocation
24 |
25 | if ($ValidPath -eq $False)
26 | {
27 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location."
28 | ExitWithExitCode 1
29 | }
30 |
31 | $gdnConfigFiles = Get-ChildItem $gdnConfigPath -Recurse -Include '*.gdnconfig'
32 | Write-Host "Discovered Guardian config files:"
33 | $gdnConfigFiles | Out-String | Write-Host
34 |
35 | Exec-BlockVerbosely {
36 | & $GuardianCliLocation run `
37 | --working-directory $WorkingDirectory `
38 | --baseline mainbaseline `
39 | --update-baseline $UpdateBaseline `
40 | --logger-level $GuardianLoggerLevel `
41 | --config @gdnConfigFiles
42 | Exit-IfNZEC "Sdl"
43 | }
44 | }
45 | catch {
46 | Write-Host $_.ScriptStackTrace
47 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
48 | ExitWithExitCode 1
49 | }
50 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/rtl.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDP_RTL_H
7 | #define XDP_RTL_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | #ifndef RTL_PTR_ADD
14 | #define RTL_PTR_ADD(Pointer, Value) \
15 | ((VOID *)((ULONG_PTR)(Pointer) + (ULONG_PTR)(Value)))
16 | #endif
17 |
18 | #ifndef RTL_PTR_SUBTRACT
19 | #define RTL_PTR_SUBTRACT(Pointer, Value) \
20 | ((PVOID)((ULONG_PTR)(Pointer) - (ULONG_PTR)(Value)))
21 | #endif
22 |
23 | #if (!defined(NTDDI_WIN10_CO) || (WDK_NTDDI_VERSION < NTDDI_WIN10_CO)) && \
24 | !defined(UINT32_VOLATILE_ACCESSORS)
25 | #define UINT32_VOLATILE_ACCESSORS
26 |
27 | FORCEINLINE
28 | UINT32
29 | ReadUInt32Acquire(
30 | _In_ _Interlocked_operand_ UINT32 const volatile *Source
31 | )
32 | {
33 | return (UINT32)ReadULongAcquire((PULONG)Source);
34 | }
35 |
36 | FORCEINLINE
37 | UINT32
38 | ReadUInt32NoFence(
39 | _In_ _Interlocked_operand_ UINT32 const volatile *Source
40 | )
41 | {
42 | return (UINT32)ReadULongNoFence((PULONG)Source);
43 | }
44 |
45 | FORCEINLINE
46 | VOID
47 | WriteUInt32Release(
48 | _Out_ _Interlocked_operand_ UINT32 volatile *Destination,
49 | _In_ UINT32 Value
50 | )
51 | {
52 | WriteULongRelease((PULONG)Destination, (ULONG)Value);
53 | }
54 |
55 | FORCEINLINE
56 | VOID
57 | WriteUInt32NoFence(
58 | _Out_ _Interlocked_operand_ UINT32 volatile *Destination,
59 | _In_ UINT32 Value
60 | )
61 | {
62 | WriteULongNoFence((PULONG)Destination, (ULONG)Value);
63 | }
64 |
65 | #endif
66 |
67 | #ifdef __cplusplus
68 | } // extern "C"
69 | #endif
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/eng/common/post-build/add-build-to-channel.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [Parameter(Mandatory=$true)][int] $BuildId,
3 | [Parameter(Mandatory=$true)][int] $ChannelId,
4 | [Parameter(Mandatory=$true)][string] $MaestroApiAccessToken,
5 | [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro.dot.net',
6 | [Parameter(Mandatory=$false)][string] $MaestroApiVersion = '2019-01-16'
7 | )
8 |
9 | try {
10 | . $PSScriptRoot\post-build-utils.ps1
11 |
12 | # Check that the channel we are going to promote the build to exist
13 | $channelInfo = Get-MaestroChannel -ChannelId $ChannelId
14 |
15 | if (!$channelInfo) {
16 | Write-PipelineTelemetryCategory -Category 'PromoteBuild' -Message "Channel with BAR ID $ChannelId was not found in BAR!"
17 | ExitWithExitCode 1
18 | }
19 |
20 | # Get info about which channel(s) the build has already been promoted to
21 | $buildInfo = Get-MaestroBuild -BuildId $BuildId
22 |
23 | if (!$buildInfo) {
24 | Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "Build with BAR ID $BuildId was not found in BAR!"
25 | ExitWithExitCode 1
26 | }
27 |
28 | # Find whether the build is already assigned to the channel or not
29 | if ($buildInfo.channels) {
30 | foreach ($channel in $buildInfo.channels) {
31 | if ($channel.Id -eq $ChannelId) {
32 | Write-Host "The build with BAR ID $BuildId is already on channel $ChannelId!"
33 | ExitWithExitCode 0
34 | }
35 | }
36 | }
37 |
38 | Write-Host "Promoting build '$BuildId' to channel '$ChannelId'."
39 |
40 | Assign-BuildToChannel -BuildId $BuildId -ChannelId $ChannelId
41 |
42 | Write-Host 'done.'
43 | }
44 | catch {
45 | Write-Host $_
46 | Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to promote build '$BuildId' to channel '$ChannelId'"
47 | ExitWithExitCode 1
48 | }
49 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/details/datapath.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #include
11 | #include
12 |
13 | typedef
14 | _IRQL_requires_max_(DISPATCH_LEVEL)
15 | VOID
16 | XDP_RECEIVE(
17 | _In_ XDP_RX_QUEUE_HANDLE XdpRxQueue
18 | );
19 |
20 | typedef
21 | _IRQL_requires_max_(DISPATCH_LEVEL)
22 | VOID
23 | XDP_FLUSH_RECEIVE(
24 | _In_ XDP_RX_QUEUE_HANDLE XdpRxQueue
25 | );
26 |
27 | typedef struct _XDP_RX_QUEUE_DISPATCH {
28 | XDP_RECEIVE *Receive;
29 | XDP_FLUSH_RECEIVE *FlushReceive;
30 | } XDP_RX_QUEUE_DISPATCH;
31 |
32 | inline
33 | _IRQL_requires_max_(DISPATCH_LEVEL)
34 | VOID
35 | XDPEXPORT(XdpReceive)(
36 | _In_ XDP_RX_QUEUE_HANDLE XdpRxQueue
37 | )
38 | {
39 | CONST XDP_RX_QUEUE_DISPATCH *Dispatch = (CONST XDP_RX_QUEUE_DISPATCH *)XdpRxQueue;
40 | Dispatch->Receive(XdpRxQueue);
41 | }
42 |
43 | inline
44 | _IRQL_requires_max_(DISPATCH_LEVEL)
45 | VOID
46 | XDPEXPORT(XdpFlushReceive)(
47 | _In_ XDP_RX_QUEUE_HANDLE XdpRxQueue
48 | )
49 | {
50 | CONST XDP_RX_QUEUE_DISPATCH *Dispatch = (CONST XDP_RX_QUEUE_DISPATCH *)XdpRxQueue;
51 | Dispatch->FlushReceive(XdpRxQueue);
52 | }
53 |
54 | typedef
55 | _IRQL_requires_max_(DISPATCH_LEVEL)
56 | VOID
57 | XDP_FLUSH_TRANSMIT(
58 | _In_ XDP_TX_QUEUE_HANDLE XdpTxQueue
59 | );
60 |
61 | typedef struct _XDP_TX_QUEUE_DISPATCH {
62 | XDP_FLUSH_TRANSMIT *FlushTransmit;
63 | } XDP_TX_QUEUE_DISPATCH;
64 |
65 | inline
66 | _IRQL_requires_max_(DISPATCH_LEVEL)
67 | VOID
68 | XDPEXPORT(XdpFlushTransmit)(
69 | _In_ XDP_TX_QUEUE_HANDLE XdpTxQueue
70 | )
71 | {
72 | CONST XDP_TX_QUEUE_DISPATCH *Dispatch = (CONST XDP_TX_QUEUE_DISPATCH *)XdpTxQueue;
73 | Dispatch->FlushTransmit(XdpTxQueue);
74 | }
75 |
76 | EXTERN_C_END
77 |
--------------------------------------------------------------------------------
/eng/common/loc/P22DotNetHtmlLocalization.lss:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/install-dependencies.ps1:
--------------------------------------------------------------------------------
1 | Set-StrictMode -Version 'Latest'
2 | $PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
3 | $ProgressPreference = 'SilentlyContinue'
4 |
5 | # Root directory of the project.
6 | $RootDir = Split-Path $PSScriptRoot -Parent
7 | $NuGetPath = Join-Path $RootDir "nuget"
8 |
9 | # Well-known location for clog packages.
10 | $ClogVersion = "0.2.0"
11 | $ClogDownloadUrl = "https://github.com/microsoft/CLOG/releases/download/v$ClogVersion"
12 | $toolsLocation = "$RootDir/src/msquic/artifacts/dotnet-tools"
13 | $installLocal = $false
14 |
15 | if (-not [string]::IsNullOrEmpty($env:AGENT_NAME)) {
16 | $installLocal = $true
17 | }
18 |
19 | function Install-ClogTool {
20 | param($ToolName)
21 | New-Item -Path $NuGetPath -ItemType Directory -Force | Out-Null
22 | $NuGetName = "$ToolName.$ClogVersion.nupkg"
23 | $NuGetFile = Join-Path $NuGetPath $NuGetName
24 | try {
25 | if (!(Test-Path $NuGetFile)) {
26 | Write-Host "Downloading $ClogDownloadUrl/$NuGetName"
27 | Invoke-WebRequest -Uri "$ClogDownloadUrl/$NuGetName" -OutFile $NuGetFile
28 | }
29 | Write-Host "Installing: $NuGetName"
30 | if ($installLocal) {
31 | dotnet tool update --tool-path $toolsLocation --add-source $NuGetPath $ToolName
32 | }
33 | else {
34 | dotnet tool update --global --add-source $NuGetPath $ToolName
35 | }
36 | } catch {
37 | if ($FailOnError) {
38 | Write-Error $_
39 | }
40 | $err = $_
41 | $MessagesAtEnd.Add("$ToolName could not be installed. Building with logs will not work")
42 | $MessagesAtEnd.Add($err.ToString())
43 | }
44 | }
45 |
46 | Install-ClogTool "Microsoft.Logging.CLOG"
47 | if ($IsWindows) {
48 | Install-ClogTool "Microsoft.Logging.CLOG2Text.Windows"
49 | } elseif ($IsLinux) {
50 | Install-ClogTool "Microsoft.Logging.CLOG2Text.Lttng"
51 | }
52 |
53 | if ($installLocal) {
54 | echo "##vso[task.prependpath]$toolsLocation"
55 | }
56 |
--------------------------------------------------------------------------------
/eng/common/post-build/check-channel-consistency.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [Parameter(Mandatory=$true)][string] $PromoteToChannels, # List of channels that the build should be promoted to
3 | [Parameter(Mandatory=$true)][array] $AvailableChannelIds # List of channel IDs available in the YAML implementation
4 | )
5 |
6 | try {
7 | . $PSScriptRoot\post-build-utils.ps1
8 |
9 | if ($PromoteToChannels -eq "") {
10 | Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info."
11 | ExitWithExitCode 0
12 | }
13 |
14 | # Check that every channel that Maestro told to promote the build to
15 | # is available in YAML
16 | $PromoteToChannelsIds = $PromoteToChannels -split "\D" | Where-Object { $_ }
17 |
18 | $hasErrors = $false
19 |
20 | foreach ($id in $PromoteToChannelsIds) {
21 | if (($id -ne 0) -and ($id -notin $AvailableChannelIds)) {
22 | Write-PipelineTaskError -Message "Channel $id is not present in the post-build YAML configuration! This is an error scenario. Please contact @dnceng."
23 | $hasErrors = $true
24 | }
25 | }
26 |
27 | # The `Write-PipelineTaskError` doesn't error the script and we might report several errors
28 | # in the previous lines. The check below makes sure that we return an error state from the
29 | # script if we reported any validation error
30 | if ($hasErrors) {
31 | ExitWithExitCode 1
32 | }
33 |
34 | Write-Host 'done.'
35 | }
36 | catch {
37 | Write-Host $_
38 | Write-PipelineTelemetryError -Category 'CheckChannelConsistency' -Message "There was an error while trying to check consistency of Maestro default channels for the build and post-build YAML configuration."
39 | ExitWithExitCode 1
40 | }
41 |
--------------------------------------------------------------------------------
/eng/common/darc-init.ps1:
--------------------------------------------------------------------------------
1 | param (
2 | $darcVersion = $null,
3 | $versionEndpoint = 'https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16',
4 | $verbosity = 'minimal',
5 | $toolpath = $null
6 | )
7 |
8 | . $PSScriptRoot\tools.ps1
9 |
10 | function InstallDarcCli ($darcVersion, $toolpath) {
11 | $darcCliPackageName = 'microsoft.dotnet.darc'
12 |
13 | $dotnetRoot = InitializeDotNetCli -install:$true
14 | $dotnet = "$dotnetRoot\dotnet.exe"
15 | $toolList = & "$dotnet" tool list -g
16 |
17 | if ($toolList -like "*$darcCliPackageName*") {
18 | & "$dotnet" tool uninstall $darcCliPackageName -g
19 | }
20 |
21 | # If the user didn't explicitly specify the darc version,
22 | # query the Maestro API for the correct version of darc to install.
23 | if (-not $darcVersion) {
24 | $darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content
25 | }
26 |
27 | $arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json'
28 |
29 | Write-Host "Installing Darc CLI version $darcVersion..."
30 | Write-Host 'You may need to restart your command window if this is the first dotnet tool you have installed.'
31 | if (-not $toolpath) {
32 | Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity -g"
33 | & "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g
34 | }else {
35 | Write-Host "'$dotnet' tool install $darcCliPackageName --version $darcVersion --add-source '$arcadeServicesSource' -v $verbosity --tool-path '$toolpath'"
36 | & "$dotnet" tool install $darcCliPackageName --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath"
37 | }
38 | }
39 |
40 | try {
41 | InstallDarcCli $darcVersion $toolpath
42 | }
43 | catch {
44 | Write-Host $_.ScriptStackTrace
45 | Write-PipelineTelemetryError -Category 'Darc' -Message $_
46 | ExitWithExitCode 1
47 | }
--------------------------------------------------------------------------------
/eng/common/post-build/publish-using-darc.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [Parameter(Mandatory=$true)][int] $BuildId,
3 | [Parameter(Mandatory=$true)][int] $PublishingInfraVersion,
4 | [Parameter(Mandatory=$true)][string] $AzdoToken,
5 | [Parameter(Mandatory=$true)][string] $MaestroToken,
6 | [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro.dot.net',
7 | [Parameter(Mandatory=$true)][string] $WaitPublishingFinish,
8 | [Parameter(Mandatory=$false)][string] $ArtifactsPublishingAdditionalParameters,
9 | [Parameter(Mandatory=$false)][string] $SymbolPublishingAdditionalParameters
10 | )
11 |
12 | try {
13 | . $PSScriptRoot\post-build-utils.ps1
14 |
15 | $darc = Get-Darc
16 |
17 | $optionalParams = [System.Collections.ArrayList]::new()
18 |
19 | if ("" -ne $ArtifactsPublishingAdditionalParameters) {
20 | $optionalParams.Add("--artifact-publishing-parameters") | Out-Null
21 | $optionalParams.Add($ArtifactsPublishingAdditionalParameters) | Out-Null
22 | }
23 |
24 | if ("" -ne $SymbolPublishingAdditionalParameters) {
25 | $optionalParams.Add("--symbol-publishing-parameters") | Out-Null
26 | $optionalParams.Add($SymbolPublishingAdditionalParameters) | Out-Null
27 | }
28 |
29 | if ("false" -eq $WaitPublishingFinish) {
30 | $optionalParams.Add("--no-wait") | Out-Null
31 | }
32 |
33 | & $darc add-build-to-channel `
34 | --id $buildId `
35 | --publishing-infra-version $PublishingInfraVersion `
36 | --default-channels `
37 | --source-branch main `
38 | --azdev-pat $AzdoToken `
39 | --bar-uri $MaestroApiEndPoint `
40 | --password $MaestroToken `
41 | @optionalParams
42 |
43 | if ($LastExitCode -ne 0) {
44 | Write-Host "Problems using Darc to promote build ${buildId} to default channels. Stopping execution..."
45 | exit 1
46 | }
47 |
48 | Write-Host 'done.'
49 | }
50 | catch {
51 | Write-Host $_
52 | Write-PipelineTelemetryError -Category 'PromoteBuild' -Message "There was an error while trying to publish build '$BuildId' to default channels."
53 | ExitWithExitCode 1
54 | }
55 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/System.Net.MsQuic.Transport.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | true
6 | false
7 | true
8 | false
9 | false
10 |
11 | $(NoWarn);NU5128
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | $(ExtraMsquicArgs) -SysRoot /crossrootfs/$(TargetArchitecture)
21 |
22 |
23 |
24 |
27 |
31 |
32 |
33 |
35 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/eng/common/internal/Tools.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | net472
6 | false
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | https://devdiv.pkgs.visualstudio.com/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json;
22 |
23 |
24 | $(RestoreSources);
25 | https://devdiv.pkgs.visualstudio.com/_packaging/VS/nuget/v3/index.json;
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/eng/common/templates/jobs/source-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # This template adds arcade-powered source-build to CI. A job is created for each platform, as
3 | # well as an optional server job that completes when all platform jobs complete.
4 |
5 | # The name of the "join" job for all source-build platforms. If set to empty string, the job is
6 | # not included. Existing repo pipelines can use this job depend on all source-build jobs
7 | # completing without maintaining a separate list of every single job ID: just depend on this one
8 | # server job. By default, not included. Recommended name if used: 'Source_Build_Complete'.
9 | allCompletedJobId: ''
10 |
11 | # See /eng/common/templates/job/source-build.yml
12 | jobNamePrefix: 'Source_Build'
13 |
14 | # This is the default platform provided by Arcade, intended for use by a managed-only repo.
15 | defaultManagedPlatform:
16 | name: 'Managed'
17 | container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8'
18 |
19 | # Defines the platforms on which to run build jobs. One job is created for each platform, and the
20 | # object in this array is sent to the job template as 'platform'. If no platforms are specified,
21 | # one job runs on 'defaultManagedPlatform'.
22 | platforms: []
23 |
24 | jobs:
25 |
26 | - ${{ if ne(parameters.allCompletedJobId, '') }}:
27 | - job: ${{ parameters.allCompletedJobId }}
28 | displayName: Source-Build Complete
29 | pool: server
30 | dependsOn:
31 | - ${{ each platform in parameters.platforms }}:
32 | - ${{ parameters.jobNamePrefix }}_${{ platform.name }}
33 | - ${{ if eq(length(parameters.platforms), 0) }}:
34 | - ${{ parameters.jobNamePrefix }}_${{ parameters.defaultManagedPlatform.name }}
35 |
36 | - ${{ each platform in parameters.platforms }}:
37 | - template: /eng/common/templates/job/source-build.yml
38 | parameters:
39 | jobNamePrefix: ${{ parameters.jobNamePrefix }}
40 | platform: ${{ platform }}
41 |
42 | - ${{ if eq(length(parameters.platforms), 0) }}:
43 | - template: /eng/common/templates/job/source-build.yml
44 | parameters:
45 | jobNamePrefix: ${{ parameters.jobNamePrefix }}
46 | platform: ${{ parameters.defaultManagedPlatform }}
47 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/execute-codeql.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # Language that should be analyzed. Defaults to csharp
3 | language: csharp
4 | # Build Commands
5 | buildCommands: ''
6 | overrideParameters: '' # Optional: to override values for parameters.
7 | additionalParameters: '' # Optional: parameters that need user specific values eg: '-SourceToolsList @("abc","def") -ArtifactToolsList @("ghi","jkl")'
8 | # Optional: if specified, restore and use this version of Guardian instead of the default.
9 | overrideGuardianVersion: ''
10 | # Optional: if true, publish the '.gdn' folder as a pipeline artifact. This can help with in-depth
11 | # diagnosis of problems with specific tool configurations.
12 | publishGuardianDirectoryToPipeline: false
13 | # The script to run to execute all SDL tools. Use this if you want to use a script to define SDL
14 | # parameters rather than relying on YAML. It may be better to use a local script, because you can
15 | # reproduce results locally without piecing together a command based on the YAML.
16 | executeAllSdlToolsScript: 'eng/common/sdl/execute-all-sdl-tools.ps1'
17 | # There is some sort of bug (has been reported) in Azure DevOps where if this parameter is named
18 | # 'continueOnError', the parameter value is not correctly picked up.
19 | # This can also be remedied by the caller (post-build.yml) if it does not use a nested parameter
20 | # optional: determines whether to continue the build if the step errors;
21 | sdlContinueOnError: false
22 |
23 | steps:
24 | - template: /eng/common/templates/steps/execute-sdl.yml
25 | parameters:
26 | overrideGuardianVersion: ${{ parameters.overrideGuardianVersion }}
27 | executeAllSdlToolsScript: ${{ parameters.executeAllSdlToolsScript }}
28 | overrideParameters: ${{ parameters.overrideParameters }}
29 | additionalParameters: '${{ parameters.additionalParameters }}
30 | -CodeQLAdditionalRunConfigParams @("BuildCommands < ${{ parameters.buildCommands }}", "Language < ${{ parameters.language }}")'
31 | publishGuardianDirectoryToPipeline: ${{ parameters.publishGuardianDirectoryToPipeline }}
32 | sdlContinueOnError: ${{ parameters.sdlContinueOnError }}
--------------------------------------------------------------------------------
/eng/common/templates-official/jobs/source-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # This template adds arcade-powered source-build to CI. A job is created for each platform, as
3 | # well as an optional server job that completes when all platform jobs complete.
4 |
5 | # The name of the "join" job for all source-build platforms. If set to empty string, the job is
6 | # not included. Existing repo pipelines can use this job depend on all source-build jobs
7 | # completing without maintaining a separate list of every single job ID: just depend on this one
8 | # server job. By default, not included. Recommended name if used: 'Source_Build_Complete'.
9 | allCompletedJobId: ''
10 |
11 | # See /eng/common/templates-official/job/source-build.yml
12 | jobNamePrefix: 'Source_Build'
13 |
14 | # This is the default platform provided by Arcade, intended for use by a managed-only repo.
15 | defaultManagedPlatform:
16 | name: 'Managed'
17 | container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8'
18 |
19 | # Defines the platforms on which to run build jobs. One job is created for each platform, and the
20 | # object in this array is sent to the job template as 'platform'. If no platforms are specified,
21 | # one job runs on 'defaultManagedPlatform'.
22 | platforms: []
23 |
24 | jobs:
25 |
26 | - ${{ if ne(parameters.allCompletedJobId, '') }}:
27 | - job: ${{ parameters.allCompletedJobId }}
28 | displayName: Source-Build Complete
29 | pool: server
30 | dependsOn:
31 | - ${{ each platform in parameters.platforms }}:
32 | - ${{ parameters.jobNamePrefix }}_${{ platform.name }}
33 | - ${{ if eq(length(parameters.platforms), 0) }}:
34 | - ${{ parameters.jobNamePrefix }}_${{ parameters.defaultManagedPlatform.name }}
35 |
36 | - ${{ each platform in parameters.platforms }}:
37 | - template: /eng/common/templates-official/job/source-build.yml
38 | parameters:
39 | jobNamePrefix: ${{ parameters.jobNamePrefix }}
40 | platform: ${{ platform }}
41 |
42 | - ${{ if eq(length(parameters.platforms), 0) }}:
43 | - template: /eng/common/templates-official/job/source-build.yml
44 | parameters:
45 | jobNamePrefix: ${{ parameters.jobNamePrefix }}
46 | platform: ${{ parameters.defaultManagedPlatform }}
47 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/publish-logs.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | StageLabel: ''
3 | JobLabel: ''
4 | CustomSensitiveDataList: ''
5 | # A default - in case value from eng/common/templates/post-build/common-variables.yml is not passed
6 | BinlogToolVersion: '1.0.11'
7 |
8 | steps:
9 | - task: Powershell@2
10 | displayName: Prepare Binlogs to Upload
11 | inputs:
12 | targetType: inline
13 | script: |
14 | New-Item -ItemType Directory $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/
15 | Move-Item -Path $(Build.SourcesDirectory)/artifacts/log/Debug/* $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/
16 | continueOnError: true
17 | condition: always()
18 |
19 | - task: PowerShell@2
20 | displayName: Redact Logs
21 | inputs:
22 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/redact-logs.ps1
23 | # For now this needs to have explicit list of all sensitive data. Taken from eng/publishing/v3/publish.yml
24 | # Sensitive data can as well be added to $(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt'
25 | # If the file exists - sensitive data for redaction will be sourced from it
26 | # (single entry per line, lines starting with '# ' are considered comments and skipped)
27 | arguments: -InputPath '$(Build.SourcesDirectory)/PostBuildLogs'
28 | -BinlogToolVersion ${{parameters.BinlogToolVersion}}
29 | -TokensFilePath '$(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt'
30 | '$(publishing-dnceng-devdiv-code-r-build-re)'
31 | '$(MaestroAccessToken)'
32 | '$(dn-bot-all-orgs-artifact-feeds-rw)'
33 | '$(akams-client-id)'
34 | '$(akams-client-secret)'
35 | '$(microsoft-symbol-server-pat)'
36 | '$(symweb-symbol-server-pat)'
37 | '$(dn-bot-all-orgs-build-rw-code-rw)'
38 | ${{parameters.CustomSensitiveDataList}}
39 | continueOnError: true
40 | condition: always()
41 |
42 | - task: PublishBuildArtifacts@1
43 | displayName: Publish Logs
44 | inputs:
45 | PathtoPublish: '$(Build.SourcesDirectory)/PostBuildLogs'
46 | PublishLocation: Container
47 | ArtifactName: PostBuildLogs
48 | continueOnError: true
49 | condition: always()
50 |
--------------------------------------------------------------------------------
/eng/common/native/init-os-and-arch.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Use uname to determine what the OS is.
4 | OSName=$(uname -s | tr '[:upper:]' '[:lower:]')
5 |
6 | if command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then
7 | OSName="android"
8 | fi
9 |
10 | case "$OSName" in
11 | freebsd|linux|netbsd|openbsd|sunos|android|haiku)
12 | os="$OSName" ;;
13 | darwin)
14 | os=osx ;;
15 | *)
16 | echo "Unsupported OS $OSName detected!"
17 | exit 1 ;;
18 | esac
19 |
20 | # On Solaris, `uname -m` is discouraged, see https://docs.oracle.com/cd/E36784_01/html/E36870/uname-1.html
21 | # and `uname -p` returns processor type (e.g. i386 on amd64).
22 | # The appropriate tool to determine CPU is isainfo(1) https://docs.oracle.com/cd/E36784_01/html/E36870/isainfo-1.html.
23 | if [ "$os" = "sunos" ]; then
24 | if uname -o 2>&1 | grep -q illumos; then
25 | os="illumos"
26 | else
27 | os="solaris"
28 | fi
29 | CPUName=$(isainfo -n)
30 | else
31 | # For the rest of the operating systems, use uname(1) to determine what the CPU is.
32 | CPUName=$(uname -m)
33 | fi
34 |
35 | case "$CPUName" in
36 | arm64|aarch64)
37 | arch=arm64
38 | if [ "$(getconf LONG_BIT)" -lt 64 ]; then
39 | # This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS)
40 | arch=arm
41 | fi
42 | ;;
43 |
44 | loongarch64)
45 | arch=loongarch64
46 | ;;
47 |
48 | riscv64)
49 | arch=riscv64
50 | ;;
51 |
52 | amd64|x86_64)
53 | arch=x64
54 | ;;
55 |
56 | armv7l|armv8l)
57 | # shellcheck disable=SC1091
58 | if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
59 | arch=armel
60 | else
61 | arch=arm
62 | fi
63 | ;;
64 |
65 | armv6l)
66 | arch=armv6
67 | ;;
68 |
69 | i[3-6]86)
70 | echo "Unsupported CPU $CPUName detected, build might not succeed!"
71 | arch=x86
72 | ;;
73 |
74 | s390x)
75 | arch=s390x
76 | ;;
77 |
78 | ppc64le)
79 | arch=ppc64le
80 | ;;
81 | *)
82 | echo "Unknown CPU $CPUName detected!"
83 | exit 1
84 | ;;
85 | esac
86 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/publish-logs.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | StageLabel: ''
3 | JobLabel: ''
4 | CustomSensitiveDataList: ''
5 | # A default - in case value from eng/common/templates-official/post-build/common-variables.yml is not passed
6 | BinlogToolVersion: '1.0.11'
7 |
8 | steps:
9 | - task: Powershell@2
10 | displayName: Prepare Binlogs to Upload
11 | inputs:
12 | targetType: inline
13 | script: |
14 | New-Item -ItemType Directory $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/
15 | Move-Item -Path $(Build.SourcesDirectory)/artifacts/log/Debug/* $(Build.SourcesDirectory)/PostBuildLogs/${{parameters.StageLabel}}/${{parameters.JobLabel}}/
16 | continueOnError: true
17 | condition: always()
18 |
19 | - task: PowerShell@2
20 | displayName: Redact Logs
21 | inputs:
22 | filePath: $(Build.SourcesDirectory)/eng/common/post-build/redact-logs.ps1
23 | # For now this needs to have explicit list of all sensitive data. Taken from eng/publishing/v3/publish.yml
24 | # Sensitive data can as well be added to $(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt'
25 | # If the file exists - sensitive data for redaction will be sourced from it
26 | # (single entry per line, lines starting with '# ' are considered comments and skipped)
27 | arguments: -InputPath '$(Build.SourcesDirectory)/PostBuildLogs'
28 | -BinlogToolVersion ${{parameters.BinlogToolVersion}}
29 | -TokensFilePath '$(Build.SourcesDirectory)/eng/BinlogSecretsRedactionFile.txt'
30 | '$(publishing-dnceng-devdiv-code-r-build-re)'
31 | '$(MaestroAccessToken)'
32 | '$(dn-bot-all-orgs-artifact-feeds-rw)'
33 | '$(akams-client-id)'
34 | '$(akams-client-secret)'
35 | '$(microsoft-symbol-server-pat)'
36 | '$(symweb-symbol-server-pat)'
37 | '$(dn-bot-all-orgs-build-rw-code-rw)'
38 | ${{parameters.CustomSensitiveDataList}}
39 | continueOnError: true
40 | condition: always()
41 |
42 | - task: 1ES.PublishBuildArtifacts@1
43 | displayName: Publish Logs
44 | inputs:
45 | PathtoPublish: '$(Build.SourcesDirectory)/PostBuildLogs'
46 | PublishLocation: Container
47 | ArtifactName: PostBuildLogs
48 | continueOnError: true
49 | condition: always()
50 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/generate-sbom.yml:
--------------------------------------------------------------------------------
1 | # BuildDropPath - The root folder of the drop directory for which the manifest file will be generated.
2 | # PackageName - The name of the package this SBOM represents.
3 | # PackageVersion - The version of the package this SBOM represents.
4 | # ManifestDirPath - The path of the directory where the generated manifest files will be placed
5 | # IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector.
6 |
7 | parameters:
8 | PackageVersion: 7.0.0
9 | BuildDropPath: '$(Build.SourcesDirectory)/artifacts'
10 | PackageName: '.NET'
11 | ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom
12 | IgnoreDirectories: ''
13 | sbomContinueOnError: true
14 |
15 | steps:
16 | - task: PowerShell@2
17 | displayName: Prep for SBOM generation in (Non-linux)
18 | condition: or(eq(variables['Agent.Os'], 'Windows_NT'), eq(variables['Agent.Os'], 'Darwin'))
19 | inputs:
20 | filePath: ./eng/common/generate-sbom-prep.ps1
21 | arguments: ${{parameters.manifestDirPath}}
22 |
23 | # Chmodding is a workaround for https://github.com/dotnet/arcade/issues/8461
24 | - script: |
25 | chmod +x ./eng/common/generate-sbom-prep.sh
26 | ./eng/common/generate-sbom-prep.sh ${{parameters.manifestDirPath}}
27 | displayName: Prep for SBOM generation in (Linux)
28 | condition: eq(variables['Agent.Os'], 'Linux')
29 | continueOnError: ${{ parameters.sbomContinueOnError }}
30 |
31 | - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
32 | displayName: 'Generate SBOM manifest'
33 | continueOnError: ${{ parameters.sbomContinueOnError }}
34 | inputs:
35 | PackageName: ${{ parameters.packageName }}
36 | BuildDropPath: ${{ parameters.buildDropPath }}
37 | PackageVersion: ${{ parameters.packageVersion }}
38 | ManifestDirPath: ${{ parameters.manifestDirPath }}
39 | ${{ if ne(parameters.IgnoreDirectories, '') }}:
40 | AdditionalComponentDetectorArgs: '--IgnoreDirectories ${{ parameters.IgnoreDirectories }}'
41 |
42 | - task: PublishPipelineArtifact@1
43 | displayName: Publish SBOM manifest
44 | continueOnError: ${{parameters.sbomContinueOnError}}
45 | inputs:
46 | targetPath: '${{parameters.manifestDirPath}}'
47 | artifactName: $(ARTIFACT_NAME)
48 |
49 |
--------------------------------------------------------------------------------
/eng/common/templates-official/steps/generate-sbom.yml:
--------------------------------------------------------------------------------
1 | # BuildDropPath - The root folder of the drop directory for which the manifest file will be generated.
2 | # PackageName - The name of the package this SBOM represents.
3 | # PackageVersion - The version of the package this SBOM represents.
4 | # ManifestDirPath - The path of the directory where the generated manifest files will be placed
5 | # IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector.
6 |
7 | parameters:
8 | PackageVersion: 7.0.0
9 | BuildDropPath: '$(Build.SourcesDirectory)/artifacts'
10 | PackageName: '.NET'
11 | ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom
12 | IgnoreDirectories: ''
13 | sbomContinueOnError: true
14 |
15 | steps:
16 | - task: PowerShell@2
17 | displayName: Prep for SBOM generation in (Non-linux)
18 | condition: or(eq(variables['Agent.Os'], 'Windows_NT'), eq(variables['Agent.Os'], 'Darwin'))
19 | inputs:
20 | filePath: ./eng/common/generate-sbom-prep.ps1
21 | arguments: ${{parameters.manifestDirPath}}
22 |
23 | # Chmodding is a workaround for https://github.com/dotnet/arcade/issues/8461
24 | - script: |
25 | chmod +x ./eng/common/generate-sbom-prep.sh
26 | ./eng/common/generate-sbom-prep.sh ${{parameters.manifestDirPath}}
27 | displayName: Prep for SBOM generation in (Linux)
28 | condition: eq(variables['Agent.Os'], 'Linux')
29 | continueOnError: ${{ parameters.sbomContinueOnError }}
30 |
31 | - task: AzureArtifacts.manifest-generator-task.manifest-generator-task.ManifestGeneratorTask@0
32 | displayName: 'Generate SBOM manifest'
33 | continueOnError: ${{ parameters.sbomContinueOnError }}
34 | inputs:
35 | PackageName: ${{ parameters.packageName }}
36 | BuildDropPath: ${{ parameters.buildDropPath }}
37 | PackageVersion: ${{ parameters.packageVersion }}
38 | ManifestDirPath: ${{ parameters.manifestDirPath }}
39 | ${{ if ne(parameters.IgnoreDirectories, '') }}:
40 | AdditionalComponentDetectorArgs: '--IgnoreDirectories ${{ parameters.IgnoreDirectories }}'
41 |
42 | - task: 1ES.PublishPipelineArtifact@1
43 | displayName: Publish SBOM manifest
44 | continueOnError: ${{parameters.sbomContinueOnError}}
45 | inputs:
46 | targetPath: '${{parameters.manifestDirPath}}'
47 | artifactName: $(ARTIFACT_NAME)
48 |
49 |
--------------------------------------------------------------------------------
/eng/common/templates-official/variables/pool-providers.yml:
--------------------------------------------------------------------------------
1 | # Select a pool provider based off branch name. Anything with branch name containing 'release' must go into an -Svc pool,
2 | # otherwise it should go into the "normal" pools. This separates out the queueing and billing of released branches.
3 |
4 | # Motivation:
5 | # Once a given branch of a repository's output has been officially "shipped" once, it is then considered to be COGS
6 | # (Cost of goods sold) and should be moved to a servicing pool provider. This allows both separation of queueing
7 | # (allowing release builds and main PR builds to not intefere with each other) and billing (required for COGS.
8 | # Additionally, the pool provider name itself may be subject to change when the .NET Core Engineering Services
9 | # team needs to move resources around and create new and potentially differently-named pools. Using this template
10 | # file from an Arcade-ified repo helps guard against both having to update one's release/* branches and renaming.
11 |
12 | # How to use:
13 | # This yaml assumes your shipped product branches use the naming convention "release/..." (which many do).
14 | # If we find alternate naming conventions in broad usage it can be added to the condition below.
15 | #
16 | # First, import the template in an arcade-ified repo to pick up the variables, e.g.:
17 | #
18 | # variables:
19 | # - template: /eng/common/templates-official/variables/pool-providers.yml
20 | #
21 | # ... then anywhere specifying the pool provider use the runtime variables,
22 | # $(DncEngInternalBuildPool)
23 | #
24 | # pool:
25 | # name: $(DncEngInternalBuildPool)
26 | # image: 1es-windows-2022
27 |
28 | variables:
29 | # Coalesce the target and source branches so we know when a PR targets a release branch
30 | # If these variables are somehow missing, fall back to main (tends to have more capacity)
31 |
32 | # Any new -Svc alternative pools should have variables added here to allow for splitting work
33 |
34 | - name: DncEngInternalBuildPool
35 | value: $[
36 | replace(
37 | replace(
38 | eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'),
39 | True,
40 | 'NetCore1ESPool-Svc-Internal'
41 | ),
42 | False,
43 | 'NetCore1ESPool-Internal'
44 | )
45 | ]
--------------------------------------------------------------------------------
/src/xdp/include/xdp/ndis6poll.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | //
9 | // This file contains tentative definitions of NDIS polling API extensions for
10 | // XDP as well as a compatibility shim for older NDIS polling API versions.
11 | //
12 |
13 | EXTERN_C_START
14 |
15 | #if NDIS_SUPPORT_NDIS685
16 |
17 | #include
18 |
19 | typedef struct _XDP_POLL_TRANSMIT_DATA {
20 | //
21 | // The number of TX frames completed to the XDP platform.
22 | //
23 | UINT32 FramesCompleted;
24 |
25 | //
26 | // The number of TX frames injected from the XDP platform.
27 | //
28 | UINT32 FramesTransmitted;
29 | } XDP_POLL_TRANSMIT_DATA;
30 |
31 | typedef struct _XDP_POLL_RECEIVE_DATA {
32 | //
33 | // The number of RX frames absorbed by the XDP platform.
34 | //
35 | UINT32 FramesAbsorbed;
36 | } XDP_POLL_RECEIVE_DATA;
37 |
38 | typedef struct _XDP_POLL_DATA {
39 | XDP_POLL_TRANSMIT_DATA Transmit;
40 | XDP_POLL_RECEIVE_DATA Receive;
41 | } XDP_POLL_DATA;
42 |
43 | typedef
44 | _IRQL_requires_max_(HIGH_LEVEL)
45 | VOID
46 | XDP_NDIS_REQUEST_POLL(
47 | _In_ NDIS_POLL_HANDLE PollHandle,
48 | _Reserved_ VOID *Reserved
49 | );
50 |
51 | //
52 | // This routine provides compatibility with NDIS polling APIs that lack support
53 | // for XDP polling extensions. XDP interface drivers must invoke this helper (or
54 | // a similar custom routine) prior to returning from their NDIS poll callback.
55 | //
56 | inline
57 | _IRQL_requires_max_(DISPATCH_LEVEL)
58 | VOID
59 | XdpCompleteNdisPoll(
60 | _In_ NDIS_POLL_HANDLE PollHandle,
61 | _In_ NDIS_POLL_DATA *Poll,
62 | _In_ XDP_POLL_DATA *XdpPoll,
63 | _In_ XDP_NDIS_REQUEST_POLL *RequestPoll
64 | )
65 | {
66 | if (Poll->Receive.IndicatedNblChain != NULL || Poll->Transmit.CompletedNblChain != NULL) {
67 | //
68 | // If NBL chains are returned to NDIS, a poll is implicitly requested.
69 | //
70 | return;
71 | }
72 |
73 | if (XdpPoll->Transmit.FramesCompleted > 0 || XdpPoll->Transmit.FramesTransmitted > 0 ||
74 | XdpPoll->Receive.FramesAbsorbed > 0) {
75 | //
76 | // XDP made forward progress, and this was not observable to NDIS.
77 | // Explicitly request another poll.
78 | //
79 | RequestPoll(PollHandle, NULL);
80 | }
81 | }
82 |
83 | #endif // NDIS_SUPPORT_NDIS685
84 |
85 | EXTERN_C_END
86 |
--------------------------------------------------------------------------------
/msquic-net.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30524.135
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4BD10F47-23DF-4E97-B305-F430E635AA0C}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.MsQuic.Transport", "src\System.Net.MsQuic.Transport\System.Net.MsQuic.Transport.proj", "{EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B87C2849-D13F-49A6-BE4C-91227C653F28}"
11 | ProjectSection(SolutionItems) = preProject
12 | README.md = README.md
13 | EndProjectSection
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Any CPU = Debug|Any CPU
18 | Debug|x64 = Debug|x64
19 | Debug|x86 = Debug|x86
20 | Release|Any CPU = Release|Any CPU
21 | Release|x64 = Release|x64
22 | Release|x86 = Release|x86
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Debug|x64.ActiveCfg = Debug|Any CPU
28 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Debug|x64.Build.0 = Debug|Any CPU
29 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Debug|x86.ActiveCfg = Debug|Any CPU
30 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Debug|x86.Build.0 = Debug|Any CPU
31 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Release|x64.ActiveCfg = Release|Any CPU
34 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Release|x64.Build.0 = Release|Any CPU
35 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Release|x86.ActiveCfg = Release|Any CPU
36 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5}.Release|x86.Build.0 = Release|Any CPU
37 | EndGlobalSection
38 | GlobalSection(SolutionProperties) = preSolution
39 | HideSolutionNode = FALSE
40 | EndGlobalSection
41 | GlobalSection(NestedProjects) = preSolution
42 | {EB965205-C305-45BE-BDC5-B8F6F9BD5DC5} = {4BD10F47-23DF-4E97-B305-F430E635AA0C}
43 | EndGlobalSection
44 | GlobalSection(ExtensibilityGlobals) = postSolution
45 | SolutionGuid = {6047DDCD-CA07-4687-99B6-C21F1AFCB9A8}
46 | EndGlobalSection
47 | EndGlobal
48 |
--------------------------------------------------------------------------------
/eng/common/sdl/trim-assets-version.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Install and run the 'Microsoft.DotNet.VersionTools.Cli' tool with the 'trim-artifacts-version' command to trim the version from the NuGet assets file name.
4 |
5 | .PARAMETER InputPath
6 | Full path to directory where artifact packages are stored
7 |
8 | .PARAMETER Recursive
9 | Search for NuGet packages recursively
10 |
11 | #>
12 |
13 | Param(
14 | [string] $InputPath,
15 | [bool] $Recursive = $true
16 | )
17 |
18 | $CliToolName = "Microsoft.DotNet.VersionTools.Cli"
19 |
20 | function Install-VersionTools-Cli {
21 | param(
22 | [Parameter(Mandatory=$true)][string]$Version
23 | )
24 |
25 | Write-Host "Installing the package '$CliToolName' with a version of '$version' ..."
26 | $feed = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"
27 |
28 | $argumentList = @("tool", "install", "--local", "$CliToolName", "--add-source $feed", "--no-cache", "--version $Version", "--create-manifest-if-needed")
29 | Start-Process "$dotnet" -Verbose -ArgumentList $argumentList -NoNewWindow -Wait
30 | }
31 |
32 | # -------------------------------------------------------------------
33 |
34 | if (!(Test-Path $InputPath)) {
35 | Write-Host "Input Path '$InputPath' does not exist"
36 | ExitWithExitCode 1
37 | }
38 |
39 | $ErrorActionPreference = 'Stop'
40 | Set-StrictMode -Version 2.0
41 |
42 | $disableConfigureToolsetImport = $true
43 | $global:LASTEXITCODE = 0
44 |
45 | # `tools.ps1` checks $ci to perform some actions. Since the SDL
46 | # scripts don't necessarily execute in the same agent that run the
47 | # build.ps1/sh script this variable isn't automatically set.
48 | $ci = $true
49 | . $PSScriptRoot\..\tools.ps1
50 |
51 | try {
52 | $dotnetRoot = InitializeDotNetCli -install:$true
53 | $dotnet = "$dotnetRoot\dotnet.exe"
54 |
55 | $toolsetVersion = Read-ArcadeSdkVersion
56 | Install-VersionTools-Cli -Version $toolsetVersion
57 |
58 | $cliToolFound = (& "$dotnet" tool list --local | Where-Object {$_.Split(' ')[0] -eq $CliToolName})
59 | if ($null -eq $cliToolFound) {
60 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "The '$CliToolName' tool is not installed."
61 | ExitWithExitCode 1
62 | }
63 |
64 | Exec-BlockVerbosely {
65 | & "$dotnet" $CliToolName trim-assets-version `
66 | --assets-path $InputPath `
67 | --recursive $Recursive
68 | Exit-IfNZEC "Sdl"
69 | }
70 | }
71 | catch {
72 | Write-Host $_
73 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
74 | ExitWithExitCode 1
75 | }
76 |
--------------------------------------------------------------------------------
/eng/common/dotnet-install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 | # resolve $source until the file is no longer a symlink
5 | while [[ -h "$source" ]]; do
6 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
7 | source="$(readlink "$source")"
8 | # if $source was a relative symlink, we need to resolve it relative to the path where the
9 | # symlink file was located
10 | [[ $source != /* ]] && source="$scriptroot/$source"
11 | done
12 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
13 |
14 | . "$scriptroot/tools.sh"
15 |
16 | version='Latest'
17 | architecture=''
18 | runtime='dotnet'
19 | runtimeSourceFeed=''
20 | runtimeSourceFeedKey=''
21 | while [[ $# > 0 ]]; do
22 | opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")"
23 | case "$opt" in
24 | -version|-v)
25 | shift
26 | version="$1"
27 | ;;
28 | -architecture|-a)
29 | shift
30 | architecture="$1"
31 | ;;
32 | -runtime|-r)
33 | shift
34 | runtime="$1"
35 | ;;
36 | -runtimesourcefeed)
37 | shift
38 | runtimeSourceFeed="$1"
39 | ;;
40 | -runtimesourcefeedkey)
41 | shift
42 | runtimeSourceFeedKey="$1"
43 | ;;
44 | *)
45 | Write-PipelineTelemetryError -Category 'Build' -Message "Invalid argument: $1"
46 | exit 1
47 | ;;
48 | esac
49 | shift
50 | done
51 |
52 | # Use uname to determine what the CPU is, see https://en.wikipedia.org/wiki/Uname#Examples
53 | cpuname=$(uname -m)
54 | case $cpuname in
55 | arm64|aarch64)
56 | buildarch=arm64
57 | if [ "$(getconf LONG_BIT)" -lt 64 ]; then
58 | # This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS)
59 | buildarch=arm
60 | fi
61 | ;;
62 | loongarch64)
63 | buildarch=loongarch64
64 | ;;
65 | amd64|x86_64)
66 | buildarch=x64
67 | ;;
68 | armv*l)
69 | buildarch=arm
70 | ;;
71 | i[3-6]86)
72 | buildarch=x86
73 | ;;
74 | *)
75 | echo "Unknown CPU $cpuname detected, treating it as x64"
76 | buildarch=x64
77 | ;;
78 | esac
79 |
80 | dotnetRoot="${repo_root}.dotnet"
81 | if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then
82 | dotnetRoot="$dotnetRoot/$architecture"
83 | fi
84 |
85 | InstallDotNet $dotnetRoot $version "$architecture" $runtime true $runtimeSourceFeed $runtimeSourceFeedKey || {
86 | local exit_code=$?
87 | Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2
88 | ExitWithExitCode $exit_code
89 | }
90 |
91 | ExitWithExitCode 0
92 |
--------------------------------------------------------------------------------
/eng/common/sdl/extract-artifact-archives.ps1:
--------------------------------------------------------------------------------
1 | # This script looks for each archive file in a directory and extracts it into the target directory.
2 | # For example, the file "$InputPath/bin.tar.gz" extracts to "$ExtractPath/bin.tar.gz.extracted/**".
3 | # Uses the "tar" utility added to Windows 10 / Windows 2019 that supports tar.gz and zip.
4 | param(
5 | # Full path to directory where archives are stored.
6 | [Parameter(Mandatory=$true)][string] $InputPath,
7 | # Full path to directory to extract archives into. May be the same as $InputPath.
8 | [Parameter(Mandatory=$true)][string] $ExtractPath
9 | )
10 |
11 | $ErrorActionPreference = 'Stop'
12 | Set-StrictMode -Version 2.0
13 |
14 | $disableConfigureToolsetImport = $true
15 |
16 | try {
17 | # `tools.ps1` checks $ci to perform some actions. Since the SDL
18 | # scripts don't necessarily execute in the same agent that run the
19 | # build.ps1/sh script this variable isn't automatically set.
20 | $ci = $true
21 | . $PSScriptRoot\..\tools.ps1
22 |
23 | Measure-Command {
24 | $jobs = @()
25 |
26 | # Find archive files for non-Windows and Windows builds.
27 | $archiveFiles = @(
28 | Get-ChildItem (Join-Path $InputPath "*.tar.gz")
29 | Get-ChildItem (Join-Path $InputPath "*.zip")
30 | )
31 |
32 | foreach ($targzFile in $archiveFiles) {
33 | $jobs += Start-Job -ScriptBlock {
34 | $file = $using:targzFile
35 | $fileName = [System.IO.Path]::GetFileName($file)
36 | $extractDir = Join-Path $using:ExtractPath "$fileName.extracted"
37 |
38 | New-Item $extractDir -ItemType Directory -Force | Out-Null
39 |
40 | Write-Host "Extracting '$file' to '$extractDir'..."
41 |
42 | # Pipe errors to stdout to prevent PowerShell detecting them and quitting the job early.
43 | # This type of quit skips the catch, so we wouldn't be able to tell which file triggered the
44 | # error. Save output so it can be stored in the exception string along with context.
45 | $output = tar -xf $file -C $extractDir 2>&1
46 | # Handle NZEC manually rather than using Exit-IfNZEC: we are in a background job, so we
47 | # don't have access to the outer scope.
48 | if ($LASTEXITCODE -ne 0) {
49 | throw "Error extracting '$file': non-zero exit code ($LASTEXITCODE). Output: '$output'"
50 | }
51 |
52 | Write-Host "Extracted to $extractDir"
53 | }
54 | }
55 |
56 | Receive-Job $jobs -Wait
57 | }
58 | }
59 | catch {
60 | Write-Host $_
61 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
62 | ExitWithExitCode 1
63 | }
64 |
--------------------------------------------------------------------------------
/eng/common/post-build/trigger-subscriptions.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [Parameter(Mandatory=$true)][string] $SourceRepo,
3 | [Parameter(Mandatory=$true)][int] $ChannelId,
4 | [Parameter(Mandatory=$true)][string] $MaestroApiAccessToken,
5 | [Parameter(Mandatory=$false)][string] $MaestroApiEndPoint = 'https://maestro.dot.net',
6 | [Parameter(Mandatory=$false)][string] $MaestroApiVersion = '2019-01-16'
7 | )
8 |
9 | try {
10 | . $PSScriptRoot\post-build-utils.ps1
11 |
12 | # Get all the $SourceRepo subscriptions
13 | $normalizedSourceRepo = $SourceRepo.Replace('dnceng@', '')
14 | $subscriptions = Get-MaestroSubscriptions -SourceRepository $normalizedSourceRepo -ChannelId $ChannelId
15 |
16 | if (!$subscriptions) {
17 | Write-PipelineTelemetryError -Category 'TriggerSubscriptions' -Message "No subscriptions found for source repo '$normalizedSourceRepo' in channel '$ChannelId'"
18 | ExitWithExitCode 0
19 | }
20 |
21 | $subscriptionsToTrigger = New-Object System.Collections.Generic.List[string]
22 | $failedTriggeredSubscription = $false
23 |
24 | # Get all enabled subscriptions that need dependency flow on 'everyBuild'
25 | foreach ($subscription in $subscriptions) {
26 | if ($subscription.enabled -and $subscription.policy.updateFrequency -like 'everyBuild' -and $subscription.channel.id -eq $ChannelId) {
27 | Write-Host "Should trigger this subscription: ${$subscription.id}"
28 | [void]$subscriptionsToTrigger.Add($subscription.id)
29 | }
30 | }
31 |
32 | foreach ($subscriptionToTrigger in $subscriptionsToTrigger) {
33 | try {
34 | Write-Host "Triggering subscription '$subscriptionToTrigger'."
35 |
36 | Trigger-Subscription -SubscriptionId $subscriptionToTrigger
37 |
38 | Write-Host 'done.'
39 | }
40 | catch
41 | {
42 | Write-Host "There was an error while triggering subscription '$subscriptionToTrigger'"
43 | Write-Host $_
44 | Write-Host $_.ScriptStackTrace
45 | $failedTriggeredSubscription = $true
46 | }
47 | }
48 |
49 | if ($subscriptionsToTrigger.Count -eq 0) {
50 | Write-Host "No subscription matched source repo '$normalizedSourceRepo' and channel ID '$ChannelId'."
51 | }
52 | elseif ($failedTriggeredSubscription) {
53 | Write-PipelineTelemetryError -Category 'TriggerSubscriptions' -Message 'At least one subscription failed to be triggered...'
54 | ExitWithExitCode 1
55 | }
56 | else {
57 | Write-Host 'All subscriptions were triggered successfully!'
58 | }
59 | }
60 | catch {
61 | Write-Host $_.ScriptStackTrace
62 | Write-PipelineTelemetryError -Category 'TriggerSubscriptions' -Message $_
63 | ExitWithExitCode 1
64 | }
65 |
--------------------------------------------------------------------------------
/eng/common/sdl/init-sdl.ps1:
--------------------------------------------------------------------------------
1 | Param(
2 | [string] $GuardianCliLocation,
3 | [string] $Repository,
4 | [string] $BranchName='master',
5 | [string] $WorkingDirectory,
6 | [string] $AzureDevOpsAccessToken,
7 | [string] $GuardianLoggerLevel='Standard'
8 | )
9 |
10 | $ErrorActionPreference = 'Stop'
11 | Set-StrictMode -Version 2.0
12 | $disableConfigureToolsetImport = $true
13 | $global:LASTEXITCODE = 0
14 |
15 | # `tools.ps1` checks $ci to perform some actions. Since the SDL
16 | # scripts don't necessarily execute in the same agent that run the
17 | # build.ps1/sh script this variable isn't automatically set.
18 | $ci = $true
19 | . $PSScriptRoot\..\tools.ps1
20 |
21 | # Don't display the console progress UI - it's a huge perf hit
22 | $ProgressPreference = 'SilentlyContinue'
23 |
24 | # Construct basic auth from AzDO access token; construct URI to the repository's gdn folder stored in that repository; construct location of zip file
25 | $encodedPat = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$AzureDevOpsAccessToken"))
26 | $escapedRepository = [Uri]::EscapeDataString("/$Repository/$BranchName/.gdn")
27 | $uri = "https://dev.azure.com/dnceng/internal/_apis/git/repositories/sdl-tool-cfg/Items?path=$escapedRepository&versionDescriptor[versionOptions]=0&`$format=zip&api-version=5.0"
28 | $zipFile = "$WorkingDirectory/gdn.zip"
29 |
30 | Add-Type -AssemblyName System.IO.Compression.FileSystem
31 | $gdnFolder = (Join-Path $WorkingDirectory '.gdn')
32 |
33 | try {
34 | # if the folder does not exist, we'll do a guardian init and push it to the remote repository
35 | Write-Host 'Initializing Guardian...'
36 | Write-Host "$GuardianCliLocation init --working-directory $WorkingDirectory --logger-level $GuardianLoggerLevel"
37 | & $GuardianCliLocation init --working-directory $WorkingDirectory --logger-level $GuardianLoggerLevel
38 | if ($LASTEXITCODE -ne 0) {
39 | Write-PipelineTelemetryError -Force -Category 'Build' -Message "Guardian init failed with exit code $LASTEXITCODE."
40 | ExitWithExitCode $LASTEXITCODE
41 | }
42 | # We create the mainbaseline so it can be edited later
43 | Write-Host "$GuardianCliLocation baseline --working-directory $WorkingDirectory --name mainbaseline"
44 | & $GuardianCliLocation baseline --working-directory $WorkingDirectory --name mainbaseline
45 | if ($LASTEXITCODE -ne 0) {
46 | Write-PipelineTelemetryError -Force -Category 'Build' -Message "Guardian baseline failed with exit code $LASTEXITCODE."
47 | ExitWithExitCode $LASTEXITCODE
48 | }
49 | ExitWithExitCode 0
50 | }
51 | catch {
52 | Write-Host $_.ScriptStackTrace
53 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
54 | ExitWithExitCode 1
55 | }
56 |
--------------------------------------------------------------------------------
/eng/common/darc-init.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 | darcVersion=''
5 | versionEndpoint='https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16'
6 | verbosity='minimal'
7 |
8 | while [[ $# > 0 ]]; do
9 | opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")"
10 | case "$opt" in
11 | --darcversion)
12 | darcVersion=$2
13 | shift
14 | ;;
15 | --versionendpoint)
16 | versionEndpoint=$2
17 | shift
18 | ;;
19 | --verbosity)
20 | verbosity=$2
21 | shift
22 | ;;
23 | --toolpath)
24 | toolpath=$2
25 | shift
26 | ;;
27 | *)
28 | echo "Invalid argument: $1"
29 | usage
30 | exit 1
31 | ;;
32 | esac
33 |
34 | shift
35 | done
36 |
37 | # resolve $source until the file is no longer a symlink
38 | while [[ -h "$source" ]]; do
39 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
40 | source="$(readlink "$source")"
41 | # if $source was a relative symlink, we need to resolve it relative to the path where the
42 | # symlink file was located
43 | [[ $source != /* ]] && source="$scriptroot/$source"
44 | done
45 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
46 |
47 | . "$scriptroot/tools.sh"
48 |
49 | if [ -z "$darcVersion" ]; then
50 | darcVersion=$(curl -X GET "$versionEndpoint" -H "accept: text/plain")
51 | fi
52 |
53 | function InstallDarcCli {
54 | local darc_cli_package_name="microsoft.dotnet.darc"
55 |
56 | InitializeDotNetCli true
57 | local dotnet_root=$_InitializeDotNetCli
58 |
59 | if [ -z "$toolpath" ]; then
60 | local tool_list=$($dotnet_root/dotnet tool list -g)
61 | if [[ $tool_list = *$darc_cli_package_name* ]]; then
62 | echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name -g)
63 | fi
64 | else
65 | local tool_list=$($dotnet_root/dotnet tool list --tool-path "$toolpath")
66 | if [[ $tool_list = *$darc_cli_package_name* ]]; then
67 | echo $($dotnet_root/dotnet tool uninstall $darc_cli_package_name --tool-path "$toolpath")
68 | fi
69 | fi
70 |
71 | local arcadeServicesSource="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"
72 |
73 | echo "Installing Darc CLI version $darcVersion..."
74 | echo "You may need to restart your command shell if this is the first dotnet tool you have installed."
75 | if [ -z "$toolpath" ]; then
76 | echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g)
77 | else
78 | echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath")
79 | fi
80 | }
81 |
82 | InstallDarcCli
83 |
--------------------------------------------------------------------------------
/eng/common/templates/variables/pool-providers.yml:
--------------------------------------------------------------------------------
1 | # Select a pool provider based off branch name. Anything with branch name containing 'release' must go into an -Svc pool,
2 | # otherwise it should go into the "normal" pools. This separates out the queueing and billing of released branches.
3 |
4 | # Motivation:
5 | # Once a given branch of a repository's output has been officially "shipped" once, it is then considered to be COGS
6 | # (Cost of goods sold) and should be moved to a servicing pool provider. This allows both separation of queueing
7 | # (allowing release builds and main PR builds to not intefere with each other) and billing (required for COGS.
8 | # Additionally, the pool provider name itself may be subject to change when the .NET Core Engineering Services
9 | # team needs to move resources around and create new and potentially differently-named pools. Using this template
10 | # file from an Arcade-ified repo helps guard against both having to update one's release/* branches and renaming.
11 |
12 | # How to use:
13 | # This yaml assumes your shipped product branches use the naming convention "release/..." (which many do).
14 | # If we find alternate naming conventions in broad usage it can be added to the condition below.
15 | #
16 | # First, import the template in an arcade-ified repo to pick up the variables, e.g.:
17 | #
18 | # variables:
19 | # - template: /eng/common/templates/variables/pool-providers.yml
20 | #
21 | # ... then anywhere specifying the pool provider use the runtime variables,
22 | # $(DncEngInternalBuildPool) and $ (DncEngPublicBuildPool), e.g.:
23 | #
24 | # pool:
25 | # name: $(DncEngInternalBuildPool)
26 | # demands: ImageOverride -equals windows.vs2019.amd64
27 |
28 | variables:
29 | # Coalesce the target and source branches so we know when a PR targets a release branch
30 | # If these variables are somehow missing, fall back to main (tends to have more capacity)
31 |
32 | # Any new -Svc alternative pools should have variables added here to allow for splitting work
33 | - name: DncEngPublicBuildPool
34 | value: $[
35 | replace(
36 | replace(
37 | eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'),
38 | True,
39 | 'NetCore-Svc-Public'
40 | ),
41 | False,
42 | 'NetCore-Public'
43 | )
44 | ]
45 |
46 | - name: DncEngInternalBuildPool
47 | value: $[
48 | replace(
49 | replace(
50 | eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'),
51 | True,
52 | 'NetCore1ESPool-Svc-Internal'
53 | ),
54 | False,
55 | 'NetCore1ESPool-Internal'
56 | )
57 | ]
58 |
--------------------------------------------------------------------------------
/eng/common/sdl/extract-artifact-packages.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [Parameter(Mandatory=$true)][string] $InputPath, # Full path to directory where artifact packages are stored
3 | [Parameter(Mandatory=$true)][string] $ExtractPath # Full path to directory where the packages will be extracted
4 | )
5 |
6 | $ErrorActionPreference = 'Stop'
7 | Set-StrictMode -Version 2.0
8 |
9 | $disableConfigureToolsetImport = $true
10 |
11 | function ExtractArtifacts {
12 | if (!(Test-Path $InputPath)) {
13 | Write-Host "Input Path does not exist: $InputPath"
14 | ExitWithExitCode 0
15 | }
16 | $Jobs = @()
17 | Get-ChildItem "$InputPath\*.nupkg" |
18 | ForEach-Object {
19 | $Jobs += Start-Job -ScriptBlock $ExtractPackage -ArgumentList $_.FullName
20 | }
21 |
22 | foreach ($Job in $Jobs) {
23 | Wait-Job -Id $Job.Id | Receive-Job
24 | }
25 | }
26 |
27 | try {
28 | # `tools.ps1` checks $ci to perform some actions. Since the SDL
29 | # scripts don't necessarily execute in the same agent that run the
30 | # build.ps1/sh script this variable isn't automatically set.
31 | $ci = $true
32 | . $PSScriptRoot\..\tools.ps1
33 |
34 | $ExtractPackage = {
35 | param(
36 | [string] $PackagePath # Full path to a NuGet package
37 | )
38 |
39 | if (!(Test-Path $PackagePath)) {
40 | Write-PipelineTelemetryError -Category 'Build' -Message "Input file does not exist: $PackagePath"
41 | ExitWithExitCode 1
42 | }
43 |
44 | $RelevantExtensions = @('.dll', '.exe', '.pdb')
45 | Write-Host -NoNewLine 'Extracting ' ([System.IO.Path]::GetFileName($PackagePath)) '...'
46 |
47 | $PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath)
48 | $ExtractPath = Join-Path -Path $using:ExtractPath -ChildPath $PackageId
49 |
50 | Add-Type -AssemblyName System.IO.Compression.FileSystem
51 |
52 | [System.IO.Directory]::CreateDirectory($ExtractPath);
53 |
54 | try {
55 | $zip = [System.IO.Compression.ZipFile]::OpenRead($PackagePath)
56 |
57 | $zip.Entries |
58 | Where-Object {$RelevantExtensions -contains [System.IO.Path]::GetExtension($_.Name)} |
59 | ForEach-Object {
60 | $TargetPath = Join-Path -Path $ExtractPath -ChildPath (Split-Path -Path $_.FullName)
61 | [System.IO.Directory]::CreateDirectory($TargetPath);
62 |
63 | $TargetFile = Join-Path -Path $ExtractPath -ChildPath $_.FullName
64 | [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $TargetFile)
65 | }
66 | }
67 | catch {
68 | Write-Host $_
69 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
70 | ExitWithExitCode 1
71 | }
72 | finally {
73 | $zip.Dispose()
74 | }
75 | }
76 | Measure-Command { ExtractArtifacts }
77 | }
78 | catch {
79 | Write-Host $_
80 | Write-PipelineTelemetryError -Force -Category 'Sdl' -Message $_
81 | ExitWithExitCode 1
82 | }
83 |
--------------------------------------------------------------------------------
/eng/common/post-build/redact-logs.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(PositionalBinding=$False)]
2 | param(
3 | [Parameter(Mandatory=$true, Position=0)][string] $InputPath,
4 | [Parameter(Mandatory=$true)][string] $BinlogToolVersion,
5 | [Parameter(Mandatory=$false)][string] $DotnetPath,
6 | [Parameter(Mandatory=$false)][string] $PackageFeed = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json',
7 | # File with strings to redact - separated by newlines.
8 | # For comments start the line with '# ' - such lines are ignored
9 | [Parameter(Mandatory=$false)][string] $TokensFilePath,
10 | [Parameter(ValueFromRemainingArguments=$true)][String[]]$TokensToRedact
11 | )
12 |
13 | try {
14 | . $PSScriptRoot\post-build-utils.ps1
15 |
16 | $packageName = 'binlogtool'
17 |
18 | $dotnet = $DotnetPath
19 |
20 | if (!$dotnet) {
21 | $dotnetRoot = InitializeDotNetCli -install:$true
22 | $dotnet = "$dotnetRoot\dotnet.exe"
23 | }
24 |
25 | $toolList = & "$dotnet" tool list -g
26 |
27 | if ($toolList -like "*$packageName*") {
28 | & "$dotnet" tool uninstall $packageName -g
29 | }
30 |
31 | $toolPath = "$PSScriptRoot\..\..\..\.tools"
32 | $verbosity = 'minimal'
33 |
34 | New-Item -ItemType Directory -Force -Path $toolPath
35 |
36 | Push-Location -Path $toolPath
37 |
38 | try {
39 | Write-Host "Installing Binlog redactor CLI..."
40 | Write-Host "'$dotnet' new tool-manifest"
41 | & "$dotnet" new tool-manifest
42 | Write-Host "'$dotnet' tool install $packageName --local --add-source '$PackageFeed' -v $verbosity --version $BinlogToolVersion"
43 | & "$dotnet" tool install $packageName --local --add-source "$PackageFeed" -v $verbosity --version $BinlogToolVersion
44 |
45 | if (Test-Path $TokensFilePath) {
46 | Write-Host "Adding additional sensitive data for redaction from file: " $TokensFilePath
47 | $TokensToRedact += Get-Content -Path $TokensFilePath | Foreach {$_.Trim()} | Where { $_ -notmatch "^# " }
48 | }
49 |
50 | $optionalParams = [System.Collections.ArrayList]::new()
51 |
52 | Foreach ($p in $TokensToRedact)
53 | {
54 | if($p -match '^\$\(.*\)$')
55 | {
56 | Write-Host ("Ignoring token {0} as it is probably unexpanded AzDO variable" -f $p)
57 | }
58 | elseif($p)
59 | {
60 | $optionalParams.Add("-p:" + $p) | Out-Null
61 | }
62 | }
63 |
64 | & $dotnet binlogtool redact --input:$InputPath --recurse --in-place `
65 | @optionalParams
66 |
67 | if ($LastExitCode -ne 0) {
68 | Write-PipelineTelemetryError -Category 'Redactor' -Type 'warning' -Message "Problems using Redactor tool (exit code: $LastExitCode). But ignoring them now."
69 | }
70 | }
71 | finally {
72 | Pop-Location
73 | }
74 |
75 | Write-Host 'done.'
76 | }
77 | catch {
78 | Write-Host $_
79 | Write-PipelineTelemetryError -Category 'Redactor' -Message "There was an error while trying to redact logs. Error: $_"
80 | ExitWithExitCode 1
81 | }
82 |
--------------------------------------------------------------------------------
/src/System.Net.MsQuic.Transport/pkg/runtime.native.System.Net.MsQuic.Transport.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | true
6 |
7 | true
8 | false
9 | true
10 | true
11 |
12 |
13 | true
14 | $(TargetsForTfmSpecificDebugSymbolsInPackage);AddRuntimeSpecificNativeSymbolToPackage
15 | $(SymbolsSuffix)
16 |
17 | $(NoWarn);NU5128
18 |
19 | openssl
20 | schannel
21 | $(TargetOS)
22 | macos
23 | $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'msquic', 'artifacts', 'bin', '$(OsFolder)', '$(TargetArchitecture)_$(Configuration)_$(TlsFlavor)'))
24 |
25 |
26 |
27 |
30 |
34 |
35 |
36 |
37 |
38 | <_SymbolFilePath>$([MSBuild]::NormalizePath('$(NativeBinDir)', '$(LibPrefix)msquic$(SymbolsSuffix)'))
39 |
40 |
41 |
43 |
44 |
45 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/eng/common/templates/post-build/setup-maestro-vars.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | BARBuildId: ''
3 | PromoteToChannelIds: ''
4 |
5 | steps:
6 | - ${{ if eq(coalesce(parameters.PromoteToChannelIds, 0), 0) }}:
7 | - task: DownloadBuildArtifacts@0
8 | displayName: Download Release Configs
9 | inputs:
10 | buildType: current
11 | artifactName: ReleaseConfigs
12 | checkDownloadedFiles: true
13 |
14 | - task: PowerShell@2
15 | name: setReleaseVars
16 | displayName: Set Release Configs Vars
17 | inputs:
18 | targetType: inline
19 | pwsh: true
20 | script: |
21 | try {
22 | if (!$Env:PromoteToMaestroChannels -or $Env:PromoteToMaestroChannels.Trim() -eq '') {
23 | $Content = Get-Content $(Build.StagingDirectory)/ReleaseConfigs/ReleaseConfigs.txt
24 |
25 | $BarId = $Content | Select -Index 0
26 | $Channels = $Content | Select -Index 1
27 | $IsStableBuild = $Content | Select -Index 2
28 |
29 | $AzureDevOpsProject = $Env:System_TeamProject
30 | $AzureDevOpsBuildDefinitionId = $Env:System_DefinitionId
31 | $AzureDevOpsBuildId = $Env:Build_BuildId
32 | }
33 | else {
34 | $buildApiEndpoint = "${Env:MaestroApiEndPoint}/api/builds/${Env:BARBuildId}?api-version=${Env:MaestroApiVersion}"
35 |
36 | $apiHeaders = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
37 | $apiHeaders.Add('Accept', 'application/json')
38 | $apiHeaders.Add('Authorization',"Bearer ${Env:MAESTRO_API_TOKEN}")
39 |
40 | $buildInfo = try { Invoke-WebRequest -Method Get -Uri $buildApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
41 |
42 | $BarId = $Env:BARBuildId
43 | $Channels = $Env:PromoteToMaestroChannels -split ","
44 | $Channels = $Channels -join "]["
45 | $Channels = "[$Channels]"
46 |
47 | $IsStableBuild = $buildInfo.stable
48 | $AzureDevOpsProject = $buildInfo.azureDevOpsProject
49 | $AzureDevOpsBuildDefinitionId = $buildInfo.azureDevOpsBuildDefinitionId
50 | $AzureDevOpsBuildId = $buildInfo.azureDevOpsBuildId
51 | }
52 |
53 | Write-Host "##vso[task.setvariable variable=BARBuildId]$BarId"
54 | Write-Host "##vso[task.setvariable variable=TargetChannels]$Channels"
55 | Write-Host "##vso[task.setvariable variable=IsStableBuild]$IsStableBuild"
56 |
57 | Write-Host "##vso[task.setvariable variable=AzDOProjectName]$AzureDevOpsProject"
58 | Write-Host "##vso[task.setvariable variable=AzDOPipelineId]$AzureDevOpsBuildDefinitionId"
59 | Write-Host "##vso[task.setvariable variable=AzDOBuildId]$AzureDevOpsBuildId"
60 | }
61 | catch {
62 | Write-Host $_
63 | Write-Host $_.Exception
64 | Write-Host $_.ScriptStackTrace
65 | exit 1
66 | }
67 | env:
68 | MAESTRO_API_TOKEN: $(MaestroApiAccessToken)
69 | BARBuildId: ${{ parameters.BARBuildId }}
70 | PromoteToMaestroChannels: ${{ parameters.PromoteToChannelIds }}
71 |
--------------------------------------------------------------------------------
/eng/common/templates-official/post-build/setup-maestro-vars.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | BARBuildId: ''
3 | PromoteToChannelIds: ''
4 |
5 | steps:
6 | - ${{ if eq(coalesce(parameters.PromoteToChannelIds, 0), 0) }}:
7 | - task: DownloadBuildArtifacts@0
8 | displayName: Download Release Configs
9 | inputs:
10 | buildType: current
11 | artifactName: ReleaseConfigs
12 | checkDownloadedFiles: true
13 |
14 | - task: PowerShell@2
15 | name: setReleaseVars
16 | displayName: Set Release Configs Vars
17 | inputs:
18 | targetType: inline
19 | pwsh: true
20 | script: |
21 | try {
22 | if (!$Env:PromoteToMaestroChannels -or $Env:PromoteToMaestroChannels.Trim() -eq '') {
23 | $Content = Get-Content $(Build.StagingDirectory)/ReleaseConfigs/ReleaseConfigs.txt
24 |
25 | $BarId = $Content | Select -Index 0
26 | $Channels = $Content | Select -Index 1
27 | $IsStableBuild = $Content | Select -Index 2
28 |
29 | $AzureDevOpsProject = $Env:System_TeamProject
30 | $AzureDevOpsBuildDefinitionId = $Env:System_DefinitionId
31 | $AzureDevOpsBuildId = $Env:Build_BuildId
32 | }
33 | else {
34 | $buildApiEndpoint = "${Env:MaestroApiEndPoint}/api/builds/${Env:BARBuildId}?api-version=${Env:MaestroApiVersion}"
35 |
36 | $apiHeaders = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
37 | $apiHeaders.Add('Accept', 'application/json')
38 | $apiHeaders.Add('Authorization',"Bearer ${Env:MAESTRO_API_TOKEN}")
39 |
40 | $buildInfo = try { Invoke-WebRequest -Method Get -Uri $buildApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
41 |
42 | $BarId = $Env:BARBuildId
43 | $Channels = $Env:PromoteToMaestroChannels -split ","
44 | $Channels = $Channels -join "]["
45 | $Channels = "[$Channels]"
46 |
47 | $IsStableBuild = $buildInfo.stable
48 | $AzureDevOpsProject = $buildInfo.azureDevOpsProject
49 | $AzureDevOpsBuildDefinitionId = $buildInfo.azureDevOpsBuildDefinitionId
50 | $AzureDevOpsBuildId = $buildInfo.azureDevOpsBuildId
51 | }
52 |
53 | Write-Host "##vso[task.setvariable variable=BARBuildId]$BarId"
54 | Write-Host "##vso[task.setvariable variable=TargetChannels]$Channels"
55 | Write-Host "##vso[task.setvariable variable=IsStableBuild]$IsStableBuild"
56 |
57 | Write-Host "##vso[task.setvariable variable=AzDOProjectName]$AzureDevOpsProject"
58 | Write-Host "##vso[task.setvariable variable=AzDOPipelineId]$AzureDevOpsBuildDefinitionId"
59 | Write-Host "##vso[task.setvariable variable=AzDOBuildId]$AzureDevOpsBuildId"
60 | }
61 | catch {
62 | Write-Host $_
63 | Write-Host $_.Exception
64 | Write-Host $_.ScriptStackTrace
65 | exit 1
66 | }
67 | env:
68 | MAESTRO_API_TOKEN: $(MaestroApiAccessToken)
69 | BARBuildId: ${{ parameters.BARBuildId }}
70 | PromoteToMaestroChannels: ${{ parameters.PromoteToChannelIds }}
71 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/datapath.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | DECLARE_HANDLE(XDP_RX_QUEUE_HANDLE);
11 | DECLARE_HANDLE(XDP_TX_QUEUE_HANDLE);
12 | DECLARE_HANDLE(XDP_INTERFACE_HANDLE);
13 |
14 | #pragma warning(push)
15 | #pragma warning(disable:4324) // structure was padded due to alignment specifier
16 |
17 | typedef struct DECLSPEC_CACHEALIGN _XDP_RING {
18 | UINT32 ProducerIndex;
19 | UINT32 ConsumerIndex;
20 | UINT32 InterfaceReserved;
21 | UINT32 Reserved;
22 | UINT32 Mask;
23 | UINT32 ElementStride;
24 | //
25 | // Followed by power-of-two array of ring elements.
26 | //
27 | } XDP_RING;
28 |
29 | #pragma warning(pop)
30 |
31 | C_ASSERT(sizeof(XDP_RING) == SYSTEM_CACHE_ALIGNMENT_SIZE);
32 |
33 | inline
34 | VOID *
35 | XdpRingGetElement(
36 | _In_ XDP_RING *Ring,
37 | _In_ UINT32 Index
38 | )
39 | {
40 | ASSERT(Index <= Ring->Mask);
41 | return (PUCHAR)&Ring[1] + (SIZE_T)Index * Ring->ElementStride;
42 | }
43 |
44 | inline
45 | UINT32
46 | XdpRingCount(
47 | _In_ XDP_RING *Ring
48 | )
49 | {
50 | return Ring->ProducerIndex - Ring->ConsumerIndex;
51 | }
52 |
53 | inline
54 | UINT32
55 | XdpRingFree(
56 | _In_ XDP_RING *Ring
57 | )
58 | {
59 | return Ring->Mask + 1 - XdpRingCount(Ring);
60 | }
61 |
62 | typedef struct _XDP_BUFFER {
63 | UINT32 DataOffset;
64 | UINT32 DataLength;
65 | UINT32 BufferLength;
66 | UINT32 Reserved;
67 | //
68 | // Followed by various XDP descriptor extensions.
69 | //
70 | } XDP_BUFFER;
71 |
72 | C_ASSERT(sizeof(XDP_BUFFER) == 16);
73 |
74 | typedef struct _XDP_FRAME {
75 | XDP_BUFFER Buffer;
76 | //
77 | // Followed by various XDP descriptor extensions.
78 | //
79 | } XDP_FRAME;
80 |
81 | typedef struct _XDP_TX_FRAME_COMPLETION {
82 | UINT64 BufferAddress;
83 | } XDP_TX_FRAME_COMPLETION;
84 |
85 | typedef enum _XDP_RX_ACTION {
86 | XDP_RX_ACTION_DROP,
87 | XDP_RX_ACTION_PASS,
88 | XDP_RX_ACTION_TX,
89 | } XDP_RX_ACTION;
90 |
91 | _IRQL_requires_max_(DISPATCH_LEVEL)
92 | VOID
93 | XdpReceive(
94 | _In_ XDP_RX_QUEUE_HANDLE XdpRxQueue
95 | );
96 |
97 | _IRQL_requires_max_(DISPATCH_LEVEL)
98 | VOID
99 | XdpFlushReceive(
100 | _In_ XDP_RX_QUEUE_HANDLE XdpRxQueue
101 | );
102 |
103 | _IRQL_requires_max_(DISPATCH_LEVEL)
104 | VOID
105 | XdpFlushTransmit(
106 | _In_ XDP_TX_QUEUE_HANDLE XdpTxQueue
107 | );
108 |
109 | typedef enum _XDP_NOTIFY_QUEUE_FLAGS {
110 | XDP_NOTIFY_QUEUE_FLAG_NONE = 0x0,
111 | XDP_NOTIFY_QUEUE_FLAG_RX = 0x1,
112 | XDP_NOTIFY_QUEUE_FLAG_TX = 0x2,
113 | XDP_NOTIFY_QUEUE_FLAG_RX_FLUSH = 0x4,
114 | XDP_NOTIFY_QUEUE_FLAG_TX_FLUSH = 0x8,
115 | } XDP_NOTIFY_QUEUE_FLAGS;
116 |
117 | DEFINE_ENUM_FLAG_OPERATORS(XDP_NOTIFY_QUEUE_FLAGS);
118 |
119 | typedef
120 | _IRQL_requires_max_(PASSIVE_LEVEL)
121 | VOID
122 | XDP_INTERFACE_NOTIFY_QUEUE(
123 | _In_ XDP_INTERFACE_HANDLE InterfaceQueue,
124 | _In_ XDP_NOTIFY_QUEUE_FLAGS Flags
125 | );
126 |
127 | #include
128 |
129 | EXTERN_C_END
130 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | syntax: glob
2 |
3 | ### VisualStudio ###
4 |
5 | # Tool Runtime Dir
6 | # note: there is no trailing slash so if these are symlinks (which are seen as files,
7 | # instead of directories), git will still ignore them.
8 | .dotnet
9 | .packages
10 | .tools
11 |
12 | # User-specific files
13 | *.suo
14 | *.user
15 | *.userosscache
16 | *.sln.docstates
17 |
18 | # Build results
19 | artifacts/
20 | .idea/
21 | [Dd]ebug/
22 | [Dd]ebugPublic/
23 | [Rr]elease/
24 | [Rr]eleases/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | msbuild.log
29 | msbuild.err
30 | msbuild.wrn
31 | *.binlog
32 | .deps/
33 | .dirstamp
34 | .libs/
35 | *.lo
36 | *.o
37 |
38 | # Cross directory
39 | eng/common/cross
40 |
41 | # Visual Studio
42 | .vs/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | #NUNIT
49 | *.VisualState.xml
50 | TestResult.xml
51 | testResults.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | *_i.c
59 | *_p.c
60 | *.ilk
61 | *.meta
62 | *.obj
63 | *.pch
64 | *.pdb
65 | *.pgc
66 | *.pgd
67 | *.rsp
68 | *.sbr
69 | *.tlb
70 | *.tli
71 | *.tlh
72 | *.tmp
73 | *.tmp_proj
74 | *.log
75 | *.vspscc
76 | *.vssscc
77 | .builds
78 | *.pidb
79 | *.svclog
80 | *.scc
81 |
82 | # Chutzpah Test files
83 | _Chutzpah*
84 |
85 | # Visual C++ cache files
86 | ipch/
87 | *.aps
88 | *.ncb
89 | *.opendb
90 | *.opensdf
91 | *.sdf
92 | *.cachefile
93 | *.VC.db
94 |
95 | # Visual Studio profiler
96 | *.psess
97 | *.vsp
98 | *.vspx
99 |
100 | # TFS 2012 Local Workspace
101 | $tf/
102 |
103 | # Guidance Automation Toolkit
104 | *.gpState
105 |
106 | # ReSharper is a .NET coding add-in
107 | _ReSharper*/
108 | *.[Rr]e[Ss]harper
109 | *.DotSettings.user
110 |
111 | # JustCode is a .NET coding addin-in
112 | .JustCode
113 |
114 | # TeamCity is a build add-in
115 | _TeamCity*
116 |
117 | # NuGet Packages
118 | *.nupkg
119 | *.nuget.g.props
120 | *.nuget.g.targets
121 | *.nuget.cache
122 | **/packages/*
123 | project.lock.json
124 | project.assets.json
125 | *.nuget.dgspec.json
126 |
127 | # C/C++ extension for Visual Studio Code
128 | browse.VC.db
129 | # Local settings folder for Visual Studio Code
130 | **/.vscode/**
131 | !**/.vscode/c_cpp_properties.json
132 |
133 | ### Windows ###
134 |
135 | # Folder config file
136 | Desktop.ini
137 |
138 | # Recycle Bin used on file shares
139 | $RECYCLE.BIN/
140 |
141 | # Windows Installer files
142 | *.cab
143 | *.msi
144 | *.msm
145 | *.msp
146 |
147 | # Windows shortcuts
148 | *.lnk
149 |
150 | ### Linux ###
151 |
152 | *~
153 |
154 | # KDE directory preferences
155 | .directory
156 |
157 | ### OSX ###
158 |
159 | .DS_Store
160 | .AppleDouble
161 | .LSOverride
162 |
163 | # Icon must end with two \r
164 | Icon
165 |
166 | # Thumbnails
167 | ._*
168 |
169 | # Files that might appear on external disk
170 | .Spotlight-V100
171 | .Trashes
172 |
173 | # Directories potentially created on remote AFP share
174 | .AppleDB
175 | .AppleDesktop
176 | Network Trash Folder
177 | Temporary Items
178 | .apdisk
179 |
180 | # vim temporary files
181 | [._]*.s[a-w][a-z]
182 | [._]s[a-w][a-z]
183 | *.un~
184 | Session.vim
185 | .netrwhist
186 |
187 | # Visual Studio Code
188 | .vscode/
189 | .devcontainer/
190 |
191 | # VS debug support files
192 | launchSettings.json
193 |
--------------------------------------------------------------------------------
/src/xdp/include/afxdp_experimental.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | //
7 | // This header declares experimental AF_XDP interfaces. All definitions within
8 | // this file are subject to breaking changes, including removal.
9 | //
10 |
11 | #ifndef AFXDP_EXPERIMENTAL_H
12 | #define AFXDP_EXPERIMENTAL_H
13 |
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 |
18 | //
19 | // XSK_SOCKOPT_POLL_MODE
20 | //
21 | // Supports: set
22 | // Optval type: XSK_POLL_MODE
23 | // Description: Sets the poll mode of a socket.
24 | //
25 |
26 | #define XSK_SOCKOPT_POLL_MODE 1000
27 |
28 | typedef enum _XSK_POLL_MODE {
29 | //
30 | // Sets the XSK polling mode to the system default.
31 | //
32 | // Expectation: XSK_RING_FLAG_NEED_POKE varies.
33 | //
34 | XSK_POLL_MODE_DEFAULT,
35 |
36 | //
37 | // Sets the XSK polling mode to a kernel busy loop.
38 | //
39 | // Expectation: XSK_RING_FLAG_NEED_POKE is usually FALSE.
40 | //
41 | XSK_POLL_MODE_BUSY,
42 |
43 | //
44 | // Sets the XSK polling mode to poll only in the context of XskNotifySocket.
45 | //
46 | // Expectation: XSK_RING_FLAG_NEED_POKE is usually TRUE.
47 | //
48 | XSK_POLL_MODE_SOCKET,
49 | } XSK_POLL_MODE;
50 |
51 | //
52 | // XSK_SOCKOPT_TX_FRAME_LAYOUT_EXTENSION
53 | //
54 | // Supports: get
55 | // Optval type: XDP_EXTENSION
56 | // Description: Gets the XDP_FRAME_LAYOUT descriptor extension for the TX frame
57 | // ring. This requires the socket is bound, the TX ring size is
58 | // set, and at least one socket option has enabled the frame layout
59 | // extension.
60 | //
61 | #define XSK_SOCKOPT_TX_FRAME_LAYOUT_EXTENSION 1001
62 |
63 | //
64 | // XSK_SOCKOPT_TX_FRAME_CHECKSUM_EXTENSION
65 | //
66 | // Supports: get
67 | // Optval type: XDP_EXTENSION
68 | // Description: Gets the XDP_FRAME_CHECKSUM descriptor extension for the TX
69 | // frame ring. This requires the socket is bound, the TX ring size
70 | // is set, and at least one socket option has enabled the frame
71 | // layout extension.
72 | //
73 | #define XSK_SOCKOPT_TX_FRAME_CHECKSUM_EXTENSION 1002
74 |
75 | //
76 | // XSK_SOCKOPT_OFFLOAD_UDP_CHECKSUM_TX
77 | //
78 | // Supports: set
79 | // Optval type: BOOLEAN
80 | // Description: Sets whether UDP checksum transmit offload is enabled. This
81 | // option requires the socket is bound and the TX frame ring size
82 | // is not set. This option enables the XDP_FRAME_LAYOUT and
83 | // XDP_FRAME_CHECKSUM extensions on the TX frame ring.
84 | //
85 | #define XSK_SOCKOPT_OFFLOAD_UDP_CHECKSUM_TX 1003
86 |
87 | //
88 | // XSK_SOCKOPT_OFFLOAD_UDP_CHECKSUM_TX_CAPABILITIES
89 | //
90 | // Supports: get
91 | // Optval type: XSK_OFFLOAD_UDP_CHECKSUM_TX_CAPABILITIES
92 | // Description: Returns the UDP checksum transmit offload capabilities. This
93 | // option requires the socket is bound.
94 | //
95 | #define XSK_SOCKOPT_OFFLOAD_UDP_CHECKSUM_TX_CAPABILITIES 1004
96 |
97 | typedef struct _XSK_OFFLOAD_UDP_CHECKSUM_TX_CAPABILITIES {
98 | BOOLEAN Supported;
99 | } XSK_OFFLOAD_UDP_CHECKSUM_TX_CAPABILITIES;
100 |
101 | #ifdef __cplusplus
102 | } // extern "C"
103 | #endif
104 |
105 | #endif
106 |
--------------------------------------------------------------------------------
/eng/common/templates-official/job/source-index-stage1.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | runAsPublic: false
3 | sourceIndexPackageVersion: 1.0.1-20240129.2
4 | sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
5 | sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
6 | preSteps: []
7 | binlogPath: artifacts/log/Debug/Build.binlog
8 | condition: ''
9 | dependsOn: ''
10 | pool: ''
11 |
12 | jobs:
13 | - job: SourceIndexStage1
14 | dependsOn: ${{ parameters.dependsOn }}
15 | condition: ${{ parameters.condition }}
16 | variables:
17 | - name: SourceIndexPackageVersion
18 | value: ${{ parameters.sourceIndexPackageVersion }}
19 | - name: SourceIndexPackageSource
20 | value: ${{ parameters.sourceIndexPackageSource }}
21 | - name: BinlogPath
22 | value: ${{ parameters.binlogPath }}
23 | - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
24 | - group: source-dot-net stage1 variables
25 | - template: /eng/common/templates-official/variables/pool-providers.yml
26 |
27 | ${{ if ne(parameters.pool, '') }}:
28 | pool: ${{ parameters.pool }}
29 | ${{ if eq(parameters.pool, '') }}:
30 | pool:
31 | ${{ if eq(variables['System.TeamProject'], 'public') }}:
32 | name: $(DncEngPublicBuildPool)
33 | image: windows.vs2022.amd64.open
34 | ${{ if eq(variables['System.TeamProject'], 'internal') }}:
35 | name: $(DncEngInternalBuildPool)
36 | image: windows.vs2022.amd64
37 |
38 | steps:
39 | - ${{ each preStep in parameters.preSteps }}:
40 | - ${{ preStep }}
41 |
42 | - task: UseDotNet@2
43 | displayName: Use .NET 8 SDK
44 | inputs:
45 | packageType: sdk
46 | version: 8.0.x
47 | installationPath: $(Agent.TempDirectory)/dotnet
48 | workingDirectory: $(Agent.TempDirectory)
49 |
50 | - script: |
51 | $(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
52 | $(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
53 | displayName: Download Tools
54 | # Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk.
55 | workingDirectory: $(Agent.TempDirectory)
56 |
57 | - script: ${{ parameters.sourceIndexBuildCommand }}
58 | displayName: Build Repository
59 |
60 | - script: $(Agent.TempDirectory)/.source-index/tools/BinLogToSln -i $(BinlogPath) -r $(Build.SourcesDirectory) -n $(Build.Repository.Name) -o .source-index/stage1output
61 | displayName: Process Binlog into indexable sln
62 |
63 | - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
64 | - script: $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name)
65 | displayName: Upload stage1 artifacts to source index
66 | env:
67 | BLOB_CONTAINER_URL: $(source-dot-net-stage1-blob-container-url)
68 |
--------------------------------------------------------------------------------
/eng/common/templates/job/source-index-stage1.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | runAsPublic: false
3 | sourceIndexPackageVersion: 1.0.1-20240129.2
4 | sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
5 | sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
6 | preSteps: []
7 | binlogPath: artifacts/log/Debug/Build.binlog
8 | condition: ''
9 | dependsOn: ''
10 | pool: ''
11 |
12 | jobs:
13 | - job: SourceIndexStage1
14 | dependsOn: ${{ parameters.dependsOn }}
15 | condition: ${{ parameters.condition }}
16 | variables:
17 | - name: SourceIndexPackageVersion
18 | value: ${{ parameters.sourceIndexPackageVersion }}
19 | - name: SourceIndexPackageSource
20 | value: ${{ parameters.sourceIndexPackageSource }}
21 | - name: BinlogPath
22 | value: ${{ parameters.binlogPath }}
23 | - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
24 | - group: source-dot-net stage1 variables
25 | - template: /eng/common/templates/variables/pool-providers.yml
26 |
27 | ${{ if ne(parameters.pool, '') }}:
28 | pool: ${{ parameters.pool }}
29 | ${{ if eq(parameters.pool, '') }}:
30 | pool:
31 | ${{ if eq(variables['System.TeamProject'], 'public') }}:
32 | name: $(DncEngPublicBuildPool)
33 | demands: ImageOverride -equals windows.vs2022.amd64.open
34 | ${{ if eq(variables['System.TeamProject'], 'internal') }}:
35 | name: $(DncEngInternalBuildPool)
36 | demands: ImageOverride -equals windows.vs2022.amd64
37 |
38 | steps:
39 | - ${{ each preStep in parameters.preSteps }}:
40 | - ${{ preStep }}
41 |
42 | - task: UseDotNet@2
43 | displayName: Use .NET 8 SDK
44 | inputs:
45 | packageType: sdk
46 | version: 8.0.x
47 | installationPath: $(Agent.TempDirectory)/dotnet
48 | workingDirectory: $(Agent.TempDirectory)
49 |
50 | - script: |
51 | $(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
52 | $(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
53 | displayName: Download Tools
54 | # Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk.
55 | workingDirectory: $(Agent.TempDirectory)
56 |
57 | - script: ${{ parameters.sourceIndexBuildCommand }}
58 | displayName: Build Repository
59 |
60 | - script: $(Agent.TempDirectory)/.source-index/tools/BinLogToSln -i $(BinlogPath) -r $(Build.SourcesDirectory) -n $(Build.Repository.Name) -o .source-index/stage1output
61 | displayName: Process Binlog into indexable sln
62 |
63 | - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
64 | - script: $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name)
65 | displayName: Upload stage1 artifacts to source index
66 | env:
67 | BLOB_CONTAINER_URL: $(source-dot-net-stage1-blob-container-url)
68 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/program.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDPPROGRAM_H
7 | #define XDPPROGRAM_H
8 |
9 | #include
10 | #include
11 |
12 | #ifdef __cplusplus
13 | extern "C" {
14 | #endif
15 |
16 | #pragma warning(push)
17 | #pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
18 |
19 | typedef enum _XDP_MATCH_TYPE {
20 | XDP_MATCH_ALL,
21 | XDP_MATCH_UDP,
22 | XDP_MATCH_UDP_DST,
23 | XDP_MATCH_IPV4_DST_MASK,
24 | XDP_MATCH_IPV6_DST_MASK,
25 | XDP_MATCH_QUIC_FLOW_SRC_CID,
26 | XDP_MATCH_QUIC_FLOW_DST_CID,
27 | XDP_MATCH_IPV4_UDP_TUPLE,
28 | XDP_MATCH_IPV6_UDP_TUPLE,
29 | XDP_MATCH_UDP_PORT_SET,
30 | XDP_MATCH_IPV4_UDP_PORT_SET,
31 | XDP_MATCH_IPV6_UDP_PORT_SET,
32 | XDP_MATCH_IPV4_TCP_PORT_SET,
33 | XDP_MATCH_IPV6_TCP_PORT_SET,
34 | XDP_MATCH_TCP_DST,
35 | XDP_MATCH_TCP_QUIC_FLOW_SRC_CID,
36 | XDP_MATCH_TCP_QUIC_FLOW_DST_CID,
37 | XDP_MATCH_TCP_CONTROL_DST,
38 | } XDP_MATCH_TYPE;
39 |
40 | typedef union _XDP_INET_ADDR {
41 | IN_ADDR Ipv4;
42 | IN6_ADDR Ipv6;
43 | } XDP_INET_ADDR;
44 |
45 | typedef struct _XDP_IP_ADDRESS_MASK {
46 | XDP_INET_ADDR Mask;
47 | XDP_INET_ADDR Address;
48 | } XDP_IP_ADDRESS_MASK;
49 |
50 | typedef struct _XDP_TUPLE {
51 | XDP_INET_ADDR SourceAddress;
52 | XDP_INET_ADDR DestinationAddress;
53 | UINT16 SourcePort;
54 | UINT16 DestinationPort;
55 | } XDP_TUPLE;
56 |
57 | #define XDP_QUIC_MAX_CID_LENGTH 20
58 |
59 | typedef struct _XDP_QUIC_FLOW {
60 | UINT16 UdpPort;
61 | UCHAR CidLength;
62 | UCHAR CidOffset;
63 | UCHAR CidData[XDP_QUIC_MAX_CID_LENGTH]; // Max allowed per QUIC v1 RFC
64 | } XDP_QUIC_FLOW;
65 |
66 | #define XDP_PORT_SET_BUFFER_SIZE ((MAXUINT16 + 1) / 8)
67 |
68 | typedef struct _XDP_PORT_SET {
69 | const UINT8 *PortSet;
70 | VOID *Reserved;
71 | } XDP_PORT_SET;
72 |
73 | typedef struct _XDP_IP_PORT_SET {
74 | XDP_INET_ADDR Address;
75 | XDP_PORT_SET PortSet;
76 | } XDP_IP_PORT_SET;
77 |
78 | typedef union _XDP_MATCH_PATTERN {
79 | UINT16 Port;
80 | XDP_IP_ADDRESS_MASK IpMask;
81 | XDP_TUPLE Tuple;
82 | XDP_QUIC_FLOW QuicFlow;
83 | XDP_PORT_SET PortSet;
84 | XDP_IP_PORT_SET IpPortSet;
85 | } XDP_MATCH_PATTERN;
86 |
87 | typedef enum _XDP_RULE_ACTION {
88 | XDP_PROGRAM_ACTION_DROP,
89 | XDP_PROGRAM_ACTION_PASS,
90 | XDP_PROGRAM_ACTION_REDIRECT,
91 | XDP_PROGRAM_ACTION_L2FWD,
92 | //
93 | // Reserved.
94 | //
95 | XDP_PROGRAM_ACTION_EBPF,
96 | } XDP_RULE_ACTION;
97 |
98 | typedef enum _XDP_REDIRECT_TARGET_TYPE {
99 | XDP_REDIRECT_TARGET_TYPE_XSK,
100 | } XDP_REDIRECT_TARGET_TYPE;
101 |
102 | typedef struct _XDP_REDIRECT_PARAMS {
103 | XDP_REDIRECT_TARGET_TYPE TargetType;
104 | HANDLE Target;
105 | } XDP_REDIRECT_PARAMS;
106 |
107 | typedef struct _XDP_EBPF_PARAMS {
108 | HANDLE Target;
109 | } XDP_EBPF_PARAMS;
110 |
111 | typedef struct _XDP_RULE {
112 | XDP_MATCH_TYPE Match;
113 | XDP_MATCH_PATTERN Pattern;
114 | XDP_RULE_ACTION Action;
115 | union {
116 | XDP_REDIRECT_PARAMS Redirect;
117 | XDP_EBPF_PARAMS Ebpf;
118 | };
119 | } XDP_RULE;
120 |
121 | #pragma warning(pop)
122 |
123 | #ifdef __cplusplus
124 | } // extern "C"
125 | #endif
126 |
127 | #endif
128 |
--------------------------------------------------------------------------------
/eng/addCmakeToPath.ps1:
--------------------------------------------------------------------------------
1 | function GetCMakeVersions
2 | {
3 | $items = @()
4 | $items += @(Get-ChildItem hklm:\SOFTWARE\Wow6432Node\Kitware -ErrorAction SilentlyContinue)
5 | $items += @(Get-ChildItem hklm:\SOFTWARE\Kitware -ErrorAction SilentlyContinue)
6 | return $items | where { $_.PSChildName.StartsWith("CMake") }
7 | }
8 |
9 | function GetCMakeInfo($regKey)
10 | {
11 | try {
12 | $version = [System.Version] $regKey.PSChildName.Split(' ')[1]
13 | }
14 | catch {
15 | return $null
16 | }
17 | $itemProperty = Get-ItemProperty $regKey.PSPath;
18 | if (Get-Member -inputobject $itemProperty -name "InstallDir" -Membertype Properties) {
19 | $cmakeDir = $itemProperty.InstallDir
20 | }
21 | else {
22 | $cmakeDir = $itemProperty.'(default)'
23 | }
24 | $cmakePath = [System.IO.Path]::Combine($cmakeDir, "artifacts\cmake.exe")
25 | if (![System.IO.File]::Exists($cmakePath)) {
26 | return $null
27 | }
28 | return @{'version' = $version; 'path' = $cmakePath}
29 | }
30 |
31 | function DownloadCMake
32 | {
33 | $downloadDir = (Split-Path $PSScriptRoot -Parent) + "\artifacts\download"
34 | $cmakeExtractPath = $downloadDir + "\cmake"
35 |
36 | $cmakeSearch = (Get-ChildItem -Path $cmakeExtractPath -Filter cmake.exe -Recurse -ErrorAction SilentlyContinue)
37 | if ($null -eq $cmakeSearch -or $cmakeSearch.Count -eq 0)
38 | {
39 | Write-Host "Downloading CMake"
40 | $cmakeZip = $downloadDir + "\cmake.zip"
41 | $cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-win64-x64.zip"
42 | if (!(Test-Path $downloadDir)) { $throwAway = mkdir $downloadDir }
43 | if (!(Test-Path $cmakeZip))
44 | {
45 | Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeZip
46 | }
47 |
48 | Write-Host "Extracting Cmake"
49 | if (!(Test-Path $cmakeExtractPath)) { $throwAway = mkdir $cmakeExtractPath }
50 | [System.IO.Compression.ZipFile]::ExtractToDirectory($cmakeZip, $cmakeExtractPath)
51 | return (Get-ChildItem -Path $cmakeExtractPath -Filter cmake.exe -Recurse -ErrorAction SilentlyContinue).FullName
52 | }
53 |
54 | return $cmakeSearch.FullName
55 | }
56 |
57 | function LocateCMake
58 | {
59 | $errorMsg = "CMake is a pre-requisite to build this repository but it was not found on the path. Please install CMake from https://cmake.org/download/ and ensure it is on your path."
60 | $inPathPath = (get-command cmake.exe -All -ErrorAction SilentlyContinue)
61 | if ($inPathPath -ne $null -or $inPathPath.Length -ge 1) {
62 | # Resolve the first version of CMake if multiple commands are found
63 | if ($inPathPath.Length -gt 1) {
64 | return $inPathPath[0].Path
65 | }
66 | return $inPathPath.Path
67 | }
68 | # Let us hope that CMake keep using their current version scheme
69 | $validVersions = @()
70 | foreach ($regKey in GetCMakeVersions) {
71 | $info = GetCMakeInfo($regKey)
72 | if ($info -ne $null) {
73 | $validVersions += @($info)
74 | }
75 | }
76 | $newestCMakePath = ($validVersions |
77 | Sort-Object -property @{Expression={$_.version}; Ascending=$false} |
78 | select -first 1).path
79 | if ($newestCMakePath -eq $null) {
80 | return DownloadCMake
81 | }
82 |
83 | return $newestCMakePath
84 | }
85 |
86 | function SetCMakePath
87 | {
88 | $cmakePath = LocateCMake
89 | $directory = Split-Path -Path $cmakePath
90 | Write-Host $directory
91 | echo "##vso[task.prependpath]$directory"
92 | $env:Path = "$directory;$env:Path"
93 | &{ cmake -version }
94 | }
95 |
96 | SetCMakePath
--------------------------------------------------------------------------------
/eng/common/templates/job/source-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # This template adds arcade-powered source-build to CI. The template produces a server job with a
3 | # default ID 'Source_Build_Complete' to put in a dependency list if necessary.
4 |
5 | # Specifies the prefix for source-build jobs added to pipeline. Use this if disambiguation needed.
6 | jobNamePrefix: 'Source_Build'
7 |
8 | # Defines the platform on which to run the job. By default, a linux-x64 machine, suitable for
9 | # managed-only repositories. This is an object with these properties:
10 | #
11 | # name: ''
12 | # The name of the job. This is included in the job ID.
13 | # targetRID: ''
14 | # The name of the target RID to use, instead of the one auto-detected by Arcade.
15 | # nonPortable: false
16 | # Enables non-portable mode. This means a more specific RID (e.g. fedora.32-x64 rather than
17 | # linux-x64), and compiling against distro-provided packages rather than portable ones.
18 | # skipPublishValidation: false
19 | # Disables publishing validation. By default, a check is performed to ensure no packages are
20 | # published by source-build.
21 | # container: ''
22 | # A container to use. Runs in docker.
23 | # pool: {}
24 | # A pool to use. Runs directly on an agent.
25 | # buildScript: ''
26 | # Specifies the build script to invoke to perform the build in the repo. The default
27 | # './build.sh' should work for typical Arcade repositories, but this is customizable for
28 | # difficult situations.
29 | # jobProperties: {}
30 | # A list of job properties to inject at the top level, for potential extensibility beyond
31 | # container and pool.
32 | platform: {}
33 |
34 | jobs:
35 | - job: ${{ parameters.jobNamePrefix }}_${{ parameters.platform.name }}
36 | displayName: Source-Build (${{ parameters.platform.name }})
37 |
38 | ${{ each property in parameters.platform.jobProperties }}:
39 | ${{ property.key }}: ${{ property.value }}
40 |
41 | ${{ if ne(parameters.platform.container, '') }}:
42 | container: ${{ parameters.platform.container }}
43 |
44 | ${{ if eq(parameters.platform.pool, '') }}:
45 | # The default VM host AzDO pool. This should be capable of running Docker containers: almost all
46 | # source-build builds run in Docker, including the default managed platform.
47 | # /eng/common/templates/variables/pool-providers.yml can't be used here (some customers declare variables already), so duplicate its logic
48 | pool:
49 | ${{ if eq(variables['System.TeamProject'], 'public') }}:
50 | name: $[replace(replace(eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), True, 'NetCore-Svc-Public' ), False, 'NetCore-Public')]
51 | demands: ImageOverride -equals Build.Ubuntu.1804.Amd64.Open
52 |
53 | ${{ if eq(variables['System.TeamProject'], 'internal') }}:
54 | name: $[replace(replace(eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), True, 'NetCore1ESPool-Svc-Internal'), False, 'NetCore1ESPool-Internal')]
55 | demands: ImageOverride -equals Build.Ubuntu.1804.Amd64
56 |
57 | ${{ if ne(parameters.platform.pool, '') }}:
58 | pool: ${{ parameters.platform.pool }}
59 |
60 | workspace:
61 | clean: all
62 |
63 | steps:
64 | - template: /eng/common/templates/steps/source-build.yml
65 | parameters:
66 | platform: ${{ parameters.platform }}
67 |
--------------------------------------------------------------------------------
/eng/common/templates-official/job/source-build.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # This template adds arcade-powered source-build to CI. The template produces a server job with a
3 | # default ID 'Source_Build_Complete' to put in a dependency list if necessary.
4 |
5 | # Specifies the prefix for source-build jobs added to pipeline. Use this if disambiguation needed.
6 | jobNamePrefix: 'Source_Build'
7 |
8 | # Defines the platform on which to run the job. By default, a linux-x64 machine, suitable for
9 | # managed-only repositories. This is an object with these properties:
10 | #
11 | # name: ''
12 | # The name of the job. This is included in the job ID.
13 | # targetRID: ''
14 | # The name of the target RID to use, instead of the one auto-detected by Arcade.
15 | # nonPortable: false
16 | # Enables non-portable mode. This means a more specific RID (e.g. fedora.32-x64 rather than
17 | # linux-x64), and compiling against distro-provided packages rather than portable ones.
18 | # skipPublishValidation: false
19 | # Disables publishing validation. By default, a check is performed to ensure no packages are
20 | # published by source-build.
21 | # container: ''
22 | # A container to use. Runs in docker.
23 | # pool: {}
24 | # A pool to use. Runs directly on an agent.
25 | # buildScript: ''
26 | # Specifies the build script to invoke to perform the build in the repo. The default
27 | # './build.sh' should work for typical Arcade repositories, but this is customizable for
28 | # difficult situations.
29 | # jobProperties: {}
30 | # A list of job properties to inject at the top level, for potential extensibility beyond
31 | # container and pool.
32 | platform: {}
33 |
34 | jobs:
35 | - job: ${{ parameters.jobNamePrefix }}_${{ parameters.platform.name }}
36 | displayName: Source-Build (${{ parameters.platform.name }})
37 |
38 | ${{ each property in parameters.platform.jobProperties }}:
39 | ${{ property.key }}: ${{ property.value }}
40 |
41 | ${{ if ne(parameters.platform.container, '') }}:
42 | container: ${{ parameters.platform.container }}
43 |
44 | ${{ if eq(parameters.platform.pool, '') }}:
45 | # The default VM host AzDO pool. This should be capable of running Docker containers: almost all
46 | # source-build builds run in Docker, including the default managed platform.
47 | # /eng/common/templates-official/variables/pool-providers.yml can't be used here (some customers declare variables already), so duplicate its logic
48 | pool:
49 | ${{ if eq(variables['System.TeamProject'], 'public') }}:
50 | name: $[replace(replace(eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), True, 'NetCore-Svc-Public' ), False, 'NetCore-Public')]
51 | demands: ImageOverride -equals build.ubuntu.1804.amd64
52 |
53 | ${{ if eq(variables['System.TeamProject'], 'internal') }}:
54 | name: $[replace(replace(eq(contains(coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranch'], 'refs/heads/main'), 'release'), 'true'), True, 'NetCore1ESPool-Svc-Internal'), False, 'NetCore1ESPool-Internal')]
55 | image: 1es-mariner-2
56 | os: linux
57 |
58 | ${{ if ne(parameters.platform.pool, '') }}:
59 | pool: ${{ parameters.platform.pool }}
60 |
61 | workspace:
62 | clean: all
63 |
64 | steps:
65 | - template: /eng/common/templates-official/steps/source-build.yml
66 | parameters:
67 | platform: ${{ parameters.platform }}
68 |
--------------------------------------------------------------------------------
/src/xdp/include/afxdp_helper.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef AFXDP_HELPER_H
7 | #define AFXDP_HELPER_H
8 |
9 | #include
10 | #include
11 |
12 | #ifdef __cplusplus
13 | extern "C" {
14 | #endif
15 |
16 | typedef struct _XSK_RING {
17 | UINT32 *SharedProducer;
18 | UINT32 *SharedConsumer;
19 | UINT32 *SharedFlags;
20 | VOID *SharedElements;
21 | UINT32 Mask;
22 | UINT32 Size;
23 | UINT32 ElementStride;
24 | } XSK_RING;
25 |
26 | inline
27 | VOID
28 | XskRingInitialize(
29 | _Out_ XSK_RING *Ring,
30 | _In_ CONST XSK_RING_INFO *RingInfo
31 | )
32 | {
33 | RtlZeroMemory(Ring, sizeof(*Ring));
34 |
35 | Ring->SharedProducer = (UINT32 *)(RingInfo->Ring + RingInfo->ProducerIndexOffset);
36 | Ring->SharedConsumer = (UINT32 *)(RingInfo->Ring + RingInfo->ConsumerIndexOffset);
37 | Ring->SharedFlags = (UINT32 *)(RingInfo->Ring + RingInfo->FlagsOffset);
38 | Ring->SharedElements = RingInfo->Ring + RingInfo->DescriptorsOffset;
39 |
40 | Ring->Mask = RingInfo->Size - 1;
41 | Ring->Size = RingInfo->Size;
42 | Ring->ElementStride = RingInfo->ElementStride;
43 | }
44 |
45 | inline
46 | VOID *
47 | XskRingGetElement(
48 | _In_ CONST XSK_RING *Ring,
49 | _In_ UINT32 Index
50 | )
51 | {
52 | return (UCHAR *)Ring->SharedElements + (Index & Ring->Mask) * (SIZE_T)Ring->ElementStride;
53 | }
54 |
55 | inline
56 | UINT32
57 | XskRingGetFlags(
58 | _In_ CONST XSK_RING *Ring
59 | )
60 | {
61 | return ReadUInt32Acquire(Ring->SharedFlags);
62 | }
63 |
64 | inline
65 | UINT32
66 | XskRingConsumerReserve(
67 | _In_ XSK_RING *Ring,
68 | _In_ UINT32 MaxCount,
69 | _Out_ UINT32 *Index
70 | )
71 | {
72 | UINT32 Consumer = *Ring->SharedConsumer;
73 | UINT32 Available = ReadUInt32Acquire(Ring->SharedProducer) - Consumer;
74 | *Index = Consumer;
75 | return Available < MaxCount ? Available : MaxCount;
76 | }
77 |
78 | inline
79 | VOID
80 | XskRingConsumerRelease(
81 | _Inout_ XSK_RING *Ring,
82 | _In_ UINT32 Count
83 | )
84 | {
85 | *Ring->SharedConsumer += Count;
86 | }
87 |
88 | inline
89 | UINT32
90 | XskRingProducerReserve(
91 | _In_ XSK_RING *Ring,
92 | _In_ UINT32 MaxCount,
93 | _Out_ UINT32 *Index
94 | )
95 | {
96 | UINT32 Producer = *Ring->SharedProducer;
97 | UINT32 Available = Ring->Size - (Producer - ReadUInt32Acquire(Ring->SharedConsumer));
98 | *Index = Producer;
99 | return Available < MaxCount ? Available : MaxCount;
100 | }
101 |
102 | inline
103 | VOID
104 | XskRingProducerSubmit(
105 | _Inout_ XSK_RING *Ring,
106 | _In_ UINT32 Count
107 | )
108 | {
109 | WriteUInt32Release(Ring->SharedProducer, *Ring->SharedProducer + Count);
110 | }
111 |
112 | inline
113 | BOOLEAN
114 | XskRingError(
115 | _In_ CONST XSK_RING *Ring
116 | )
117 | {
118 | return !!(XskRingGetFlags(Ring) & XSK_RING_FLAG_ERROR);
119 | }
120 |
121 | inline
122 | BOOLEAN
123 | XskRingProducerNeedPoke(
124 | _In_ CONST XSK_RING *Ring
125 | )
126 | {
127 | return !!(XskRingGetFlags(Ring) & XSK_RING_FLAG_NEED_POKE);
128 | }
129 |
130 | inline
131 | BOOLEAN
132 | XskRingAffinityChanged(
133 | _In_ CONST XSK_RING *Ring
134 | )
135 | {
136 | return !!(XskRingGetFlags(Ring) & XSK_RING_FLAG_AFFINITY_CHANGED);
137 | }
138 |
139 | #ifdef __cplusplus
140 | } // extern "C"
141 | #endif
142 |
143 | #endif
144 |
--------------------------------------------------------------------------------
/eng/common/sdk-task.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(PositionalBinding=$false)]
2 | Param(
3 | [string] $configuration = 'Debug',
4 | [string] $task,
5 | [string] $verbosity = 'minimal',
6 | [string] $msbuildEngine = $null,
7 | [switch] $restore,
8 | [switch] $prepareMachine,
9 | [switch] $help,
10 | [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
11 | )
12 |
13 | $ci = $true
14 | $binaryLog = $true
15 | $warnAsError = $true
16 |
17 | . $PSScriptRoot\tools.ps1
18 |
19 | function Print-Usage() {
20 | Write-Host "Common settings:"
21 | Write-Host " -task Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package)"
22 | Write-Host " -restore Restore dependencies"
23 | Write-Host " -verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]"
24 | Write-Host " -help Print help and exit"
25 | Write-Host ""
26 |
27 | Write-Host "Advanced settings:"
28 | Write-Host " -prepareMachine Prepare machine for CI run"
29 | Write-Host " -msbuildEngine Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
30 | Write-Host ""
31 | Write-Host "Command line arguments not listed above are passed thru to msbuild."
32 | }
33 |
34 | function Build([string]$target) {
35 | $logSuffix = if ($target -eq 'Execute') { '' } else { ".$target" }
36 | $log = Join-Path $LogDir "$task$logSuffix.binlog"
37 | $outputPath = Join-Path $ToolsetDir "$task\"
38 |
39 | MSBuild $taskProject `
40 | /bl:$log `
41 | /t:$target `
42 | /p:Configuration=$configuration `
43 | /p:RepoRoot=$RepoRoot `
44 | /p:BaseIntermediateOutputPath=$outputPath `
45 | /v:$verbosity `
46 | @properties
47 | }
48 |
49 | try {
50 | if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) {
51 | Print-Usage
52 | exit 0
53 | }
54 |
55 | if ($task -eq "") {
56 | Write-PipelineTelemetryError -Category 'Build' -Message "Missing required parameter '-task '"
57 | Print-Usage
58 | ExitWithExitCode 1
59 | }
60 |
61 | if( $msbuildEngine -eq "vs") {
62 | # Ensure desktop MSBuild is available for sdk tasks.
63 | if( -not ($GlobalJson.tools.PSObject.Properties.Name -contains "vs" )) {
64 | $GlobalJson.tools | Add-Member -Name "vs" -Value (ConvertFrom-Json "{ `"version`": `"16.5`" }") -MemberType NoteProperty
65 | }
66 | if( -not ($GlobalJson.tools.PSObject.Properties.Name -match "xcopy-msbuild" )) {
67 | $GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.8.5" -MemberType NoteProperty
68 | }
69 | if ($GlobalJson.tools."xcopy-msbuild".Trim() -ine "none") {
70 | $xcopyMSBuildToolsFolder = InitializeXCopyMSBuild $GlobalJson.tools."xcopy-msbuild" -install $true
71 | }
72 | if ($xcopyMSBuildToolsFolder -eq $null) {
73 | throw 'Unable to get xcopy downloadable version of msbuild'
74 | }
75 |
76 | $global:_MSBuildExe = "$($xcopyMSBuildToolsFolder)\MSBuild\Current\Bin\MSBuild.exe"
77 | }
78 |
79 | $taskProject = GetSdkTaskProject $task
80 | if (!(Test-Path $taskProject)) {
81 | Write-PipelineTelemetryError -Category 'Build' -Message "Unknown task: $task"
82 | ExitWithExitCode 1
83 | }
84 |
85 | if ($restore) {
86 | Build 'Restore'
87 | }
88 |
89 | Build 'Execute'
90 | }
91 | catch {
92 | Write-Host $_.ScriptStackTrace
93 | Write-PipelineTelemetryError -Category 'Build' -Message $_
94 | ExitWithExitCode 1
95 | }
96 |
97 | ExitWithExitCode 0
98 |
--------------------------------------------------------------------------------
/eng/common/native/install-cmake.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
5 |
6 | . $scriptroot/common-library.sh
7 |
8 | base_uri=
9 | install_path=
10 | version=
11 | clean=false
12 | force=false
13 | download_retries=5
14 | retry_wait_time_seconds=30
15 |
16 | while (($# > 0)); do
17 | lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
18 | case $lowerI in
19 | --baseuri)
20 | base_uri=$2
21 | shift 2
22 | ;;
23 | --installpath)
24 | install_path=$2
25 | shift 2
26 | ;;
27 | --version)
28 | version=$2
29 | shift 2
30 | ;;
31 | --clean)
32 | clean=true
33 | shift 1
34 | ;;
35 | --force)
36 | force=true
37 | shift 1
38 | ;;
39 | --downloadretries)
40 | download_retries=$2
41 | shift 2
42 | ;;
43 | --retrywaittimeseconds)
44 | retry_wait_time_seconds=$2
45 | shift 2
46 | ;;
47 | --help)
48 | echo "Common settings:"
49 | echo " --baseuri Base file directory or Url wrom which to acquire tool archives"
50 | echo " --installpath Base directory to install native tool to"
51 | echo " --clean Don't install the tool, just clean up the current install of the tool"
52 | echo " --force Force install of tools even if they previously exist"
53 | echo " --help Print help and exit"
54 | echo ""
55 | echo "Advanced settings:"
56 | echo " --downloadretries Total number of retry attempts"
57 | echo " --retrywaittimeseconds Wait time between retry attempts in seconds"
58 | echo ""
59 | exit 0
60 | ;;
61 | esac
62 | done
63 |
64 | tool_name="cmake"
65 | tool_os=$(GetCurrentOS)
66 | tool_folder="$(echo $tool_os | tr "[:upper:]" "[:lower:]")"
67 | tool_arch="x86_64"
68 | tool_name_moniker="$tool_name-$version-$tool_os-$tool_arch"
69 | tool_install_directory="$install_path/$tool_name/$version"
70 | tool_file_path="$tool_install_directory/$tool_name_moniker/bin/$tool_name"
71 | shim_path="$install_path/$tool_name.sh"
72 | uri="${base_uri}/$tool_folder/$tool_name/$tool_name_moniker.tar.gz"
73 |
74 | # Clean up tool and installers
75 | if [[ $clean = true ]]; then
76 | echo "Cleaning $tool_install_directory"
77 | if [[ -d $tool_install_directory ]]; then
78 | rm -rf $tool_install_directory
79 | fi
80 |
81 | echo "Cleaning $shim_path"
82 | if [[ -f $shim_path ]]; then
83 | rm -rf $shim_path
84 | fi
85 |
86 | tool_temp_path=$(GetTempPathFileName $uri)
87 | echo "Cleaning $tool_temp_path"
88 | if [[ -f $tool_temp_path ]]; then
89 | rm -rf $tool_temp_path
90 | fi
91 |
92 | exit 0
93 | fi
94 |
95 | # Install tool
96 | if [[ -f $tool_file_path ]] && [[ $force = false ]]; then
97 | echo "$tool_name ($version) already exists, skipping install"
98 | exit 0
99 | fi
100 |
101 | DownloadAndExtract $uri $tool_install_directory $force $download_retries $retry_wait_time_seconds
102 |
103 | if [[ $? != 0 ]]; then
104 | Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Installation failed'
105 | exit 1
106 | fi
107 |
108 | # Generate Shim
109 | # Always rewrite shims so that we are referencing the expected version
110 | NewScriptShim $shim_path $tool_file_path true
111 |
112 | if [[ $? != 0 ]]; then
113 | Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Shim generation failed'
114 | exit 1
115 | fi
116 |
117 | exit 0
118 |
--------------------------------------------------------------------------------
/eng/common/native/install-cmake-test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source="${BASH_SOURCE[0]}"
4 | scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
5 |
6 | . $scriptroot/common-library.sh
7 |
8 | base_uri=
9 | install_path=
10 | version=
11 | clean=false
12 | force=false
13 | download_retries=5
14 | retry_wait_time_seconds=30
15 |
16 | while (($# > 0)); do
17 | lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
18 | case $lowerI in
19 | --baseuri)
20 | base_uri=$2
21 | shift 2
22 | ;;
23 | --installpath)
24 | install_path=$2
25 | shift 2
26 | ;;
27 | --version)
28 | version=$2
29 | shift 2
30 | ;;
31 | --clean)
32 | clean=true
33 | shift 1
34 | ;;
35 | --force)
36 | force=true
37 | shift 1
38 | ;;
39 | --downloadretries)
40 | download_retries=$2
41 | shift 2
42 | ;;
43 | --retrywaittimeseconds)
44 | retry_wait_time_seconds=$2
45 | shift 2
46 | ;;
47 | --help)
48 | echo "Common settings:"
49 | echo " --baseuri Base file directory or Url wrom which to acquire tool archives"
50 | echo " --installpath Base directory to install native tool to"
51 | echo " --clean Don't install the tool, just clean up the current install of the tool"
52 | echo " --force Force install of tools even if they previously exist"
53 | echo " --help Print help and exit"
54 | echo ""
55 | echo "Advanced settings:"
56 | echo " --downloadretries Total number of retry attempts"
57 | echo " --retrywaittimeseconds Wait time between retry attempts in seconds"
58 | echo ""
59 | exit 0
60 | ;;
61 | esac
62 | done
63 |
64 | tool_name="cmake-test"
65 | tool_os=$(GetCurrentOS)
66 | tool_folder="$(echo $tool_os | tr "[:upper:]" "[:lower:]")"
67 | tool_arch="x86_64"
68 | tool_name_moniker="$tool_name-$version-$tool_os-$tool_arch"
69 | tool_install_directory="$install_path/$tool_name/$version"
70 | tool_file_path="$tool_install_directory/$tool_name_moniker/bin/$tool_name"
71 | shim_path="$install_path/$tool_name.sh"
72 | uri="${base_uri}/$tool_folder/$tool_name/$tool_name_moniker.tar.gz"
73 |
74 | # Clean up tool and installers
75 | if [[ $clean = true ]]; then
76 | echo "Cleaning $tool_install_directory"
77 | if [[ -d $tool_install_directory ]]; then
78 | rm -rf $tool_install_directory
79 | fi
80 |
81 | echo "Cleaning $shim_path"
82 | if [[ -f $shim_path ]]; then
83 | rm -rf $shim_path
84 | fi
85 |
86 | tool_temp_path=$(GetTempPathFileName $uri)
87 | echo "Cleaning $tool_temp_path"
88 | if [[ -f $tool_temp_path ]]; then
89 | rm -rf $tool_temp_path
90 | fi
91 |
92 | exit 0
93 | fi
94 |
95 | # Install tool
96 | if [[ -f $tool_file_path ]] && [[ $force = false ]]; then
97 | echo "$tool_name ($version) already exists, skipping install"
98 | exit 0
99 | fi
100 |
101 | DownloadAndExtract $uri $tool_install_directory $force $download_retries $retry_wait_time_seconds
102 |
103 | if [[ $? != 0 ]]; then
104 | Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Installation failed'
105 | exit 1
106 | fi
107 |
108 | # Generate Shim
109 | # Always rewrite shims so that we are referencing the expected version
110 | NewScriptShim $shim_path $tool_file_path true
111 |
112 | if [[ $? != 0 ]]; then
113 | Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Shim generation failed'
114 | exit 1
115 | fi
116 |
117 | exit 0
118 |
--------------------------------------------------------------------------------
/src/xdp/include/xdp/rxqueueconfig.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #pragma once
7 |
8 | EXTERN_C_START
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | DECLARE_HANDLE(XDP_RX_QUEUE_CONFIG_CREATE);
17 | DECLARE_HANDLE(XDP_RX_QUEUE_CONFIG_ACTIVATE);
18 |
19 | CONST XDP_QUEUE_INFO *
20 | XdpRxQueueGetTargetQueueInfo(
21 | _In_ XDP_RX_QUEUE_CONFIG_CREATE RxQueueConfig
22 | );
23 |
24 | typedef struct _XDP_RX_CAPABILITIES {
25 | XDP_OBJECT_HEADER Header;
26 | BOOLEAN VirtualAddressSupported;
27 | UINT16 ReceiveFrameCountHint;
28 | UINT8 MaximumFragments;
29 | BOOLEAN TxActionSupported;
30 | } XDP_RX_CAPABILITIES;
31 |
32 | #define XDP_RX_CAPABILITIES_REVISION_1 1
33 |
34 | #define XDP_SIZEOF_RX_CAPABILITIES_REVISION_1 \
35 | RTL_SIZEOF_THROUGH_FIELD(XDP_RX_CAPABILITIES, TxActionSupported)
36 |
37 | inline
38 | VOID
39 | XdpInitializeRxCapabilitiesDriverVa(
40 | _Out_ XDP_RX_CAPABILITIES *Capabilities
41 | )
42 | {
43 | RtlZeroMemory(Capabilities, sizeof(*Capabilities));
44 | Capabilities->Header.Revision = XDP_RX_CAPABILITIES_REVISION_1;
45 | Capabilities->Header.Size = XDP_SIZEOF_RX_CAPABILITIES_REVISION_1;
46 | Capabilities->VirtualAddressSupported = TRUE;
47 | }
48 |
49 | typedef struct _XDP_RX_DESCRIPTOR_CONTEXTS {
50 | XDP_OBJECT_HEADER Header;
51 | UINT8 FrameContextSize;
52 | UINT8 FrameContextAlignment;
53 | UINT8 BufferContextSize;
54 | UINT8 BufferContextAlignment;
55 | } XDP_RX_DESCRIPTOR_CONTEXTS;
56 |
57 | #define XDP_RX_DESCRIPTOR_CONTEXTS_REVISION_1 1
58 |
59 | #define XDP_SIZEOF_RX_DESCRIPTOR_CONTEXTS_REVISION_1 \
60 | RTL_SIZEOF_THROUGH_FIELD(XDP_RX_DESCRIPTOR_CONTEXTS, BufferContextAlignment)
61 |
62 | inline
63 | VOID
64 | XdpInitializeRxDescriptorContexts(
65 | _Out_ XDP_RX_DESCRIPTOR_CONTEXTS *DescriptorContexts
66 | )
67 | {
68 | RtlZeroMemory(DescriptorContexts, sizeof(*DescriptorContexts));
69 | DescriptorContexts->Header.Revision = XDP_RX_DESCRIPTOR_CONTEXTS_REVISION_1;
70 | DescriptorContexts->Header.Size = XDP_SIZEOF_RX_DESCRIPTOR_CONTEXTS_REVISION_1;
71 | }
72 |
73 | VOID
74 | XdpRxQueueSetCapabilities(
75 | _In_ XDP_RX_QUEUE_CONFIG_CREATE RxQueueConfig,
76 | _In_ XDP_RX_CAPABILITIES *Capabilities
77 | );
78 |
79 | VOID
80 | XdpRxQueueRegisterExtensionVersion(
81 | _In_ XDP_RX_QUEUE_CONFIG_CREATE RxQueueConfig,
82 | _In_ XDP_EXTENSION_INFO *ExtensionInfo
83 | );
84 |
85 | VOID
86 | XdpRxQueueSetDescriptorContexts(
87 | _In_ XDP_RX_QUEUE_CONFIG_CREATE RxQueueConfig,
88 | _In_ XDP_RX_DESCRIPTOR_CONTEXTS *DescriptorContexts
89 | );
90 |
91 | VOID
92 | XdpRxQueueSetPollInfo(
93 | _In_ XDP_RX_QUEUE_CONFIG_CREATE RxQueueConfig,
94 | _In_ XDP_POLL_INFO *PollInfo
95 | );
96 |
97 | XDP_RING *
98 | XdpRxQueueGetFrameRing(
99 | _In_ XDP_RX_QUEUE_CONFIG_ACTIVATE RxQueueConfig
100 | );
101 |
102 | XDP_RING *
103 | XdpRxQueueGetFragmentRing(
104 | _In_ XDP_RX_QUEUE_CONFIG_ACTIVATE RxQueueConfig
105 | );
106 |
107 | VOID
108 | XdpRxQueueGetExtension(
109 | _In_ XDP_RX_QUEUE_CONFIG_ACTIVATE RxQueueConfig,
110 | _In_ XDP_EXTENSION_INFO *ExtensionInfo,
111 | _Out_ XDP_EXTENSION *Extension
112 | );
113 |
114 | BOOLEAN
115 | XdpRxQueueIsVirtualAddressEnabled(
116 | _In_ XDP_RX_QUEUE_CONFIG_ACTIVATE RxQueueConfig
117 | );
118 |
119 | #include
120 |
121 | EXTERN_C_END
122 |
--------------------------------------------------------------------------------
/FLOW.md:
--------------------------------------------------------------------------------
1 |
2 | [This](https://github.com/dotnet/msquic) repo is a thin wrapper around https://github.com/microsoft/msquic . It is used to produce a package for _testing_ purposes, when an official MsQuic package is not available.
3 | At this moment, there are two main use cases:
4 | - Consuming latest MsQuic main to pick up feature work and general improvements to feed main branch of runtime,
5 | - Building the package to test on Linux distros that don't have an official package yet (such as Alpine).
6 |
7 | The build will create signed NuGet packages to be consumed by Windows and unsigned Linux and MacOS packages. Neither of them are meant for direct consumption.
8 |
9 | On Windows, release versions of .NET use official MsQuic packages that are published to [NuGet](https://www.nuget.org/packages/Microsoft.Native.Quic.MsQuic.Schannel). Windows package is consumed by .NET runtime and `msquic.dll` is part of runtime distribution on Windows. In order to switch to the private package within the dotnet/runtime repo, you need to change the value of the [UseQuicTransportPackage](https://github.com/dotnet/runtime/blob/0c513d95c181159f3ea02531c7901ce15503f3ee/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj#L20) flag to `true`.
10 |
11 | For Linux, there is currently no automated workflow. Signed packages are published on https://packages.microsoft.com/. Linux users should use packages from there either directly or via their package manager.
12 |
13 | For more info, see [System.Net.Quic readme](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Quic/readme.md).
14 |
15 | **Build & Updates**
16 |
17 | To build this repro, make sure you checkout appropriate branch _RECURSIVELY_. MsQuic code is pulled in as submodule as well as it uses submodules internally. The build currently depends on PowerShell as well as it needs all the prerequisities required by MsQuic. (https://github.com/microsoft/msquic/blob/main/docs/BUILD.md)
18 |
19 | To build it, run top-level `build` script. That essentially calls `Build-native` from [src/System.Net.MsQuic.Transport/System.Net.MsQuic.Transport.csproj](https://github.com/dotnet/msquic/blob/main/src/System.Net.MsQuic.Transport/System.Net.MsQuic.Transport.csproj)
20 | To see what is going on with official Azure pipeline you can check [eng/pipelines/msquic.yml](https://github.com/dotnet/msquic/blob/main/eng/pipelines/msquic.yml)
21 |
22 | to update msquic you can use following sequence
23 | ```
24 | cd src/msquic
25 | git fetch origin
26 | git checkout main (or what ever branch or tag)
27 | cd ../..
28 | git add src/msquic
29 | ```
30 | At this point, full build is recommended and changes should be staged for PR. You can use `git log` to check whether msquic has changed. Also GitHub UI shows the actual changes instead of just updated directory like the command line tool.
31 |
32 | When changes are submitted, official build will kick in and it will produce updated NuGet package. To see the latest package and its history look at https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet9-transport/NuGet/System.Net.MsQuic.Transport
33 |
34 | The packages _should_ flow to runtime repo via DARC e.g. there should eventually be maestro PR to updated reference.
35 | It is also always possible to update the runtime directly with change similar to https://github.com/dotnet/runtime/pull/57541
36 |
37 | There is currently no process for updating Linux packages.
38 |
39 | **Updating test images**
40 |
41 | On Linux for now we only run tests in cotainers. To pick up change, one need to rebuild appropriate container and update pipeline configuration to point at update image. To rebuild container _without_ submitting changes, one needs to do manual pipeline run (internal) with added `noCache = true` variable.
42 |
43 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/execute-sdl.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | overrideGuardianVersion: ''
3 | executeAllSdlToolsScript: ''
4 | overrideParameters: ''
5 | additionalParameters: ''
6 | publishGuardianDirectoryToPipeline: false
7 | sdlContinueOnError: false
8 | condition: ''
9 |
10 | steps:
11 | - task: NuGetAuthenticate@1
12 | inputs:
13 | nuGetServiceConnections: GuardianConnect
14 |
15 | - task: NuGetToolInstaller@1
16 | displayName: 'Install NuGet.exe'
17 |
18 | - ${{ if ne(parameters.overrideGuardianVersion, '') }}:
19 | - pwsh: |
20 | Set-Location -Path $(Build.SourcesDirectory)\eng\common\sdl
21 | . .\sdl.ps1
22 | $guardianCliLocation = Install-Gdn -Path $(Build.SourcesDirectory)\.artifacts -Version ${{ parameters.overrideGuardianVersion }}
23 | Write-Host "##vso[task.setvariable variable=GuardianCliLocation]$guardianCliLocation"
24 | displayName: Install Guardian (Overridden)
25 |
26 | - ${{ if eq(parameters.overrideGuardianVersion, '') }}:
27 | - pwsh: |
28 | Set-Location -Path $(Build.SourcesDirectory)\eng\common\sdl
29 | . .\sdl.ps1
30 | $guardianCliLocation = Install-Gdn -Path $(Build.SourcesDirectory)\.artifacts
31 | Write-Host "##vso[task.setvariable variable=GuardianCliLocation]$guardianCliLocation"
32 | displayName: Install Guardian
33 |
34 | - ${{ if ne(parameters.overrideParameters, '') }}:
35 | - powershell: ${{ parameters.executeAllSdlToolsScript }} ${{ parameters.overrideParameters }}
36 | displayName: Execute SDL (Overridden)
37 | continueOnError: ${{ parameters.sdlContinueOnError }}
38 | condition: ${{ parameters.condition }}
39 |
40 | - ${{ if eq(parameters.overrideParameters, '') }}:
41 | - powershell: ${{ parameters.executeAllSdlToolsScript }}
42 | -GuardianCliLocation $(GuardianCliLocation)
43 | -NugetPackageDirectory $(Build.SourcesDirectory)\.packages
44 | -AzureDevOpsAccessToken $(dn-bot-dotnet-build-rw-code-rw)
45 | ${{ parameters.additionalParameters }}
46 | displayName: Execute SDL
47 | continueOnError: ${{ parameters.sdlContinueOnError }}
48 | condition: ${{ parameters.condition }}
49 |
50 | - ${{ if ne(parameters.publishGuardianDirectoryToPipeline, 'false') }}:
51 | # We want to publish the Guardian results and configuration for easy diagnosis. However, the
52 | # '.gdn' dir is a mix of configuration, results, extracted dependencies, and Guardian default
53 | # tooling files. Some of these files are large and aren't useful during an investigation, so
54 | # exclude them by simply deleting them before publishing. (As of writing, there is no documented
55 | # way to selectively exclude a dir from the pipeline artifact publish task.)
56 | - task: DeleteFiles@1
57 | displayName: Delete Guardian dependencies to avoid uploading
58 | inputs:
59 | SourceFolder: $(Agent.BuildDirectory)/.gdn
60 | Contents: |
61 | c
62 | i
63 | condition: succeededOrFailed()
64 |
65 | - publish: $(Agent.BuildDirectory)/.gdn
66 | artifact: GuardianConfiguration
67 | displayName: Publish GuardianConfiguration
68 | condition: succeededOrFailed()
69 |
70 | # Publish the SARIF files in a container named CodeAnalysisLogs to enable integration
71 | # with the "SARIF SAST Scans Tab" Azure DevOps extension
72 | - task: CopyFiles@2
73 | displayName: Copy SARIF files
74 | inputs:
75 | flattenFolders: true
76 | sourceFolder: $(Agent.BuildDirectory)/.gdn/rc/
77 | contents: '**/*.sarif'
78 | targetFolder: $(Build.SourcesDirectory)/CodeAnalysisLogs
79 | condition: succeededOrFailed()
80 |
81 | # Use PublishBuildArtifacts because the SARIF extension only checks this case
82 | # see microsoft/sarif-azuredevops-extension#4
83 | - task: PublishBuildArtifacts@1
84 | displayName: Publish SARIF files to CodeAnalysisLogs container
85 | inputs:
86 | pathToPublish: $(Build.SourcesDirectory)/CodeAnalysisLogs
87 | artifactName: CodeAnalysisLogs
88 | condition: succeededOrFailed()
--------------------------------------------------------------------------------
/eng/common/post-build/post-build-utils.ps1:
--------------------------------------------------------------------------------
1 | # Most of the functions in this file require the variables `MaestroApiEndPoint`,
2 | # `MaestroApiVersion` and `MaestroApiAccessToken` to be globally available.
3 |
4 | $ErrorActionPreference = 'Stop'
5 | Set-StrictMode -Version 2.0
6 |
7 | # `tools.ps1` checks $ci to perform some actions. Since the post-build
8 | # scripts don't necessarily execute in the same agent that run the
9 | # build.ps1/sh script this variable isn't automatically set.
10 | $ci = $true
11 | $disableConfigureToolsetImport = $true
12 | . $PSScriptRoot\..\tools.ps1
13 |
14 | function Create-MaestroApiRequestHeaders([string]$ContentType = 'application/json') {
15 | Validate-MaestroVars
16 |
17 | $headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
18 | $headers.Add('Accept', $ContentType)
19 | $headers.Add('Authorization',"Bearer $MaestroApiAccessToken")
20 | return $headers
21 | }
22 |
23 | function Get-MaestroChannel([int]$ChannelId) {
24 | Validate-MaestroVars
25 |
26 | $apiHeaders = Create-MaestroApiRequestHeaders
27 | $apiEndpoint = "$MaestroApiEndPoint/api/channels/${ChannelId}?api-version=$MaestroApiVersion"
28 |
29 | $result = try { Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
30 | return $result
31 | }
32 |
33 | function Get-MaestroBuild([int]$BuildId) {
34 | Validate-MaestroVars
35 |
36 | $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
37 | $apiEndpoint = "$MaestroApiEndPoint/api/builds/${BuildId}?api-version=$MaestroApiVersion"
38 |
39 | $result = try { return Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
40 | return $result
41 | }
42 |
43 | function Get-MaestroSubscriptions([string]$SourceRepository, [int]$ChannelId) {
44 | Validate-MaestroVars
45 |
46 | $SourceRepository = [System.Web.HttpUtility]::UrlEncode($SourceRepository)
47 | $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
48 | $apiEndpoint = "$MaestroApiEndPoint/api/subscriptions?sourceRepository=$SourceRepository&channelId=$ChannelId&api-version=$MaestroApiVersion"
49 |
50 | $result = try { Invoke-WebRequest -Method Get -Uri $apiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
51 | return $result
52 | }
53 |
54 | function Assign-BuildToChannel([int]$BuildId, [int]$ChannelId) {
55 | Validate-MaestroVars
56 |
57 | $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
58 | $apiEndpoint = "$MaestroApiEndPoint/api/channels/${ChannelId}/builds/${BuildId}?api-version=$MaestroApiVersion"
59 | Invoke-WebRequest -Method Post -Uri $apiEndpoint -Headers $apiHeaders | Out-Null
60 | }
61 |
62 | function Trigger-Subscription([string]$SubscriptionId) {
63 | Validate-MaestroVars
64 |
65 | $apiHeaders = Create-MaestroApiRequestHeaders -AuthToken $MaestroApiAccessToken
66 | $apiEndpoint = "$MaestroApiEndPoint/api/subscriptions/$SubscriptionId/trigger?api-version=$MaestroApiVersion"
67 | Invoke-WebRequest -Uri $apiEndpoint -Headers $apiHeaders -Method Post | Out-Null
68 | }
69 |
70 | function Validate-MaestroVars {
71 | try {
72 | Get-Variable MaestroApiEndPoint | Out-Null
73 | Get-Variable MaestroApiVersion | Out-Null
74 | Get-Variable MaestroApiAccessToken | Out-Null
75 |
76 | if (!($MaestroApiEndPoint -Match '^http[s]?://maestro-(int|prod).westus2.cloudapp.azure.com$')) {
77 | Write-PipelineTelemetryError -Category 'MaestroVars' -Message "MaestroApiEndPoint is not a valid Maestro URL. '$MaestroApiEndPoint'"
78 | ExitWithExitCode 1
79 | }
80 |
81 | if (!($MaestroApiVersion -Match '^[0-9]{4}-[0-9]{2}-[0-9]{2}$')) {
82 | Write-PipelineTelemetryError -Category 'MaestroVars' -Message "MaestroApiVersion does not match a version string in the format yyyy-MM-DD. '$MaestroApiVersion'"
83 | ExitWithExitCode 1
84 | }
85 | }
86 | catch {
87 | Write-PipelineTelemetryError -Category 'MaestroVars' -Message 'Error: Variables `MaestroApiEndPoint`, `MaestroApiVersion` and `MaestroApiAccessToken` are required while using this script.'
88 | Write-Host $_
89 | ExitWithExitCode 1
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/eng/common/templates/steps/telemetry-end.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | maxRetries: 5
3 | retryDelay: 10 # in seconds
4 |
5 | steps:
6 | - bash: |
7 | if [ "$AGENT_JOBSTATUS" = "Succeeded" ] || [ "$AGENT_JOBSTATUS" = "PartiallySucceeded" ]; then
8 | errorCount=0
9 | else
10 | errorCount=1
11 | fi
12 | warningCount=0
13 |
14 | curlStatus=1
15 | retryCount=0
16 | # retry loop to harden against spotty telemetry connections
17 | # we don't retry successes and 4xx client errors
18 | until [[ $curlStatus -eq 0 || ( $curlStatus -ge 400 && $curlStatus -le 499 ) || $retryCount -ge $MaxRetries ]]
19 | do
20 | if [ $retryCount -gt 0 ]; then
21 | echo "Failed to send telemetry to Helix; waiting $RetryDelay seconds before retrying..."
22 | sleep $RetryDelay
23 | fi
24 |
25 | # create a temporary file for curl output
26 | res=`mktemp`
27 |
28 | curlResult=`
29 | curl --verbose --output $res --write-out "%{http_code}"\
30 | -H 'Content-Type: application/json' \
31 | -H "X-Helix-Job-Token: $Helix_JobToken" \
32 | -H 'Content-Length: 0' \
33 | -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$Helix_WorkItemId/finish" \
34 | --data-urlencode "errorCount=$errorCount" \
35 | --data-urlencode "warningCount=$warningCount"`
36 | curlStatus=$?
37 |
38 | if [ $curlStatus -eq 0 ]; then
39 | if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then
40 | curlStatus=$curlResult
41 | fi
42 | fi
43 |
44 | let retryCount++
45 | done
46 |
47 | if [ $curlStatus -ne 0 ]; then
48 | echo "Failed to Send Build Finish information after $retryCount retries"
49 | vstsLogOutput="vso[task.logissue type=error;sourcepath=templates/steps/telemetry-end.yml;code=1;]Failed to Send Build Finish information: $curlStatus"
50 | echo "##$vstsLogOutput"
51 | exit 1
52 | fi
53 | displayName: Send Unix Build End Telemetry
54 | env:
55 | # defined via VSTS variables in start-job.sh
56 | Helix_JobToken: $(Helix_JobToken)
57 | Helix_WorkItemId: $(Helix_WorkItemId)
58 | MaxRetries: ${{ parameters.maxRetries }}
59 | RetryDelay: ${{ parameters.retryDelay }}
60 | condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT'))
61 | - powershell: |
62 | if (($env:Agent_JobStatus -eq 'Succeeded') -or ($env:Agent_JobStatus -eq 'PartiallySucceeded')) {
63 | $ErrorCount = 0
64 | } else {
65 | $ErrorCount = 1
66 | }
67 | $WarningCount = 0
68 |
69 | # Basic retry loop to harden against server flakiness
70 | $retryCount = 0
71 | while ($retryCount -lt $env:MaxRetries) {
72 | try {
73 | Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$env:Helix_WorkItemId/finish?errorCount=$ErrorCount&warningCount=$WarningCount" -Method Post -ContentType "application/json" -Body "" `
74 | -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken }
75 | break
76 | }
77 | catch {
78 | $statusCode = $_.Exception.Response.StatusCode.value__
79 | if ($statusCode -ge 400 -and $statusCode -le 499) {
80 | Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix (status code $statusCode); not retrying (4xx client error)"
81 | Write-Host "##vso[task.logissue]error ", $_.Exception.GetType().FullName, $_.Exception.Message
82 | exit 1
83 | }
84 | Write-Host "Failed to send telemetry to Helix (status code $statusCode); waiting $env:RetryDelay seconds before retrying..."
85 | $retryCount++
86 | sleep $env:RetryDelay
87 | continue
88 | }
89 | }
90 |
91 | if ($retryCount -ge $env:MaxRetries) {
92 | Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix after $retryCount retries."
93 | exit 1
94 | }
95 | displayName: Send Windows Build End Telemetry
96 | env:
97 | # defined via VSTS variables in start-job.ps1
98 | Helix_JobToken: $(Helix_JobToken)
99 | Helix_WorkItemId: $(Helix_WorkItemId)
100 | MaxRetries: ${{ parameters.maxRetries }}
101 | RetryDelay: ${{ parameters.retryDelay }}
102 | condition: and(always(),eq(variables['Agent.Os'], 'Windows_NT'))
103 |
--------------------------------------------------------------------------------
/src/xdp/include/xdpapi.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | //
5 |
6 | #ifndef XDPAPI_H
7 | #define XDPAPI_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | #include
14 | #include
15 | #include
16 |
17 | #ifndef XDPAPI
18 | #define XDPAPI __declspec(dllimport)
19 | #endif
20 |
21 | typedef enum _XDP_CREATE_PROGRAM_FLAGS {
22 | XDP_CREATE_PROGRAM_FLAG_NONE = 0x0,
23 | XDP_CREATE_PROGRAM_FLAG_GENERIC = 0x1,
24 | XDP_CREATE_PROGRAM_FLAG_NATIVE = 0x2,
25 | XDP_CREATE_PROGRAM_FLAG_ALL_QUEUES = 0x4,
26 | } XDP_CREATE_PROGRAM_FLAGS;
27 |
28 | DEFINE_ENUM_FLAG_OPERATORS(XDP_CREATE_PROGRAM_FLAGS);
29 | C_ASSERT(sizeof(XDP_CREATE_PROGRAM_FLAGS) == sizeof(UINT32));
30 |
31 | typedef
32 | HRESULT
33 | XDP_CREATE_PROGRAM_FN(
34 | _In_ UINT32 InterfaceIndex,
35 | _In_ CONST XDP_HOOK_ID *HookId,
36 | _In_ UINT32 QueueId,
37 | _In_ XDP_CREATE_PROGRAM_FLAGS Flags,
38 | _In_reads_(RuleCount) CONST XDP_RULE *Rules,
39 | _In_ UINT32 RuleCount,
40 | _Out_ HANDLE *Program
41 | );
42 |
43 | typedef
44 | HRESULT
45 | XDP_INTERFACE_OPEN_FN(
46 | _In_ UINT32 InterfaceIndex,
47 | _Out_ HANDLE *InterfaceHandle
48 | );
49 |
50 | #include "afxdp.h"
51 |
52 | typedef struct _XDP_API_TABLE XDP_API_TABLE;
53 |
54 | //
55 | // The only API version currently supported. Any change to the API is considered
56 | // a breaking change and support for previous versions will be removed.
57 | //
58 | #define XDP_API_VERSION_1 1
59 |
60 | typedef
61 | HRESULT
62 | XDP_OPEN_API_FN(
63 | _In_ UINT32 XdpApiVersion,
64 | _Out_ CONST XDP_API_TABLE **XdpApiTable
65 | );
66 |
67 | XDPAPI XDP_OPEN_API_FN XdpOpenApi;
68 |
69 | typedef
70 | VOID
71 | XDP_CLOSE_API_FN(
72 | _In_ CONST XDP_API_TABLE *XdpApiTable
73 | );
74 |
75 | XDPAPI XDP_CLOSE_API_FN XdpCloseApi;
76 |
77 | typedef
78 | VOID *
79 | XDP_GET_ROUTINE_FN(
80 | _In_z_ const CHAR *RoutineName
81 | );
82 |
83 | typedef struct _XDP_API_TABLE {
84 | XDP_OPEN_API_FN *XdpOpenApi;
85 | XDP_CLOSE_API_FN *XdpCloseApi;
86 | XDP_GET_ROUTINE_FN *XdpGetRoutine;
87 | XDP_CREATE_PROGRAM_FN *XdpCreateProgram;
88 | XDP_INTERFACE_OPEN_FN *XdpInterfaceOpen;
89 | XSK_CREATE_FN *XskCreate;
90 | XSK_BIND_FN *XskBind;
91 | XSK_ACTIVATE_FN *XskActivate;
92 | XSK_NOTIFY_SOCKET_FN *XskNotifySocket;
93 | XSK_NOTIFY_ASYNC_FN *XskNotifyAsync;
94 | XSK_GET_NOTIFY_ASYNC_RESULT_FN *XskGetNotifyAsyncResult;
95 | XSK_SET_SOCKOPT_FN *XskSetSockopt;
96 | XSK_GET_SOCKOPT_FN *XskGetSockopt;
97 | XSK_IOCTL_FN *XskIoctl;
98 | } XDP_API_TABLE;
99 |
100 | typedef struct _XDP_LOAD_CONTEXT *XDP_LOAD_API_CONTEXT;
101 |
102 | #if !defined(_KERNEL_MODE)
103 |
104 | inline
105 | HRESULT
106 | XdpLoadApi(
107 | _In_ UINT32 XdpApiVersion,
108 | _Out_ XDP_LOAD_API_CONTEXT *XdpLoadApiContext,
109 | _Out_ CONST XDP_API_TABLE **XdpApiTable
110 | )
111 | {
112 | HRESULT Result;
113 | HMODULE XdpHandle;
114 | XDP_OPEN_API_FN *OpenApi;
115 |
116 | *XdpLoadApiContext = NULL;
117 | *XdpApiTable = NULL;
118 |
119 | XdpHandle = LoadLibraryA("xdpapi.dll");
120 | if (XdpHandle == NULL) {
121 | Result = E_NOINTERFACE;
122 | goto Exit;
123 | }
124 |
125 | OpenApi = (XDP_OPEN_API_FN *)GetProcAddress(XdpHandle, "XdpOpenApi");
126 | if (OpenApi == NULL) {
127 | Result = E_NOINTERFACE;
128 | goto Exit;
129 | }
130 |
131 | Result = OpenApi(XdpApiVersion, XdpApiTable);
132 |
133 | Exit:
134 |
135 | if (SUCCEEDED(Result)) {
136 | *XdpLoadApiContext = (XDP_LOAD_API_CONTEXT)XdpHandle;
137 | } else {
138 | if (XdpHandle != NULL) {
139 | FreeLibrary(XdpHandle);
140 | }
141 | }
142 |
143 | return Result;
144 | }
145 |
146 | inline
147 | VOID
148 | XdpUnloadApi(
149 | _In_ XDP_LOAD_API_CONTEXT XdpLoadApiContext,
150 | _In_ CONST XDP_API_TABLE *XdpApiTable
151 | )
152 | {
153 | HMODULE XdpHandle = (HMODULE)XdpLoadApiContext;
154 |
155 | XdpApiTable->XdpCloseApi(XdpApiTable);
156 |
157 | FreeLibrary(XdpHandle);
158 | }
159 |
160 | #endif // !defined(_KERNEL_MODE)
161 |
162 | #ifdef __cplusplus
163 | } // extern "C"
164 | #endif
165 |
166 | #endif
167 |
--------------------------------------------------------------------------------
/eng/common/templates/job/onelocbuild.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # Optional: dependencies of the job
3 | dependsOn: ''
4 |
5 | # Optional: A defined YAML pool - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#pool
6 | pool: ''
7 |
8 | CeapexPat: $(dn-bot-ceapex-package-r) # PAT for the loc AzDO instance https://dev.azure.com/ceapex
9 | GithubPat: $(BotAccount-dotnet-bot-repo-PAT)
10 |
11 | SourcesDirectory: $(Build.SourcesDirectory)
12 | CreatePr: true
13 | AutoCompletePr: false
14 | ReusePr: true
15 | UseLfLineEndings: true
16 | UseCheckedInLocProjectJson: false
17 | SkipLocProjectJsonGeneration: false
18 | LanguageSet: VS_Main_Languages
19 | LclSource: lclFilesInRepo
20 | LclPackageId: ''
21 | RepoType: gitHub
22 | GitHubOrg: dotnet
23 | MirrorRepo: ''
24 | MirrorBranch: main
25 | condition: ''
26 | JobNameSuffix: ''
27 |
28 | jobs:
29 | - job: OneLocBuild${{ parameters.JobNameSuffix }}
30 |
31 | dependsOn: ${{ parameters.dependsOn }}
32 |
33 | displayName: OneLocBuild${{ parameters.JobNameSuffix }}
34 |
35 | variables:
36 | - group: OneLocBuildVariables # Contains the CeapexPat and GithubPat
37 | - name: _GenerateLocProjectArguments
38 | value: -SourcesDirectory ${{ parameters.SourcesDirectory }}
39 | -LanguageSet "${{ parameters.LanguageSet }}"
40 | -CreateNeutralXlfs
41 | - ${{ if eq(parameters.UseCheckedInLocProjectJson, 'true') }}:
42 | - name: _GenerateLocProjectArguments
43 | value: ${{ variables._GenerateLocProjectArguments }} -UseCheckedInLocProjectJson
44 | - template: /eng/common/templates/variables/pool-providers.yml
45 |
46 | ${{ if ne(parameters.pool, '') }}:
47 | pool: ${{ parameters.pool }}
48 | ${{ if eq(parameters.pool, '') }}:
49 | pool:
50 | # We don't use the collection uri here because it might vary (.visualstudio.com vs. dev.azure.com)
51 | ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
52 | name: VSEngSS-MicroBuild2022-1ES
53 | demands: Cmd
54 | # If it's not devdiv, it's dnceng
55 | ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}:
56 | name: $(DncEngInternalBuildPool)
57 | demands: ImageOverride -equals windows.vs2019.amd64
58 |
59 | steps:
60 | - ${{ if ne(parameters.SkipLocProjectJsonGeneration, 'true') }}:
61 | - task: Powershell@2
62 | inputs:
63 | filePath: $(Build.SourcesDirectory)/eng/common/generate-locproject.ps1
64 | arguments: $(_GenerateLocProjectArguments)
65 | displayName: Generate LocProject.json
66 | condition: ${{ parameters.condition }}
67 |
68 | - task: OneLocBuild@2
69 | displayName: OneLocBuild
70 | env:
71 | SYSTEM_ACCESSTOKEN: $(System.AccessToken)
72 | inputs:
73 | locProj: eng/Localize/LocProject.json
74 | outDir: $(Build.ArtifactStagingDirectory)
75 | lclSource: ${{ parameters.LclSource }}
76 | lclPackageId: ${{ parameters.LclPackageId }}
77 | isCreatePrSelected: ${{ parameters.CreatePr }}
78 | isAutoCompletePrSelected: ${{ parameters.AutoCompletePr }}
79 | ${{ if eq(parameters.CreatePr, true) }}:
80 | isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }}
81 | ${{ if eq(parameters.RepoType, 'gitHub') }}:
82 | isShouldReusePrSelected: ${{ parameters.ReusePr }}
83 | packageSourceAuth: patAuth
84 | patVariable: ${{ parameters.CeapexPat }}
85 | ${{ if eq(parameters.RepoType, 'gitHub') }}:
86 | repoType: ${{ parameters.RepoType }}
87 | gitHubPatVariable: "${{ parameters.GithubPat }}"
88 | ${{ if ne(parameters.MirrorRepo, '') }}:
89 | isMirrorRepoSelected: true
90 | gitHubOrganization: ${{ parameters.GitHubOrg }}
91 | mirrorRepo: ${{ parameters.MirrorRepo }}
92 | mirrorBranch: ${{ parameters.MirrorBranch }}
93 | condition: ${{ parameters.condition }}
94 |
95 | - task: PublishBuildArtifacts@1
96 | displayName: Publish Localization Files
97 | inputs:
98 | PathtoPublish: '$(Build.ArtifactStagingDirectory)/loc'
99 | PublishLocation: Container
100 | ArtifactName: Loc
101 | condition: ${{ parameters.condition }}
102 |
103 | - task: PublishBuildArtifacts@1
104 | displayName: Publish LocProject.json
105 | inputs:
106 | PathtoPublish: '$(Build.SourcesDirectory)/eng/Localize/'
107 | PublishLocation: Container
108 | ArtifactName: Loc
109 | condition: ${{ parameters.condition }}
--------------------------------------------------------------------------------
/eng/common/templates/jobs/jobs.yml:
--------------------------------------------------------------------------------
1 | parameters:
2 | # See schema documentation in /Documentation/AzureDevOps/TemplateSchema.md
3 | continueOnError: false
4 |
5 | # Optional: Include PublishBuildArtifacts task
6 | enablePublishBuildArtifacts: false
7 |
8 | # Optional: Enable publishing using release pipelines
9 | enablePublishUsingPipelines: false
10 |
11 | # Optional: Enable running the source-build jobs to build repo from source
12 | enableSourceBuild: false
13 |
14 | # Optional: Parameters for source-build template.
15 | # See /eng/common/templates/jobs/source-build.yml for options
16 | sourceBuildParameters: []
17 |
18 | graphFileGeneration:
19 | # Optional: Enable generating the graph files at the end of the build
20 | enabled: false
21 | # Optional: Include toolset dependencies in the generated graph files
22 | includeToolset: false
23 |
24 | # Required: A collection of jobs to run - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job
25 | jobs: []
26 |
27 | # Optional: Override automatically derived dependsOn value for "publish build assets" job
28 | publishBuildAssetsDependsOn: ''
29 |
30 | # Optional: Publish the assets as soon as the publish to BAR stage is complete, rather doing so in a separate stage.
31 | publishAssetsImmediately: false
32 |
33 | # Optional: If using publishAssetsImmediately and additional parameters are needed, can be used to send along additional parameters (normally sent to post-build.yml)
34 | artifactsPublishingAdditionalParameters: ''
35 | signingValidationAdditionalParameters: ''
36 |
37 | # Optional: should run as a public build even in the internal project
38 | # if 'true', the build won't run any of the internal only steps, even if it is running in non-public projects.
39 | runAsPublic: false
40 |
41 | enableSourceIndex: false
42 | sourceIndexParams: {}
43 |
44 | # Internal resources (telemetry, microbuild) can only be accessed from non-public projects,
45 | # and some (Microbuild) should only be applied to non-PR cases for internal builds.
46 |
47 | jobs:
48 | - ${{ each job in parameters.jobs }}:
49 | - template: ../job/job.yml
50 | parameters:
51 | # pass along parameters
52 | ${{ each parameter in parameters }}:
53 | ${{ if ne(parameter.key, 'jobs') }}:
54 | ${{ parameter.key }}: ${{ parameter.value }}
55 |
56 | # pass along job properties
57 | ${{ each property in job }}:
58 | ${{ if ne(property.key, 'job') }}:
59 | ${{ property.key }}: ${{ property.value }}
60 |
61 | name: ${{ job.job }}
62 |
63 | - ${{ if eq(parameters.enableSourceBuild, true) }}:
64 | - template: /eng/common/templates/jobs/source-build.yml
65 | parameters:
66 | allCompletedJobId: Source_Build_Complete
67 | ${{ each parameter in parameters.sourceBuildParameters }}:
68 | ${{ parameter.key }}: ${{ parameter.value }}
69 |
70 | - ${{ if eq(parameters.enableSourceIndex, 'true') }}:
71 | - template: ../job/source-index-stage1.yml
72 | parameters:
73 | runAsPublic: ${{ parameters.runAsPublic }}
74 | ${{ each parameter in parameters.sourceIndexParams }}:
75 | ${{ parameter.key }}: ${{ parameter.value }}
76 |
77 | - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
78 | - ${{ if or(eq(parameters.enablePublishBuildAssets, true), eq(parameters.artifacts.publish.manifests, 'true'), ne(parameters.artifacts.publish.manifests, '')) }}:
79 | - template: ../job/publish-build-assets.yml
80 | parameters:
81 | continueOnError: ${{ parameters.continueOnError }}
82 | dependsOn:
83 | - ${{ if ne(parameters.publishBuildAssetsDependsOn, '') }}:
84 | - ${{ each job in parameters.publishBuildAssetsDependsOn }}:
85 | - ${{ job.job }}
86 | - ${{ if eq(parameters.publishBuildAssetsDependsOn, '') }}:
87 | - ${{ each job in parameters.jobs }}:
88 | - ${{ job.job }}
89 | - ${{ if eq(parameters.enableSourceBuild, true) }}:
90 | - Source_Build_Complete
91 |
92 | runAsPublic: ${{ parameters.runAsPublic }}
93 | publishUsingPipelines: ${{ parameters.enablePublishUsingPipelines }}
94 | publishAssetsImmediately: ${{ parameters.publishAssetsImmediately }}
95 | enablePublishBuildArtifacts: ${{ parameters.enablePublishBuildArtifacts }}
96 | artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }}
97 | signingValidationAdditionalParameters: ${{ parameters.signingValidationAdditionalParameters }}
98 |
--------------------------------------------------------------------------------