Skip to content

Commit

Permalink
Update ebpf-for-windows version to v0.15.1 (#485)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
matthewige authored Apr 9, 2024
1 parent ec68e76 commit 3b7480b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/bpfexport/bpfexport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/xdp.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<XdpMinorVersion>1</XdpMinorVersion>
<XdpPatchVersion>0</XdpPatchVersion>
<!-- Project-wide properties -->
<EbpfPackagePath>$(SolutionDir)packages\eBPF-for-Windows.0.13.0\</EbpfPackagePath>
<EbpfPackagePath>$(SolutionDir)packages\eBPF-for-Windows.0.15.1\</EbpfPackagePath>
<WiXPackagePath>$(SolutionDir)packages\wix.3.14.1\</WiXPackagePath>
<FnPackagePath>$(SolutionDir)artifacts\fn\devkit-0.4.1\</FnPackagePath>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/xdp/ebpfextension.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
27 changes: 20 additions & 7 deletions src/xdp/ebpfstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/xdp/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="eBPF-for-Windows" version="0.13.0" targetFramework="native" developmentDependency="true" />
<package id="eBPF-for-Windows" version="0.15.1" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.Build.Tasks.Git" version="1.0.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.AzureRepos.Git" version="1.0.0" targetFramework="native" developmentDependency="true" />
<package id="Microsoft.SourceLink.Common" version="1.0.0" targetFramework="native" developmentDependency="true" />
Expand Down
33 changes: 15 additions & 18 deletions src/xdp/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,45 +642,42 @@ 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,
.context_destroy = XdpDeleteContext,
.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,
.Guid = EBPF_PROGRAM_TYPE_XDP_INIT,
};

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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tools/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function Get-EbpfInstallPath {
}

function Get-EbpfMsiVersion {
return "0.13.0"
return "0.15.1"
}

# Returns the eBPF package type.
Expand Down
27 changes: 0 additions & 27 deletions tools/prepare-machine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 3b7480b

Please sign in to comment.