From 1989d26873e0297b7d7e16813b4aac2729b47fa1 Mon Sep 17 00:00:00 2001 From: Alan Jowett Date: Mon, 25 Apr 2022 10:46:22 -0600 Subject: [PATCH] Remove ebpf_verify_program API (#997) * Remove ebpf_verify_program API Signed-off-by: Alan Jowett * Remove old test Signed-off-by: Alan Jowett * Cleanup runners Signed-off-by: Alan Jowett * PR feedback Signed-off-by: Alan Jowett * Cleanup old artifacts Signed-off-by: Alan Jowett Co-authored-by: Alan Jowett --- .github/codecov.yml | 4 +- .github/workflows/cicd.yml | 2 + .github/workflows/reusable-test.yml | 5 + docs/GettingStarted.md | 10 -- ebpf-for-windows.sln | 34 +--- ebpfapi/rpc_client.cpp | 19 --- ebpfsvc/rpc_api.cpp | 30 ---- libs/api/rpc_client.h | 6 - libs/service/api_service.cpp | 41 ----- libs/service/api_service.h | 11 -- rpc_interface/rpc_interface.idl | 6 - scripts/deploy-ebpf.ps1 | 2 - scripts/run_driver_tests.psm1 | 1 - scripts/run_tests.bat | 5 - tests/client/ebpf_client.vcxproj | 194 ----------------------- tests/client/ebpf_client.vcxproj.filters | 43 ----- tests/client/main.cpp | 156 ------------------ tests/client/packages.config | 5 - 18 files changed, 12 insertions(+), 562 deletions(-) delete mode 100644 tests/client/ebpf_client.vcxproj delete mode 100644 tests/client/ebpf_client.vcxproj.filters delete mode 100644 tests/client/main.cpp delete mode 100644 tests/client/packages.config diff --git a/.github/codecov.yml b/.github/codecov.yml index 75e5e55e3..fb3e041a3 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -4,9 +4,9 @@ codecov: notify: wait_for_ci: yes - after_n_builds: 8 # (unit_tests, ebpf_client, fuzzing, bpf2c) * (Debug, Release) + after_n_builds: 6 # (unit_tests, fuzzing, bpf2c) * (Debug, Release) comment: - after_n_builds: 8 # (unit_tests, ebpf_client, fuzzing, bpf2c) * (Debug, Release) + after_n_builds: 6 # (unit_tests, fuzzing, bpf2c) * (Debug, Release) coverage: status: project: diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 810bc04dd..db1961d8b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -118,6 +118,8 @@ jobs: environment: ebpf_cicd_tests # driver test copies dumps to testlog folder. gather_dumps: false + # driver tests manually gather code coverage + code_coverage: false # Run the unit tests in GitHub with address sanitizer. sanitize_unit_tests: diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index ea75f1df1..a6ea5f923 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -107,6 +107,11 @@ jobs: checkName: ${{inputs.build_job}} (${{env.BUILD_CONFIGURATION}}) ref: ${{ github.event.pull_request.head.sha || github.sha }} + - name: Remove existing artifacts + if: inputs.environment == 'ebpf_cicd_tests' + run: | + Remove-Item -Path ${{github.workspace}}\${{env.BUILD_PLATFORM}}\${{env.BUILD_CONFIGURATION}} -Recurse -Force -ErrorAction SilentlyContinue + - name: Download build artifact if: success() uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index c8b57ec19..81e31f045 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -76,8 +76,6 @@ This will build the following binaries: * `ebpfsvc.exe`: A user-mode service that verifies and loads an eBPF program in the execution context. * `unit_tests.exe`: A collection of tests using the Catch framework. These tests are also run as part of the Github CI/CD so should always pass. -* `ebpf_client.exe`: A collection of program verification tests that exercises the RPC channel from client to ebpfsvc. - These tests are also run as part of the Github CI/CD so should always pass. * `api_test.exe`: A collection of tests that exercises eBPF user mode APIs. This requires EbpSvc service to be running, and EbpCore and NetEbpfExt drivers to be loaded. * `sample_ebpf_ext.sys`: A sample eBPF extension driver that implements a test hook (for a test program type) and test helper functions. @@ -176,14 +174,6 @@ components via a Mock IOCTL interface. The tests initialize the user mode and ke mode components, load an eBPF program from an ELF file, and then run the eBPF program by having the mocked extensions emit events. -### ebpf_client.exe -This test does verification for different sample programs by parsing the ELF file and -sending the verification request to ebpfsvc. For the cases when the verification fails, -the test receives and prints the verifier failure message. -If ebpfsvc is not already installed, this test tries to install and start the service before -executing the tests, hence this test should be run as admin if ebpfsvc is not already installed -and running. - ### api_test.exe This test exercises various eBPF user mode eBPF APIs, including those to load programs, enumerate maps and programs etc. This test requires the eBPF user mode service (EbpfSvc), and the diff --git a/ebpf-for-windows.sln b/ebpf-for-windows.sln index 49a50eeb8..0271b586d 100644 --- a/ebpf-for-windows.sln +++ b/ebpf-for-windows.sln @@ -93,8 +93,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ebpfsvc", "ebpfsvc\eBPFSvc. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encode_program_info", "tools\encode_program_info\encode_program_info.vcxproj", "{FA9BB88D-8259-40C1-9422-BDEDF9E9CE68}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ebpf_client", "tests\client\ebpf_client.vcxproj", "{3C195972-46BB-491D-8820-0500FF4BA8B7}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "service", "libs\service\service.vcxproj", "{AF85C549-57CC-40A5-BDFC-DCF1998DE80F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "idl", "idl", "{7978FF80-0017-4BD7-A91D-3B113F1F9F9E}" @@ -126,6 +124,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yaml-cpp", "external\ebpf-verifier\build\yaml-cpp.vcxproj", "{A94F0C6F-3696-3BAF-AC6F-6D0684B8AFCA}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bpf2c", "tools\bpf2c\bpf2c.vcxproj", "{69B97E52-18DC-434E-A6E4-4C0F3E88C44A}" + ProjectSection(ProjectDependencies) = postProject + {231EE32B-EBA4-4FE5-A55B-DB18F539D403} = {231EE32B-EBA4-4FE5-A55B-DB18F539D403} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bpf2c_tests", "tests\bpf2c_tests\bpf2c_tests.vcxproj", "{61DF9973-81B9-4006-9148-52F58259BBCF}" EndProject @@ -759,34 +760,6 @@ Global {FA9BB88D-8259-40C1-9422-BDEDF9E9CE68}.RelWithDebInfo|x64.Build.0 = Release|x64 {FA9BB88D-8259-40C1-9422-BDEDF9E9CE68}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 {FA9BB88D-8259-40C1-9422-BDEDF9E9CE68}.RelWithDebInfo|x86.Build.0 = Release|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Debug|ARM.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Debug|ARM64.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Debug|x64.ActiveCfg = Debug|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Debug|x64.Build.0 = Debug|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Debug|x86.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Debug|x86.Build.0 = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|ARM.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|ARM.Build.0 = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|ARM64.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|ARM64.Build.0 = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|x64.ActiveCfg = Debug|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|x64.Build.0 = Debug|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|x86.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.MinSizeRel|x86.Build.0 = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Release|ARM.ActiveCfg = Release|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Release|ARM64.ActiveCfg = Release|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Release|x64.ActiveCfg = Release|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Release|x64.Build.0 = Release|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Release|x86.ActiveCfg = Release|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.Release|x86.Build.0 = Release|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|ARM.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|ARM.Build.0 = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|ARM64.ActiveCfg = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|ARM64.Build.0 = Debug|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|x64.ActiveCfg = Release|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|x64.Build.0 = Release|x64 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 - {3C195972-46BB-491D-8820-0500FF4BA8B7}.RelWithDebInfo|x86.Build.0 = Release|Win32 {AF85C549-57CC-40A5-BDFC-DCF1998DE80F}.Debug|ARM.ActiveCfg = Debug|Win32 {AF85C549-57CC-40A5-BDFC-DCF1998DE80F}.Debug|ARM64.ActiveCfg = Debug|Win32 {AF85C549-57CC-40A5-BDFC-DCF1998DE80F}.Debug|x64.ActiveCfg = Debug|x64 @@ -1383,7 +1356,6 @@ Global {55499E36-37D4-4F86-B694-9F2990315758} = {97D3096A-20FB-4ACB-A038-88E652FE61E3} {BA065B6A-38F8-4197-8F66-87C84AFAD513} = {4B0B9AFE-78D9-48AF-9968-88D3BB83770F} {FA9BB88D-8259-40C1-9422-BDEDF9E9CE68} = {B09749EC-3D14-414B-BA9B-CD20E218DC84} - {3C195972-46BB-491D-8820-0500FF4BA8B7} = {492C9B22-9237-4996-9E33-CA14D3533616} {AF85C549-57CC-40A5-BDFC-DCF1998DE80F} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B} {1423245D-0249-40FC-A077-FF7780ACFE3F} = {7978FF80-0017-4BD7-A91D-3B113F1F9F9E} {E79382B2-FED9-4CD4-9498-DBDDD6C46C91} = {69CDB6A1-434D-4BC9-9BFF-D12DF7EDBB6B} diff --git a/ebpfapi/rpc_client.cpp b/ebpfapi/rpc_client.cpp index ff83cf900..9f80ee6d6 100644 --- a/ebpfapi/rpc_client.cpp +++ b/ebpfapi/rpc_client.cpp @@ -20,25 +20,6 @@ static const WCHAR* _protocol_sequence = L"ncalrpc"; static bool _binding_initialized = false; -ebpf_result_t -ebpf_rpc_verify_program( - _In_ ebpf_program_verify_info* info, - _Outptr_result_maybenull_z_ const char** logs, - _Out_ uint32_t* logs_size) noexcept -{ - ebpf_result_t result; - - RpcTryExcept { result = ebpf_client_verify_program(info, logs_size, const_cast(logs)); } - RpcExcept(RpcExceptionFilter(RpcExceptionCode())) - { - // TODO: (Issue# 247) Add tracing for the RpcExceptionCode() that is returned. - result = EBPF_RPC_EXCEPTION; - } - RpcEndExcept - - return result; -} - ebpf_result_t ebpf_rpc_load_program( _In_ ebpf_program_load_info* info, diff --git a/ebpfsvc/rpc_api.cpp b/ebpfsvc/rpc_api.cpp index b853567ab..a2ca6177b 100644 --- a/ebpfsvc/rpc_api.cpp +++ b/ebpfsvc/rpc_api.cpp @@ -39,33 +39,3 @@ ebpf_server_verify_and_load_program( ebpf_clear_thread_local_storage(); return result; } - -ebpf_result_t -ebpf_server_verify_program( - /* [ref][in] */ ebpf_program_verify_info* info, - /* [out] */ uint32_t* logs_size, - /* [ref][size_is][size_is][out] */ char** logs) -{ - ebpf_result_t result; - - if (info->byte_code_size == 0) { - return EBPF_INVALID_ARGUMENT; - } - - // MIDL generates warnings if any [out] param uses 'const', - // since RPC marshaling will copy the data anyway. So we - // can safely cast the 'logs' param below. - - result = ebpf_verify_program( - reinterpret_cast(&info->program_type), - info->execution_context, - info->map_descriptors_count, - reinterpret_cast(info->map_descriptors), - info->byte_code_size, - info->byte_code, - const_cast(logs), - logs_size); - - ebpf_clear_thread_local_storage(); - return result; -} diff --git a/libs/api/rpc_client.h b/libs/api/rpc_client.h index a5a81ff67..fe2eb0a0d 100644 --- a/libs/api/rpc_client.h +++ b/libs/api/rpc_client.h @@ -12,12 +12,6 @@ initialize_rpc_binding(void); RPC_STATUS clean_up_rpc_binding(void); -ebpf_result_t -ebpf_rpc_verify_program( - _In_ ebpf_program_verify_info* info, - _Outptr_result_maybenull_z_ const char** logs, - _Out_ uint32_t* logs_size) noexcept; - ebpf_result_t ebpf_rpc_load_program( _In_ ebpf_program_load_info* info, diff --git a/libs/service/api_service.cpp b/libs/service/api_service.cpp index 6fe803e36..84982ade1 100644 --- a/libs/service/api_service.cpp +++ b/libs/service/api_service.cpp @@ -229,47 +229,6 @@ _query_and_cache_map_descriptors( return EBPF_SUCCESS; } -ebpf_result_t -ebpf_verify_program( - const GUID* program_type, - ebpf_execution_context_t execution_context, - uint32_t map_descriptors_count, - EbpfMapDescriptor* map_descriptors, - uint32_t byte_code_size, - uint8_t* byte_code, - const char** logs, - uint32_t* logs_size) noexcept -{ - ebpf_result_t result = EBPF_SUCCESS; - - // Only kernel execution context supported currently. - if (execution_context == execution_context_user_mode) { - return EBPF_INVALID_ARGUMENT; - } - - clear_map_descriptors(); - - try { - if (map_descriptors_count != 0) { - cache_map_original_file_descriptors(map_descriptors, map_descriptors_count); - } - - // Verify the program. - result = verify_byte_code(program_type, byte_code, byte_code_size, logs, logs_size); - } catch (const std::bad_alloc&) { - result = EBPF_NO_MEMORY; - } catch (std::runtime_error& err) { - auto message = err.what(); - *logs = allocate_string(message, logs_size); - - result = EBPF_VERIFICATION_FAILED; - } catch (...) { - result = EBPF_FAILED; - } - - return result; -} - ebpf_result_t ebpf_verify_and_load_program( const GUID* program_type, diff --git a/libs/service/api_service.h b/libs/service/api_service.h index f85aebf8b..b12b12216 100644 --- a/libs/service/api_service.h +++ b/libs/service/api_service.h @@ -10,17 +10,6 @@ #include "ebpf_result.h" #include "rpc_interface_h.h" -ebpf_result_t -ebpf_verify_program( - const GUID* program_type, - ebpf_execution_context_t execution_context, - uint32_t map_descriptors_count, - EbpfMapDescriptor* map_descriptors, - uint32_t byte_code_size, - uint8_t* byte_code, - const char** logs, - uint32_t* logs_size) noexcept; - ebpf_result_t ebpf_verify_and_load_program( const GUID* program_type, diff --git a/rpc_interface/rpc_interface.idl b/rpc_interface/rpc_interface.idl index 03ddf2572..8eb916467 100644 --- a/rpc_interface/rpc_interface.idl +++ b/rpc_interface/rpc_interface.idl @@ -75,10 +75,4 @@ import "wtypes.idl"; [ in, ref ] ebpf_program_load_info * info, [ out, ref ] uint32_t * logs_size, [ out, size_is(, *logs_size), ref ] char** logs); - - ebpf_result_t verify_program([ in, ref ] ebpf_program_verify_info * info, [out] uint32_t * logs_size, [ - out, - size_is(, *logs_size), - ref - ] char** logs); } diff --git a/scripts/deploy-ebpf.ps1 b/scripts/deploy-ebpf.ps1 index c7d984dc4..7739c3a18 100644 --- a/scripts/deploy-ebpf.ps1 +++ b/scripts/deploy-ebpf.ps1 @@ -70,8 +70,6 @@ $build_directory=".\x64\Debug" "droppacket_um.pdb", "droppacket.sys", "droppacket_unsafe.o", - "ebpf_client.exe", - "ebpf_client.pdb", "EbpfApi.pdb", "ebpfnetsh.pdb", "encap_reflect_packet.o", diff --git a/scripts/run_driver_tests.psm1 b/scripts/run_driver_tests.psm1 index 5144f855a..8a7e0118d 100644 --- a/scripts/run_driver_tests.psm1 +++ b/scripts/run_driver_tests.psm1 @@ -88,7 +88,6 @@ function Invoke-CICDTests try { $TestList = @( - "ebpf_client.exe", "api_test.exe", "bpftool_tests.exe", "sample_ext_app.exe", diff --git a/scripts/run_tests.bat b/scripts/run_tests.bat index 5961ae773..3665933a8 100644 --- a/scripts/run_tests.bat +++ b/scripts/run_tests.bat @@ -20,11 +20,6 @@ if %install% == 1 ( @echo ===================== .\unit_tests.exe @if ERRORLEVEL 1 goto EOF -@echo =========================== -@echo Executing RPC Client Tests. -@echo =========================== -.\ebpf_client.exe -@if ERRORLEVEL 1 goto EOF @echo ==================== @echo Executing API Tests. @echo ==================== diff --git a/tests/client/ebpf_client.vcxproj b/tests/client/ebpf_client.vcxproj deleted file mode 100644 index a099dab2a..000000000 --- a/tests/client/ebpf_client.vcxproj +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {3c195972-46bb-491d-8820-0500ff4ba8b7} - rpcclient - 10.0 - ebpf_client - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - $(IncludePath) - - - false - - - - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - mincore.lib;%(AdditionalDependencies) - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - mincore.lib;%(AdditionalDependencies) - - - - - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(SolutionDir)libs\api_common;$(SolutionDir)tests\libs\util;$(SolutionDir)libs\api;$(SolutionDir)include;$(SolutionDir)libs\platform;$(SolutionDir)libs\platform\user;$(SolutionDir)rpc_interface;$(SolutionDir)external\ebpf-verifier\external;$(SolutionDir)external\ebpf-verifier\src;$(SolutionDir)\ebpfsvc;$(SolutionDir)external\catch2\src;$(SolutionDir)external\catch2\build\generated-includes;%(AdditionalIncludeDirectories) - - - Console - DebugFull - mincore.lib;%(AdditionalDependencies) - - - - - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(SolutionDir)libs\api_common;$(SolutionDir)tests\libs\util;$(SolutionDir)libs\api;$(SolutionDir)include;$(SolutionDir)libs\platform;$(SolutionDir)libs\platform\user;$(SolutionDir)rpc_interface;$(SolutionDir)external\ebpf-verifier\external;$(SolutionDir)external\ebpf-verifier\src;$(SolutionDir)\ebpfsvc;$(SolutionDir)external\catch2\src;$(SolutionDir)external\catch2\build\generated-includes;%(AdditionalIncludeDirectories) - - - Console - true - true - DebugFull - mincore.lib;%(AdditionalDependencies) - - - - - - - - - - {8bd3552a-2cfb-4a59-ab15-2031b97ada1e} - - - {7d5b4e68-c0fa-3f86-9405-f6400219b440} - - - {c8bf60c3-40a9-43ad-891a-8aa34f1c3a68} - - - {e79382b2-fed9-4cd4-9498-dbddd6c46c91} - - - {c26cb6a9-158c-4a9e-a243-755ddd98e5fe} - - - {af85c549-57cc-40a5-bdfc-dcf1998de80f} - - - {245f0ec7-1ebc-4d68-8b1f-f758ea9196ae} - - - {1423245d-0249-40fc-a077-ff7780acfe3f} - - - {d6725f19-b9bf-435f-80f2-c5f3ef0f4b8f} - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/tests/client/ebpf_client.vcxproj.filters b/tests/client/ebpf_client.vcxproj.filters deleted file mode 100644 index 98341dcda..000000000 --- a/tests/client/ebpf_client.vcxproj.filters +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - - - - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/tests/client/main.cpp b/tests/client/main.cpp deleted file mode 100644 index 4e98c33df..000000000 --- a/tests/client/main.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) Microsoft Corporation -// SPDX-License-Identifier: MIT - -#define CATCH_CONFIG_MAIN - -#include "api_internal.h" -#include "catch_wrapper.hpp" -#include "ebpf_api.h" -#include "ebpf_verifier_wrapper.hpp" -#include "header.h" -#include "rpc_client.h" -#include "rpc_interface_h.h" -#include "service_helper.h" - -#define EBPF_SERVICE_BINARY_NAME L"ebpfsvc.exe" -#define EBPF_SERVICE_NAME L"ebpfsvc" - -static service_install_helper _service_helper(EBPF_SERVICE_NAME, EBPF_SERVICE_BINARY_NAME, SERVICE_WIN32_OWN_PROCESS); - -static void -_get_program_byte_code_helper(const char* file_name, const char* section_name, ebpf_program_verify_info* info) -{ - EbpfMapDescriptor* descriptors = nullptr; - int descriptors_count; - ebpf_result_t result = EBPF_SUCCESS; - const char* error_message = nullptr; - std::vector programs; - ebpf_program_t* program; - - // Get byte code and map descriptors from ELF file. - REQUIRE( - (result = ebpf_get_program_byte_code( - file_name, - section_name, - true, // mock map fd - programs, - &descriptors, - &descriptors_count, - &error_message), - error_message ? printf("ebpf_get_program_byte_code failed with %s\n", error_message) : 0, - ebpf_free_string(error_message), - error_message = nullptr, - result == EBPF_SUCCESS)); - - REQUIRE(programs.size() == 1); - program = programs[0]; - REQUIRE(program->byte_code_size != 0); - - info->program_type = program->program_type; - info->byte_code = program->byte_code; - info->byte_code_size = program->byte_code_size; - info->map_descriptors_count = descriptors_count; - info->execution_context = execution_context_kernel_mode; - if (descriptors != nullptr) { - info->map_descriptors = reinterpret_cast(descriptors); - } - - printf("instruction_array_size = %d\n", program->byte_code_size); - ebpf_free_string(error_message); -} - -TEST_CASE("verify-program-droppacket", "[verify-program-droppacket]") -{ - uint32_t result; - const char* verifier_message = nullptr; - uint32_t verifier_message_size; - ebpf_program_verify_info info = {0}; - - // Get byte code and map descriptors from ELF file. - _get_program_byte_code_helper("droppacket.o", "xdp", &info); - - REQUIRE(initialize_rpc_binding() == RPC_S_OK); - - REQUIRE( - (result = ebpf_rpc_verify_program(&info, &verifier_message, &verifier_message_size), - verifier_message ? printf("ebpf_rpc_verify_program failed with: %s\n", verifier_message) : 0, - ebpf_free_string(verifier_message), - verifier_message = nullptr, - result == ERROR_SUCCESS)); - - ebpf_free_string(verifier_message); - clean_up_rpc_binding(); -} - -TEST_CASE("verify-program-bindmonitor", "[verify-program-bindmonitor]") -{ - uint32_t result; - const char* verifier_message = nullptr; - uint32_t verifier_message_size; - ebpf_program_verify_info info = {0}; - - // Get byte code and map descriptors from ELF file. - _get_program_byte_code_helper("bindmonitor.o", "bind", &info); - - REQUIRE(initialize_rpc_binding() == RPC_S_OK); - - REQUIRE( - (result = ebpf_rpc_verify_program(&info, &verifier_message, &verifier_message_size), - verifier_message ? printf("ebpf_rpc_verify_program failed with %s\n", verifier_message) : 0, - ebpf_free_string(verifier_message), - verifier_message = nullptr, - result == ERROR_SUCCESS)); - - ebpf_free_string(verifier_message); - clean_up_rpc_binding(); -} - -TEST_CASE("verify-program-divide_by_zero", "[verify-program-divide_by_zero]") -{ - uint32_t result; - const char* verifier_message = nullptr; - uint32_t verifier_message_size; - ebpf_program_verify_info info = {0}; - - // Get byte code and map descriptors from ELF file. - _get_program_byte_code_helper("divide_by_zero.o", "xdp", &info); - - REQUIRE(initialize_rpc_binding() == RPC_S_OK); - - REQUIRE( - (result = ebpf_rpc_verify_program(&info, &verifier_message, &verifier_message_size), - verifier_message ? printf("ebpf_rpc_verify_program failed with %s\n", verifier_message) : 0, - ebpf_free_string(verifier_message), - verifier_message = nullptr, - result == ERROR_SUCCESS)); - - ebpf_free_string(verifier_message); - clean_up_rpc_binding(); -} - -TEST_CASE("verify-program-droppacket_unsafe", "[verify-program-droppacket_unsafe]") -{ - uint32_t result; - const char* verifier_message = nullptr; - uint32_t verifier_message_size; - ebpf_program_verify_info info = {0}; - - // Get byte code and map descriptors from ELF file. - _get_program_byte_code_helper("droppacket_unsafe.o", "xdp", &info); - - REQUIRE(initialize_rpc_binding() == RPC_S_OK); - - result = ebpf_rpc_verify_program(&info, &verifier_message, &verifier_message_size); - if (result != ERROR_SUCCESS) { - if (verifier_message_size > 0) { - printf("message from verifier:\n %s\n", verifier_message); - ebpf_free_string(verifier_message); - verifier_message = nullptr; - } - } - REQUIRE((result == (int)EBPF_VERIFICATION_FAILED)); - REQUIRE(verifier_message_size > 0); - - ebpf_free_string(verifier_message); - clean_up_rpc_binding(); -} diff --git a/tests/client/packages.config b/tests/client/packages.config deleted file mode 100644 index 6e4fbb960..000000000 --- a/tests/client/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file