Skip to content

Commit

Permalink
Update ebpf to 0.17, Update vc_redist version in scripts (#564)
Browse files Browse the repository at this point in the history
* update ebpf to 0.17

* update headers

* remove deleted batch param args

* update scripts

* add debug log

* debug log

* fix

* update to vc_redist v17
  • Loading branch information
matthewige authored Jun 20, 2024
1 parent d536bb2 commit efbe1df
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 43 deletions.
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.15.1\</EbpfPackagePath>
<EbpfPackagePath>$(SolutionDir)packages\eBPF-for-Windows.0.17.0\</EbpfPackagePath>
<WiXPackagePath>$(SolutionDir)packages\wix.3.14.1\</WiXPackagePath>
<FnPackagePath>$(SolutionDir)artifacts\fn\devkit-0.4.4\</FnPackagePath>
</PropertyGroup>
Expand Down
17 changes: 4 additions & 13 deletions src/xdp/ebpfstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ 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
},
.header = EBPF_HELPER_FUNCTION_PROTOTYPE_HEADER,
.helper_id = XDP_EXT_HELPER_FUNCTION_START + 1,
.name = "bpf_xdp_adjust_head",
.return_type = EBPF_RETURN_TYPE_INTEGER,
Expand All @@ -39,28 +36,22 @@ static const ebpf_helper_function_prototype_t EbpfXdpHelperFunctionPrototype[] =
};

static const ebpf_program_type_descriptor_t EbpfXdpProgramTypeDescriptor = {
.header = {
.version = EBPF_PROGRAM_TYPE_DESCRIPTOR_CURRENT_VERSION,
.size = EBPF_PROGRAM_TYPE_DESCRIPTOR_CURRENT_VERSION_SIZE
},
.header = EBPF_PROGRAM_TYPE_DESCRIPTOR_HEADER,
.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 = {
.header = {
.version = EBPF_PROGRAM_INFORMATION_CURRENT_VERSION,
.size = EBPF_PROGRAM_INFORMATION_CURRENT_VERSION_SIZE
},
.header = EBPF_PROGRAM_INFORMATION_HEADER,
.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 }, \
EBPF_PROGRAM_SECTION_INFORMATION_HEADER, \
(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.15.1" targetFramework="native" developmentDependency="true" />
<package id="eBPF-for-Windows" version="0.17.0" 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
26 changes: 5 additions & 21 deletions src/xdp/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,21 +320,16 @@ XdpInspectEbpfStartBatch(
)
{
const EBPF_EXTENSION_CLIENT *Client;
const VOID *ClientBindingContext;
ebpf_result_t EbpfResult;

ASSERT(XdpProgramIsEbpf(Program));

Client = (const EBPF_EXTENSION_CLIENT *)Program->Rules[0].Ebpf.Target;
ClientBindingContext = EbpfExtensionClientGetClientContext(Client);

ebpf_program_batch_begin_invoke_function_t EbpfBatchBegin =
EbpfExtensionClientGetProgramDispatch(Client)->ebpf_program_batch_begin_invoke_function;

EbpfResult =
EbpfBatchBegin(
ClientBindingContext, sizeof(InspectionContext->EbpfContext),
&InspectionContext->EbpfContext);
EbpfResult = EbpfBatchBegin(sizeof(InspectionContext->EbpfContext), &InspectionContext->EbpfContext);

return EbpfResult == EBPF_SUCCESS;
}
Expand All @@ -347,18 +342,16 @@ XdpInspectEbpfEndBatch(
)
{
const EBPF_EXTENSION_CLIENT *Client;
const VOID *ClientBindingContext;
ebpf_result_t EbpfResult;

ASSERT(XdpProgramIsEbpf(Program));

Client = (const EBPF_EXTENSION_CLIENT *)Program->Rules[0].Ebpf.Target;
ClientBindingContext = EbpfExtensionClientGetClientContext(Client);

ebpf_program_batch_end_invoke_function_t EbpfBatchEnd =
EbpfExtensionClientGetProgramDispatch(Client)->ebpf_program_batch_end_invoke_function;

EbpfResult = EbpfBatchEnd(ClientBindingContext, &InspectionContext->EbpfContext);
EbpfResult = EbpfBatchEnd(&InspectionContext->EbpfContext);

ASSERT(EbpfResult == EBPF_SUCCESS);
}
Expand Down Expand Up @@ -648,19 +641,13 @@ 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
},
.header = EBPF_HELPER_FUNCTION_ADDRESSES_HEADER,
.helper_function_count = RTL_NUMBER_OF(EbpfXdpHelperFunctions),
.helper_function_address = (UINT64 *)EbpfXdpHelperFunctions
};

