Signed-off-by: Dave Thaler <dthaler@microsoft.com>

Co-authored-by: Alan Jowett <alanjo@microsoft.com>
This commit is contained in:
Dave Thaler 2022-04-14 07:31:26 -07:00 коммит произвёл GitHub
Родитель 42312e8d76
Коммит 1c2cae9e75
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 21 добавлений и 15 удалений

2
external/bpftool поставляемый

@ -1 +1 @@
Subproject commit 3aea5630b101c0145cd9728f179bd29fbcdfed0e
Subproject commit cf5b26a932ef0e83c742f525f2dd6e59ce03b12f

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

@ -5,5 +5,8 @@
typedef uint16_t __u16;
typedef uint32_t __u32;
typedef uint64_t __u64;
typedef int16_t __s16;
typedef int32_t __s32;
typedef int64_t __s64;
#define __SIZEOF_LONG_LONG__ 8 /* only x64 is supported */
#define __SIZEOF_LONG__ 4 /* only x64 is supported */

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

@ -117,7 +117,7 @@ enum bpf_prog_type
*
* **eBPF program prototype:** \ref xdp_hook_t
*
* **Attach type(s):** \ref BPF_ATTACH_TYPE_XDP
* **Attach type(s):** \ref BPF_XDP
*
* **Helpers available:** all helpers defined in bpf_helpers.h
*/
@ -178,7 +178,7 @@ enum bpf_attach_type
*
* **Program type:** \ref BPF_PROG_TYPE_XDP
*/
BPF_ATTACH_TYPE_XDP,
BPF_XDP,
/** @brief Attach type for handling socket bind() requests.
*

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

@ -51,7 +51,7 @@ _get_ebpf_attach_type(enum bpf_attach_type type)
// TODO(issue #223): read this mapping from the registry
switch (type) {
case BPF_ATTACH_TYPE_XDP:
case BPF_XDP:
attach_type = &EBPF_ATTACH_TYPE_XDP;
break;
case BPF_CGROUP_INET4_CONNECT:
@ -76,7 +76,7 @@ _get_bpf_attach_type(const ebpf_attach_type_t* type)
{
// TODO(issue #223): read this mapping from the registry
if (memcmp(type, &EBPF_ATTACH_TYPE_XDP, sizeof(*type)) == 0) {
return BPF_ATTACH_TYPE_XDP;
return BPF_XDP;
}
return BPF_ATTACH_TYPE_UNSPEC;
}
@ -451,7 +451,7 @@ libbpf_prog_type_by_name(const char* name, enum bpf_prog_type* prog_type, enum b
// TODO(issue #223): get info from registry.
if (memcmp(&program_type_uuid, &EBPF_PROGRAM_TYPE_XDP, sizeof(program_type_uuid)) == 0) {
*prog_type = BPF_PROG_TYPE_XDP;
*expected_attach_type = BPF_ATTACH_TYPE_XDP;
*expected_attach_type = BPF_XDP;
return 0;
}
if (memcmp(&program_type_uuid, &EBPF_PROGRAM_TYPE_BIND, sizeof(program_type_uuid)) == 0) {

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

@ -269,10 +269,10 @@ TEST_CASE("libbpf program attach", "[libbpf]")
enum bpf_attach_type type = bpf_program__get_expected_attach_type(program);
REQUIRE(type == BPF_ATTACH_TYPE_UNSPEC);
bpf_program__set_expected_attach_type(program, BPF_ATTACH_TYPE_XDP);
bpf_program__set_expected_attach_type(program, BPF_XDP);
type = bpf_program__get_expected_attach_type(program);
REQUIRE(type == BPF_ATTACH_TYPE_XDP);
REQUIRE(type == BPF_XDP);
bpf_link* link = bpf_program__attach(program);
REQUIRE(link != nullptr);
@ -1277,7 +1277,7 @@ TEST_CASE("libbpf_prog_type_by_name", "[libbpf]")
// Try a cross-platform type.
REQUIRE(libbpf_prog_type_by_name("xdp", &prog_type, &expected_attach_type) == 0);
REQUIRE(prog_type == BPF_PROG_TYPE_XDP);
REQUIRE(expected_attach_type == BPF_ATTACH_TYPE_XDP);
REQUIRE(expected_attach_type == BPF_XDP);
// Try a Windows-specific type.
REQUIRE(libbpf_prog_type_by_name("bind", &prog_type, &expected_attach_type) == 0);
@ -1287,7 +1287,7 @@ TEST_CASE("libbpf_prog_type_by_name", "[libbpf]")
// Try something that will fall back to the default.
REQUIRE(libbpf_prog_type_by_name("default", &prog_type, &expected_attach_type) == 0);
REQUIRE(prog_type == BPF_PROG_TYPE_XDP);
REQUIRE(expected_attach_type == BPF_ATTACH_TYPE_XDP);
REQUIRE(expected_attach_type == BPF_XDP);
}
TEST_CASE("libbpf_get_error", "[libbpf]")

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

@ -16,6 +16,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\external\bpftool\libbpf\src\hashmap.c" />
<ClCompile Include="..\..\external\bpftool\libbpf\src\libbpf.c" />
<ClCompile Include="..\..\external\bpftool\src\btf.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
@ -57,10 +58,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\external\bpftool\src\net.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\external\bpftool\src\net.c" />
<ClCompile Include="..\..\external\bpftool\src\netlink_dumper.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
@ -163,6 +161,7 @@
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<AdditionalDependencies>iphlpapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -179,6 +178,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<AdditionalDependencies>iphlpapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

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

@ -97,6 +97,9 @@
<ClCompile Include="..\..\external\bpftool\libbpf\src\hashmap.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\external\bpftool\libbpf\src\libbpf.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\external\bpftool\src\skeleton\pid_iter.h">