Skip to content

Commit

Permalink
Wip - Add delay in workitem
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhiren Vispute authored and Dhiren Vispute committed Feb 29, 2024
1 parent e611b8a commit a407a4e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 210 deletions.
217 changes: 7 additions & 210 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,168 +68,26 @@ jobs:
build_nuget: true
configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]'

# Run the unit tests in GitHub.
unit_tests_appverif:
# Always run this job.
needs: regular
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
name: unit_tests
pre_test: appverif -enable Exceptions Handles Heaps Leak Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe
# Exclude [processes] test that CodeCoverage can't work with.
test_command: .\unit_tests.exe -d yes ~[processes]
build_artifact: Build-x64
environment: windows-2022
code_coverage: true
gather_dumps: true
capture_etw: true
leak_detection: true

# Run the unit tests in GitHub.
unit_tests:
# Always run this job.
needs: regular
if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group'
uses: ./.github/workflows/reusable-test.yml
with:
name: unit_tests
pre_test: appverif -enable Exceptions Handles Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe
# Exclude [processes] test that CodeCoverage can't work with.
test_command: .\unit_tests.exe -d yes ~[processes]
build_artifact: Build-x64
environment: windows-2022
code_coverage: true
gather_dumps: true
capture_etw: true
leak_detection: true

# Run the netebpfext unit tests in GitHub.
netebpf_ext_unit_tests:
# Always run this job.
needs: regular
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
name: netebpf_ext_unit_tests
pre_test: appverif -enable Exceptions Handles Heaps Leak Locks Memory SRWLock Threadpool TLS DangerousAPIs DirtyStacks TimeRollOver -for unit_tests.exe
test_command: .\netebpfext_unit.exe -d yes
build_artifact: Build-x64
environment: windows-2022
code_coverage: true
gather_dumps: true
capture_etw: true
leak_detection: true

# Run the bpf2c tests in GitHub.
bpf2c:
# Always run this job.
needs: regular
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
test_command: .\bpf2c_tests.exe -d yes
name: bpf2c
build_artifact: Build-x64
environment: windows-2022
vs_dev: true
code_coverage: true
gather_dumps: true
capture_etw: true

# Run the bpf2c conformance tests in GitHub.
bpf2c_conformance:
# Always run this job.
# Run multi-threaded stress tests with 'restart extension' enabled
# against the kernel mode eBPF sub-system.
aaa_km_mt_stress_tests_restart_extension:
needs: regular
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
pre_test: Invoke-WebRequest https://github.com/Alan-Jowett/bpf_conformance/releases/download/v0.0.5/bpf_conformance_runner.exe -OutFile bpf_conformance_runner.exe
test_command: .\bpf_conformance_runner.exe --test_file_directory %SOURCE_ROOT%\external\ebpf-verifier\external\bpf_conformance\tests --cpu_version v4 --exclude_regex local --plugin_path bpf2c_plugin.exe --debug true --plugin_options "--include %SOURCE_ROOT%\include"
name: bpf2c_conformance
build_artifact: Build-x64
environment: windows-2022
vs_dev: true
code_coverage: true
gather_dumps: true
capture_etw: true

# Run the driver tests on self-hosted runners.
driver_ws2019:
# Always run this job.
# Only run this on repos that have self-host runners.
needs: regular
if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch')
uses: ./.github/workflows/reusable-test.yml
with:
pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file"
test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD"
name: aaa_km_mt_stress_tests_restart_extension
pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "memory"
test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "Stress" -Options @("RestartExtension")
post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true
name: driver_ws2019
build_artifact: Build-x64
environment: ebpf_cicd_tests_ws2019
# driver test copies dumps to testlog folder.
gather_dumps: false
# driver tests manually gather code coverage
code_coverage: false

# Run the driver tests on self-hosted runners.
driver_ws2022:
# Always run this job.
# Only run this on repos that have self-host runners.
needs: regular
if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch')
uses: ./.github/workflows/reusable-test.yml
with:
pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file"
test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD"
post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true
name: driver_ws2022
build_artifact: Build-x64
environment: ebpf_cicd_tests_ws2022
# driver test copies dumps to testlog folder.
# For this test, we only want kernel mode dumps and not user mode dumps.
gather_dumps: false
# driver tests manually gather code coverage
code_coverage: false

# Run the native-only driver tests on self-hosted runners.
driver_native_only_ws2019:
# Always run this job.
# Only run this on repos that have self-host runners.
needs: regular_native-only
if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch')
uses: ./.github/workflows/reusable-test.yml
with:
pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file"
test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD"
post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true
name: driver_native_only_ws2019
build_artifact: Build-x64-native-only
environment: ebpf_cicd_tests_ws2019
# driver test copies dumps to testlog folder.
gather_dumps: false
# driver tests manually gather code coverage
code_coverage: false
configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]'

