Skip to content

Commit

Permalink
direct call for prog array, add spd file (#3816)
Browse files Browse the repository at this point in the history
  • Loading branch information
saxena-anurag authored Sep 7, 2024
1 parent e4d425c commit 99c4e48
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ebpfcore/EbpfCore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<Link>
<AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\ndis.lib;$(DDK_LIB_PATH)\wdmsec.lib;$(DDK_LIB_PATH)\fwpkclnt.lib;$(SDK_LIB_PATH)\uuid.lib;$(DDK_LIB_PATH)\netio.lib;$(DDK_LIB_PATH)\ksecdd.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/spdin:$(SolutionDir)spd\ebpfcore.spd %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/spgo /spdin:$(SolutionDir)spd\ebpfcore.spd %(AdditionalOptions)</AdditionalOptions>
</Link>
<DriverSign>
<FileDigestAlgorithm>SHA256</FileDigestAlgorithm>
Expand All @@ -144,7 +144,7 @@
<Link>
<AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\ntoskrnl.lib;$(DDK_LIB_PATH)\ndis.lib;$(DDK_LIB_PATH)\wdmsec.lib;$(DDK_LIB_PATH)\fwpkclnt.lib;$(SDK_LIB_PATH)\uuid.lib;$(DDK_LIB_PATH)\netio.lib;$(DDK_LIB_PATH)\ksecdd.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/spdin:$(SolutionDir)spd\ebpfcore.spd %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/spgo /spdin:$(SolutionDir)spd\ebpfcore.spd %(AdditionalOptions)</AdditionalOptions>
</Link>
<DriverSign>
<FileDigestAlgorithm>SHA256</FileDigestAlgorithm>
Expand Down
9 changes: 6 additions & 3 deletions libs/execution_context/ebpf_maps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2540,15 +2540,18 @@ ebpf_map_get_program_from_entry(_Inout_ ebpf_map_t* map, size_t key_size, _In_re
return NULL;
}
ebpf_map_type_t type = map->ebpf_map_definition.type;
if (ebpf_map_metadata_tables[type].get_object_from_entry == NULL) {
// This function should be invoked only for BPF_MAP_TYPE_PROG_ARRAY.
// We can bypass the metadata table lookup and directly call the function.
if (type != BPF_MAP_TYPE_PROG_ARRAY) {
EBPF_LOG_MESSAGE_UINT64(
EBPF_TRACELOG_LEVEL_ERROR,
EBPF_TRACELOG_KEYWORD_MAP,
"ebpf_map_get_program_from_entry not supported on map",
map->ebpf_map_definition.type);
type);
return NULL;
}
return (ebpf_program_t*)ebpf_map_metadata_tables[type].get_object_from_entry(map, key);

return (ebpf_program_t*)_get_object_from_array_map_entry(map, key);
}

_Must_inspect_result_ ebpf_result_t
Expand Down
Binary file added spd/EbpfCore.spd
Binary file not shown.

0 comments on commit 99c4e48

Please sign in to comment.