Skip to content

Commit

Permalink
Build XskFwd sample for kernel and user mode (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfriesen authored Nov 12, 2024
1 parent db27316 commit 1746795
Show file tree
Hide file tree
Showing 17 changed files with 499 additions and 112 deletions.
55 changes: 54 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,59 @@ jobs:
shell: PowerShell
run: tools/check-drivers.ps1 -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Verbose

xskfwdkm_test:
name: XskFwdKm Test
needs: build
strategy:
fail-fast: false
matrix:
windows: [2019, 2022, Prerelease]
configuration: [Release, Debug]
platform: [x64, arm64]
exclude:
- windows: 2019
platform: arm64
- windows: 2022
platform: arm64
runs-on:
- self-hosted
- "1ES.Pool=xdp-ci-functional${{ matrix.platform != 'x64' && format('-{0}', matrix.platform) || '' }}-gh"
- "1ES.ImageOverride=WS${{ matrix.windows }}${{ matrix.platform != 'x64' && format('-{0}', matrix.platform) || '' }}-Functional"
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
sparse-checkout: tools
- name: Check Drivers
shell: PowerShell
run: tools/check-drivers.ps1 -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Verbose
- name: Prepare Machine
shell: PowerShell
run: tools/prepare-machine.ps1 -Platform ${{ matrix.platform }} -ForFunctionalTest -RequireNoReboot -Verbose
- name: Download Artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: bin_${{ matrix.configuration }}_${{ matrix.platform }}
path: artifacts/bin
- name: Run XskFwdKm
shell: PowerShell
run: tools/xskfwdkm.ps1 -Verbose -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }}
- name: Convert Logs
if: ${{ always() }}
timeout-minutes: 15
shell: PowerShell
run: tools/log.ps1 -Convert -Name xskfwdkm -Verbose -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }}
- name: Upload Logs
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
if: ${{ always() }}
with:
name: logs_xskfwdkm_win${{ matrix.windows }}_${{ matrix.configuration }}_${{ matrix.platform }}
path: artifacts/logs
- name: Check Drivers
if: ${{ always() }}
shell: PowerShell
run: tools/check-drivers.ps1 -Config ${{ matrix.configuration }} -Platform ${{ matrix.platform }} -Verbose

create_artifacts:
name: Create Release Artifacts
needs: build
Expand Down Expand Up @@ -506,7 +559,7 @@ jobs:
Complete:
name: Complete
if: always()
needs: [build, build_allpackage, onebranch_build_validation, functional_tests, stress_tests, pktfuzz_tests, perf_tests, downlevel_functional_tests, create_artifacts, etw]
needs: [build, build_allpackage, onebranch_build_validation, functional_tests, stress_tests, pktfuzz_tests, perf_tests, xskfwdkm_test, downlevel_functional_tests, create_artifacts, etw]
runs-on: ubuntu-latest
permissions: {} # No need for any permissions.
steps:
Expand Down
12 changes: 6 additions & 6 deletions published/external/xdp/details/afxdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ _XskCreateVersion(
_XdpInitializeEaVersion(XDP_OBJECT_TYPE_XSK, ApiVersion, EaBuffer, sizeof(EaBuffer));

Res = _XdpOpen(Socket, FILE_CREATE, EaBuffer, sizeof(EaBuffer));
if (FAILED(Res)) {
if (XDP_FAILED(Res)) {
return Res;
}

//
// Performance optimization: skip setting the file handle upon each IO completion.
//
Res = _XdpSetFileCompletionModes(*Socket, FILE_SKIP_SET_EVENT_ON_HANDLE);
if (FAILED(Res)) {
if (XDP_FAILED(Res)) {
_XdpCloseHandle(*Socket);
}

Expand Down Expand Up @@ -198,7 +198,7 @@ XskGetSockopt(
&BytesReturned,
NULL,
FALSE);
if (FAILED(Res)) {
if (XDP_FAILED(Res)) {
return Res;
}

Expand Down Expand Up @@ -263,7 +263,7 @@ XskNotifySocket(
&BytesReturned,
NULL,
FALSE);
if (FAILED(Res)) {
if (XDP_FAILED(Res)) {
return Res;
}

Expand Down Expand Up @@ -311,8 +311,8 @@ XskGetNotifyAsyncResult(
if (!NT_SUCCESS(Iosb->Status)) {
XDP_STATUS Status;
Status = _XdpConvertNtStatusToXdpStatus(Iosb->Status);
XDPAPI_ASSERT(FAILED(Status));
_Analysis_assume_(FAILED(Status));
XDPAPI_ASSERT(XDP_FAILED(Status));
_Analysis_assume_(XDP_FAILED(Status));
return Status;
}

Expand Down
10 changes: 8 additions & 2 deletions published/external/xdp/details/ioctlfn.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,19 @@ _XdpOpen(
UNICODE_STRING DeviceName;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
#ifdef _KERNEL_MODE
#define _XDP_OPEN_KERNEL_OBJ_FLAGS OBJ_KERNEL_HANDLE
#else
#define _XDP_OPEN_KERNEL_OBJ_FLAGS 0
#endif

//
// Open a handle to the XDP device.
//
RtlInitUnicodeString(&DeviceName, XDP_DEVICE_NAME);
InitializeObjectAttributes(
&ObjectAttributes, &DeviceName, OBJ_CASE_INSENSITIVE, NULL, NULL);
&ObjectAttributes, &DeviceName, OBJ_CASE_INSENSITIVE | _XDP_OPEN_KERNEL_OBJ_FLAGS,
NULL, NULL);

return
_XdpConvertNtStatusToXdpStatus(
Expand Down Expand Up @@ -243,7 +249,7 @@ _XdpIoctl(

if (Event == &LocalEvent && XdpStatus == XDP_STATUS_PENDING) {
XdpStatus = _XdpWaitInfinite(Event);
if (FAILED(XdpStatus)) {
if (XDP_FAILED(XdpStatus)) {
goto Exit;
}

Expand Down
5 changes: 4 additions & 1 deletion published/external/xdp/wincommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ extern "C" {

#ifdef _KERNEL_MODE

#include <wdm.h>
#include <ntdef.h>
#include <ntstatus.h>
#include <ntifs.h>
#include <ntintsafe.h>

#else

Expand Down
Loading

0 comments on commit 1746795

Please sign in to comment.