driver_native_only_ws2022:
# Always run this job.
# Only run this on repos that have self-host runners.
needs: regular_native-only
if: github.repository == 'microsoft/ebpf-for-windows' && (github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch')
uses: ./.github/workflows/reusable-test.yml
with:
pre_test: .\setup_ebpf_cicd_tests.ps1 -KmTracing $true -KmTraceType "file"
test_command: .\execute_ebpf_cicd_tests.ps1 -TestMode "CI/CD"
post_test: .\cleanup_ebpf_cicd_tests.ps1 -KmTracing $true
name: driver_native_only_ws2022
build_artifact: Build-x64-native-only
environment: ebpf_cicd_tests_ws2022
# driver test copies dumps to testlog folder.
gather_dumps: false
# driver tests manually gather code coverage
code_coverage: false
configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]'

ossar:
# Always run this job.
Expand Down Expand Up @@ -359,51 +217,6 @@ jobs:
gather_dumps: true
configurations: '["FuzzerDebug"]'

# Run Cilium regression tests in GitHub.
cilium_tests:
needs: regular
# Only run on schedule and pull request.
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
name: cilium_tests
test_command: .\cilium_tests.exe -d yes
build_artifact: Build-x64
environment: windows-2022
code_coverage: false
gather_dumps: true

# Run the quick stress tests in GitHub.
stress:
needs: regular
# Only run on schedule and pull request.
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
name: stress
# Until there is a dedicated stress test, re-use the perf test.
test_command: .\ebpf_performance.exe -d yes
build_artifact: Build-x64
environment: windows-2022
# No code coverage on stress.
code_coverage: false
gather_dumps: true

# Run the unit tests in GitHub with address sanitizer.
sanitize_unit_tests:
needs: sanitize
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-test.yml
with:
name: unit_tests
# Exclude [processes] test that ASAN can't work with.
test_command: .\unit_tests.exe -d yes ~[processes]
build_artifact: Build-x64-Sanitize
environment: windows-2022
code_coverage: false
gather_dumps: true
capture_etw: true

# Run the fault injection simulator in GitHub.
fault_injection:
needs: regular
Expand Down Expand Up @@ -434,22 +247,6 @@ jobs:
fault_injection: true
leak_detection: true

# Run a fast multi-threaded stress test pass against the usersim user-mode 'mock' framework.
# Added as a 'per-PR' test to catch usersim regressions and/or run-time usage issues.
quick_user_mode_multi_threaded_stress_test:
needs: regular
if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group'
uses: ./.github/workflows/reusable-test.yml
with:
name: quick_user_mode_multi_threaded_stress
test_command: .\ebpf_stress_tests_um -tt=8 -td=2
build_artifact: Build-x64
environment: windows-2022
code_coverage: false
leak_detection: false
gather_dumps: true
capture_etw: true

# Additional jobs to run on a schedule only (skip push and pull request).
# ---------------------------------------------------------------------------
codeql:
Expand Down
18 changes: 18 additions & 0 deletions netebpfext/net_ebpf_ext_hook_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,29 @@ IO_WORKITEM_ROUTINE _net_ebpf_extension_detach_client_completion;
#pragma alloc_text(PAGE, _net_ebpf_extension_detach_client_completion)
#endif

void
dv_delay(int64_t period_in_100ns_units)
{
LARGE_INTEGER delay;
NTSTATUS status;
KEVENT local_event;

delay.QuadPart = period_in_100ns_units;
KeInitializeEvent(&local_event, SynchronizationEvent, FALSE);
status = KeWaitForSingleObject(&local_event, Executive, KernelMode, FALSE, &delay);
if (!NT_SUCCESS(status)) {
__fastfail(FAST_FAIL_INVALID_ARG);
}
}

/**
* @brief IO work item routine callback that waits on client rundown to complete.
*
* @param[in] device_object IO Device object.
* @param[in] context Pointer to work item context.
*
*/

void
_net_ebpf_extension_detach_client_completion(_In_ DEVICE_OBJECT* device_object, _In_opt_ void* context)
{
Expand All @@ -147,6 +163,8 @@ _net_ebpf_extension_detach_client_completion(_In_ DEVICE_OBJECT* device_object,

work_item = hook_client->detach_work_item;

dv_delay(-5000000); // sleep for 500 milli-secs (in 100 ns intervals)

// The NMR model is async, but the only Windows run-down protection API available is a blocking API, so the
// following call will block until all using threads are complete. This should be fixed in the future.
// Issue: https://github.com/microsoft/ebpf-for-windows/issues/1854
Expand Down

0 comments on commit a407a4e

Please sign in to comment.