Remove ebpf_verify_program API (#997)

* Remove ebpf_verify_program API

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Remove old test

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Cleanup runners

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* PR feedback

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

* Cleanup old artifacts

Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>

Co-authored-by: Alan Jowett <alan.jowett@microsoft.com>
This commit is contained in:
Alan Jowett 2022-04-25 10:46:22 -06:00 коммит произвёл GitHub
Родитель 6bc0a6bd8a
Коммит 1989d26873
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
18 изменённых файлов: 12 добавлений и 562 удалений

4
.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:

2
.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:

5
.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

Просмотреть файл

@ -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

Просмотреть файл

@ -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}

Просмотреть файл

@ -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<char**>(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,

Просмотреть файл

@ -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<const GUID*>(&info->program_type),
info->execution_context,
info->map_descriptors_count,
reinterpret_cast<EbpfMapDescriptor*>(info->map_descriptors),
info->byte_code_size,
info->byte_code,
const_cast<const char**>(logs),
logs_size);
ebpf_clear_thread_local_storage();
return result;
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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,

Просмотреть файл

@ -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,

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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",

Просмотреть файл

@ -88,7 +88,6 @@ function Invoke-CICDTests
try {
$TestList = @(
"ebpf_client.exe",
"api_test.exe",
"bpftool_tests.exe",
"sample_ext_app.exe",

Просмотреть файл

@ -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 ====================

Просмотреть файл

@ -1,194 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: MIT
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\CatchOrg.Catch.2.8.0\build\native\CatchOrg.Catch.props" Condition="Exists('..\..\packages\CatchOrg.Catch.2.8.0\build\native\CatchOrg.Catch.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{3c195972-46bb-491d-8820-0500ff4ba8b7}</ProjectGuid>
<RootNamespace>rpcclient</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>ebpf_client</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<AdditionalDependencies>mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<AdditionalDependencies>mincore.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\ebpfapi\rpc_client.cpp" />
<ClCompile Include="..\..\libs\thunk\windows\platform.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\external\Catch2\build\src\Catch2WithMain.vcxproj">
<Project>{8bd3552a-2cfb-4a59-ab15-2031b97ada1e}</Project>
</ProjectReference>
<ProjectReference Include="..\..\external\ebpf-verifier\build\ebpfverifier.vcxproj">
<Project>{7d5b4e68-c0fa-3f86-9405-f6400219b440}</Project>
</ProjectReference>
<ProjectReference Include="..\..\libs\api\api.vcxproj">
<Project>{c8bf60c3-40a9-43ad-891a-8aa34f1c3a68}</Project>
</ProjectReference>
<ProjectReference Include="..\..\libs\api_common\api_common.vcxproj">
<Project>{e79382b2-fed9-4cd4-9498-dbddd6c46c91}</Project>
</ProjectReference>
<ProjectReference Include="..\..\libs\platform\user\platform_user.vcxproj">
<Project>{c26cb6a9-158c-4a9e-a243-755ddd98e5fe}</Project>
</ProjectReference>
<ProjectReference Include="..\..\libs\service\service.vcxproj">
<Project>{af85c549-57cc-40a5-bdfc-dcf1998de80f}</Project>
</ProjectReference>
<ProjectReference Include="..\..\libs\ubpf\user\ubpf_user.vcxproj">
<Project>{245f0ec7-1ebc-4d68-8b1f-f758ea9196ae}</Project>
</ProjectReference>
<ProjectReference Include="..\..\rpc_interface\rpc_interface.vcxproj">
<Project>{1423245d-0249-40fc-a077-ff7780acfe3f}</Project>
</ProjectReference>
<ProjectReference Include="..\libs\util\test_util.vcxproj">
<Project>{d6725f19-b9bf-435f-80f2-c5f3ef0f4b8f}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\libs\api\rpc_client.h" />
<ClInclude Include="header.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\boost.1.75.0.0\build\boost.targets" Condition="Exists('..\..\packages\boost.1.75.0.0\build\boost.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\boost.1.75.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\boost.1.75.0.0\build\boost.targets'))" />
<Error Condition="!Exists('..\..\packages\CatchOrg.Catch.2.8.0\build\native\CatchOrg.Catch.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\CatchOrg.Catch.2.8.0\build\native\CatchOrg.Catch.props'))" />
</Target>
</Project>

Просмотреть файл

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) Microsoft Corporation
SPDX-License-Identifier: MIT
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ebpfapi\rpc_client.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\libs\thunk\windows\platform.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="header.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\libs\api\rpc_client.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

Просмотреть файл

@ -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<ebpf_program_t*> 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<ebpf_map_descriptor*>(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();
}

Просмотреть файл

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="boost" version="1.75.0.0" targetFramework="native" />
<package id="CatchOrg.Catch" version="2.8.0" targetFramework="native" />
</packages>