static const ebpf_program_data_t EbpfXdpProgramData = {
.header = {
.version = EBPF_PROGRAM_DATA_CURRENT_VERSION,
.size = EBPF_PROGRAM_DATA_CURRENT_VERSION_SIZE
},
.header = EBPF_PROGRAM_DATA_HEADER,
.program_info = &EbpfXdpProgramInfo,
.program_type_specific_helper_function_addresses = &XdpHelperFunctionAddresses,
.context_create = XdpCreateContext,
Expand All @@ -675,10 +662,7 @@ 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
},
.header = EBPF_ATTACH_PROVIDER_DATA_HEADER,
.supported_program_type = EBPF_PROGRAM_TYPE_XDP_INIT,
.bpf_attach_type = BPF_XDP,
.link_type = BPF_LINK_TYPE_XDP,
Expand Down
14 changes: 11 additions & 3 deletions 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.15.1"
return "0.17.0"
}

# Returns the eBPF package type.
Expand All @@ -124,10 +124,18 @@ function Get-EbpfPackageType {
# Return the eBPF package name.
function Get-EbpfPackageName {
if ($UseJitEbpf) {
return "Build-x64-Release.zip"
return "Build-x64.Release.zip"
}

return "Build-x64-native-only-NativeOnlyRelease.zip"
return "Build-x64-native-only.NativeOnlyRelease.zip"
}

function Get-EbpfDirectoryName {
if ($UseJitEbpf) {
return "Build-x64 Release"
}

return "Build-x64-native-only NativeOnlyRelease"
}

# Returns the eBPF MSI full path
Expand Down
8 changes: 4 additions & 4 deletions tools/prepare-machine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ function Extract-Ebpf-Msi {
$EbpfPackageFullPath = "$ArtifactsDir\ebpf.zip"
$EbpfMsiFullPath = Get-EbpfMsiFullPath
$EbpfMsiDir = Split-Path $EbpfMsiFullPath
$EbpfPackageType = Get-EbpfPackageType
$EbpfDirectoryName = Get-EbpfDirectoryName

Write-Debug "Extracting eBPF MSI from Release package"

# Extract the MSI from the package.
pushd $ArtifactsDir
dir
Expand-Archive -Path $EbpfPackageFullPath -Force
Expand-Archive -Path "$ArtifactsDir\ebpf\build-$EbpfPackageType.zip" -Force
xcopy "$ArtifactsDir\build-$EbpfPackageType\$EbpfPackageType\ebpf-for-windows.msi" /F /Y $EbpfMsiDir
xcopy "$ArtifactsDir\ebpf\$EbpfDirectoryName\ebpf-for-windows.msi" /F /Y $EbpfMsiDir
popd
}

Expand Down Expand Up @@ -233,7 +233,7 @@ function Setup-VcRuntime {
Remove-Item -Force "$ArtifactsDir\vc_redist.x64.exe" -ErrorAction Ignore

# Download and install.
Invoke-WebRequest-WithRetry -Uri "https://aka.ms/vs/16/release/vc_redist.x64.exe" -OutFile "$ArtifactsDir\vc_redist.x64.exe"
Invoke-WebRequest-WithRetry -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile "$ArtifactsDir\vc_redist.x64.exe"
& $ArtifactsDir\vc_redist.x64.exe /install /passive | Write-Verbose
}
}
Expand Down

0 comments on commit efbe1df

Please sign in to comment.