From 3b7480bf7669c82bb4a2eddb06047d25358eba9a Mon Sep 17 00:00:00 2001 From: Matthew Ige Date: Tue, 9 Apr 2024 08:00:57 -0700 Subject: [PATCH] Update ebpf-for-windows version to v0.15.1 (#485) * update ebpf to v0.15.0 * update structs * fix * WIP * compile fixes * fix * fix * fix provider regsiter * fix * wip * wip * tmp * tmp * update to v0.15.1 * tmp * tmp --- src/bpfexport/bpfexport.c | 2 +- src/xdp.props | 2 +- src/xdp/ebpfextension.h | 2 +- src/xdp/ebpfstore.h | 27 ++++++++++++++++++++------- src/xdp/packages.config | 2 +- src/xdp/program.c | 33 +++++++++++++++------------------ tools/common.ps1 | 2 +- tools/prepare-machine.ps1 | 27 --------------------------- 8 files changed, 40 insertions(+), 57 deletions(-) diff --git a/src/bpfexport/bpfexport.c b/src/bpfexport/bpfexport.c index 1943878a..7469b0c4 100644 --- a/src/bpfexport/bpfexport.c +++ b/src/bpfexport/bpfexport.c @@ -46,7 +46,7 @@ main( exit_code = -1; } - result = ebpf_store_update_program_information(&EbpfXdpProgramInfo, 1); + result = ebpf_store_update_program_information_array(&EbpfXdpProgramInfo, 1); if (result != EBPF_SUCCESS) { fprintf(stderr, "ebpf_store_update_program_information failed: %u\n", result); exit_code = -1; diff --git a/src/xdp.props b/src/xdp.props index a33d19e9..927c1f48 100644 --- a/src/xdp.props +++ b/src/xdp.props @@ -5,7 +5,7 @@ 1 0 - $(SolutionDir)packages\eBPF-for-Windows.0.13.0\ + $(SolutionDir)packages\eBPF-for-Windows.0.15.1\ $(SolutionDir)packages\wix.3.14.1\ $(SolutionDir)artifacts\fn\devkit-0.4.1\ diff --git a/src/xdp/ebpfextension.h b/src/xdp/ebpfextension.h index 04cb5721..bcc95ddd 100644 --- a/src/xdp/ebpfextension.h +++ b/src/xdp/ebpfextension.h @@ -23,7 +23,7 @@ EBPF_EXTENSION_ON_CLIENT_DETACH( typedef struct _EBPF_EXTENSION_PROVIDER_PARAMETERS { const NPI_MODULEID *ProviderModuleId; - const ebpf_extension_data_t *ProviderData; + const VOID *ProviderData; } EBPF_EXTENSION_PROVIDER_PARAMETERS; const ebpf_extension_data_t * diff --git a/src/xdp/ebpfstore.h b/src/xdp/ebpfstore.h index 6756dc36..da64b8b7 100644 --- a/src/xdp/ebpfstore.h +++ b/src/xdp/ebpfstore.h @@ -24,6 +24,10 @@ static const ebpf_context_descriptor_t EbpfXdpContextDescriptor = { // XDP helper function prototype descriptors. static const ebpf_helper_function_prototype_t EbpfXdpHelperFunctionPrototype[] = { { + .header = { + .version = EBPF_HELPER_FUNCTION_PROTOTYPE_CURRENT_VERSION, + .size = EBPF_HELPER_FUNCTION_PROTOTYPE_CURRENT_VERSION_SIZE + }, .helper_id = XDP_EXT_HELPER_FUNCTION_START + 1, .name = "bpf_xdp_adjust_head", .return_type = EBPF_RETURN_TYPE_INTEGER, @@ -34,20 +38,29 @@ static const ebpf_helper_function_prototype_t EbpfXdpHelperFunctionPrototype[] = }, }; -#pragma warning(suppress:4090) // 'initializing': different 'const' qualifiers +static const ebpf_program_type_descriptor_t EbpfXdpProgramTypeDescriptor = { + .header = { + .version = EBPF_PROGRAM_TYPE_DESCRIPTOR_CURRENT_VERSION, + .size = EBPF_PROGRAM_TYPE_DESCRIPTOR_CURRENT_VERSION_SIZE + }, + .name = "xdp", + .context_descriptor = &EbpfXdpContextDescriptor, + .program_type = EBPF_PROGRAM_TYPE_XDP_INIT, + .bpf_prog_type = BPF_PROG_TYPE_XDP +}; + const ebpf_program_info_t EbpfXdpProgramInfo = { -#pragma warning(suppress:4090) // 'initializing': different 'const' qualifiers - .program_type_descriptor = { - .name = "xdp", - .context_descriptor = &EbpfXdpContextDescriptor, - .program_type = EBPF_PROGRAM_TYPE_XDP_INIT, - BPF_PROG_TYPE_XDP, + .header = { + .version = EBPF_PROGRAM_INFORMATION_CURRENT_VERSION, + .size = EBPF_PROGRAM_INFORMATION_CURRENT_VERSION_SIZE }, + .program_type_descriptor = &EbpfXdpProgramTypeDescriptor, .count_of_program_type_specific_helpers = RTL_NUMBER_OF(EbpfXdpHelperFunctionPrototype), .program_type_specific_helper_prototype = EbpfXdpHelperFunctionPrototype, }; #define DECLARE_XDP_SECTION(_section_name) \ + { EBPF_PROGRAM_SECTION_INFORMATION_CURRENT_VERSION, EBPF_PROGRAM_SECTION_INFORMATION_CURRENT_VERSION_SIZE }, \ (const wchar_t*)_section_name, &EBPF_PROGRAM_TYPE_XDP, &EBPF_ATTACH_TYPE_XDP, \ BPF_PROG_TYPE_XDP, BPF_XDP diff --git a/src/xdp/packages.config b/src/xdp/packages.config index 29092091..ca2a1a2b 100644 --- a/src/xdp/packages.config +++ b/src/xdp/packages.config @@ -1,6 +1,6 @@  - + diff --git a/src/xdp/program.c b/src/xdp/program.c index 1153d329..310612e6 100644 --- a/src/xdp/program.c +++ b/src/xdp/program.c @@ -642,12 +642,19 @@ static const VOID *EbpfXdpHelperFunctions[] = { }; static const ebpf_helper_function_addresses_t XdpHelperFunctionAddresses = { + .header = { + .version = EBPF_HELPER_FUNCTION_ADDRESSES_CURRENT_VERSION, + .size = EBPF_HELPER_FUNCTION_ADDRESSES_CURRENT_VERSION_SIZE + }, .helper_function_count = RTL_NUMBER_OF(EbpfXdpHelperFunctions), .helper_function_address = (UINT64 *)EbpfXdpHelperFunctions }; -#pragma warning(suppress:4090) // 'initializing': different 'const' qualifiers static const ebpf_program_data_t EbpfXdpProgramData = { + .header = { + .version = EBPF_PROGRAM_DATA_CURRENT_VERSION, + .size = EBPF_PROGRAM_DATA_CURRENT_VERSION_SIZE + }, .program_info = &EbpfXdpProgramInfo, .program_type_specific_helper_function_addresses = &XdpHelperFunctionAddresses, .context_create = XdpCreateContext, @@ -655,13 +662,6 @@ static const ebpf_program_data_t EbpfXdpProgramData = { .required_irql = DISPATCH_LEVEL, }; -#pragma warning(suppress:4090) // 'initializing': different 'const' qualifiers -static const ebpf_extension_data_t EbpfXdpProgramInfoProviderData = { - .version = 0, // Review: versioning? - .size = sizeof(EbpfXdpProgramData), - .data = &EbpfXdpProgramData, -}; - static const NPI_MODULEID EbpfXdpProgramInfoProviderModuleId = { .Length = sizeof(NPI_MODULEID), .Type = MIT_GUID, @@ -669,18 +669,15 @@ static const NPI_MODULEID EbpfXdpProgramInfoProviderModuleId = { }; static const ebpf_attach_provider_data_t EbpfXdpHookAttachProviderData = { + .header = { + .version = EBPF_ATTACH_PROVIDER_DATA_CURRENT_VERSION , + .size = EBPF_ATTACH_PROVIDER_DATA_CURRENT_VERSION_SIZE + }, .supported_program_type = EBPF_PROGRAM_TYPE_XDP_INIT, .bpf_attach_type = BPF_XDP, .link_type = BPF_LINK_TYPE_XDP, }; -#pragma warning(suppress:4090) // 'initializing': different 'const' qualifiers -static const ebpf_extension_data_t EbpfXdpHookProviderData = { - .version = EBPF_ATTACH_PROVIDER_DATA_VERSION, - .size = sizeof(EbpfXdpHookAttachProviderData), - .data = &EbpfXdpHookAttachProviderData, -}; - static const NPI_MODULEID EbpfXdpHookProviderModuleId = { .Length = sizeof(NPI_MODULEID), .Type = MIT_GUID, @@ -1646,7 +1643,7 @@ EbpfProgramOnClientAttach( TraceEnter( TRACE_CORE, "AttachingProvider=%p AttachingClient=%p", AttachingProvider, AttachingClient); - if (ClientData == NULL || ClientData->size != sizeof(IfIndex) || ClientData->data == NULL) { + if (ClientData == NULL || ClientData->header.size != sizeof(IfIndex) || ClientData->data == NULL) { Status = STATUS_INVALID_PARAMETER; goto Exit; } @@ -1731,11 +1728,11 @@ XdpProgramStart( { const EBPF_EXTENSION_PROVIDER_PARAMETERS EbpfProgramInfoProviderParameters = { .ProviderModuleId = &EbpfXdpProgramInfoProviderModuleId, - .ProviderData = &EbpfXdpProgramInfoProviderData, + .ProviderData = &EbpfXdpProgramData, }; const EBPF_EXTENSION_PROVIDER_PARAMETERS EbpfHookProviderParameters = { .ProviderModuleId = &EbpfXdpHookProviderModuleId, - .ProviderData = &EbpfXdpHookProviderData, + .ProviderData = &EbpfXdpHookAttachProviderData, }; DWORD EbpfEnabled; NTSTATUS Status; diff --git a/tools/common.ps1 b/tools/common.ps1 index a398bdbc..7d41bbae 100644 --- a/tools/common.ps1 +++ b/tools/common.ps1 @@ -109,7 +109,7 @@ function Get-EbpfInstallPath { } function Get-EbpfMsiVersion { - return "0.13.0" + return "0.15.1" } # Returns the eBPF package type. diff --git a/tools/prepare-machine.ps1 b/tools/prepare-machine.ps1 index 5c9cd0d0..18e0b739 100644 --- a/tools/prepare-machine.ps1 +++ b/tools/prepare-machine.ps1 @@ -88,12 +88,6 @@ if (!$ForBuild -and !$ForEbpfBuild -and !$ForTest -and !$ForFunctionalTest -and Write-Error 'Must one of -ForBuild, -ForTest, -ForFunctionalTest, -ForSpinxskTest, -ForPerfTest, -ForNetPerfTest, or -ForLogging' } -$EbpfNugetVersion = "eBPF-for-Windows.0.13.0" -$EbpfNugetBuild = "+5122375852" -$EbpfNuget = "$EbpfNugetVersion$EbpfNugetBuild.nupkg" -$EbpfNugetUrl = "https://github.com/microsoft/xdp-for-windows/releases/download/main-prerelease/$EbpfNugetVersion$EbpfNugetBuild.nupkg" -$EbpfNugetRestoreDir = "$RootDir/packages/$EbpfNugetVersion" - # Flag that indicates something required a reboot. $Reboot = $false @@ -113,27 +107,6 @@ function Download-CoreNet-Deps { } } -function Download-eBpf-Nuget { - # Download and extract private eBPF Nuget package. - $NugetDir = "$ArtifactsDir/nuget" - if ($Force -and (Test-Path $NugetDir)) { - Remove-Item -Recurse -Force $NugetDir - } - if (!(Test-Path $NugetDir)) { - mkdir $NugetDir | Write-Verbose - } - - if (!(Test-Path $NugetDir/$EbpfNuget)) { - # Remove any old builds of the package. - if (Test-Path $EbpfNugetRestoreDir) { - Remove-Item -Recurse -Force $EbpfNugetRestoreDir - } - Remove-Item -Force $NugetDir/$EbpfNugetVersion* - - Invoke-WebRequest-WithRetry -Uri $EbpfNugetUrl -OutFile $NugetDir/$EbpfNuget - } -} - function Extract-Ebpf-Msi { $EbpfPackageFullPath = "$ArtifactsDir\ebpf.zip" $EbpfMsiFullPath = Get-EbpfMsiFullPath