From 98a1222c04af997272b6d9f71a598c1b4e03211d Mon Sep 17 00:00:00 2001 From: ami-GS <1991.daiki@gmail.com> Date: Thu, 25 Apr 2024 09:41:53 -0700 Subject: [PATCH] remove BuildLibXdpFromSource --- .gitmodules | 4 --- docs/BUILD.md | 10 +------ scripts/build.ps1 | 8 +---- scripts/prepare-machine.ps1 | 19 +++--------- src/platform/CMakeLists.txt | 58 ++++--------------------------------- submodules/xdp-tools | 1 - 6 files changed, 11 insertions(+), 89 deletions(-) delete mode 160000 submodules/xdp-tools diff --git a/.gitmodules b/.gitmodules index 1c2da71357..a675f72114 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,10 +12,6 @@ [submodule "submodules/clog"] path = submodules/clog url = https://github.com/microsoft/CLOG.git -[submodule "submodules/xdp-tools"] - path = submodules/xdp-tools - url = https://github.com/xdp-project/xdp-tools.git - branch = v1.4.2 [submodule "submodules/xdp-for-windows"] path = submodules/xdp-for-windows url = https://github.com/microsoft/xdp-for-windows.git diff --git a/docs/BUILD.md b/docs/BUILD.md index 30f67301d3..27ea9d77dc 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -219,7 +219,7 @@ sudo MSQUIC_ENABLE_XDP=1 ./artifacts/bin/linux/x64_Debug_openssl3/msquictest --d - Q: Is this workload really running on XDP? A: If you have the `xdp-dump` command, try using `sudo xdp-dump --list-interfaces`. The `xdp_main` function is located in `src/platform/datapath_raw_xdp_linux_kern.c`. If none of the interfaces load the XDP program, something must be wrong. ``` -$ sudo ./submodules/xdp-tools/xdp-dump/xdpdump --list-interfaces +$ sudo ./xdp-tools/xdp-dump/xdpdump --list-interfaces Interface Prio Program name Mode ID Tag Chain actions -------------------------------------------------------------------------------------- lo @@ -233,14 +233,6 @@ duo1 xdp_dispatcher native 608225 4d7e87c0d30db711 - Q: Is Ubuntu 20.04LTS supported? A: Not officially, but you can still **build** it by running `apt-get upgrade linux-libc-dev`. Please be aware of potential side effects from the **upgrade**. -- Q: Can I build libxdp/libbpf from source? -A: Yes. Try below. We don't use CI/CD for the source version, but we saw xdp-tools v1.4.2 from source works. -```sh -pwsh ./scripts/prepare-machine.ps1 -BuildLibXdpFromSource -pwsh ./scripts/build.ps1 -BuildLibXdpFromSource -# try using ldd whether your libxdp.so/libbpf.so are linked -# When running binary, set LIBXDP_SKIP_DISPATCHER=1 or LIBXDP_OBJECT_PATH=${where xdp-dispatcher.o is located} -``` ### macOS The build needs CMake and compiler. diff --git a/scripts/build.ps1 b/scripts/build.ps1 index fc2d57a16a..531a513f36 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -212,10 +212,7 @@ param ( [switch]$OneBranch = $false, [Parameter(Mandatory = $false)] - [string]$ToolchainFile = "", - - [Parameter(Mandatory = $false)] - [switch]$BuildLibXdpFromSource = $false + [string]$ToolchainFile = "" ) Set-StrictMode -Version 'Latest' @@ -406,9 +403,6 @@ function CMake-Generate { "arm64" { $env:PKG_CONFIG_PATH="$SysRoot/usr/lib/aarch64-linux-gnu/pkgconfig" } } } - if ($BuildLibXdpFromSource) { - $Arguments += " -DQUIC_BUILD_LIBXDP_FROM_SOURCE=on" - } } if ($ToolchainFile -ne "") { $Arguments += " -DCMAKE_TOOLCHAIN_FILE=""$ToolchainFile""" diff --git a/scripts/prepare-machine.ps1 b/scripts/prepare-machine.ps1 index ca7eaea681..08631fa011 100644 --- a/scripts/prepare-machine.ps1 +++ b/scripts/prepare-machine.ps1 @@ -86,10 +86,7 @@ param ( [switch]$DisableTest, [Parameter(Mandatory = $false)] - [switch]$InstallCoreNetCiDeps, - - [Parameter(Mandatory = $false)] - [switch]$BuildLibXdpFromSource = $false + [switch]$InstallCoreNetCiDeps ) # Admin is required because a lot of things are installed to the local machine @@ -476,12 +473,6 @@ if ($ForBuild -or $ForContainerBuild) { } git submodule update --jobs=8 - if ($IsLinux -and $BuildLibXdpFromSource) { - Write-Host "Initializing xdp-tools submodules" - git submodule update --init --recursive --jobs=8 submodules/xdp-tools - # temporal workaround for libxdp v1.4.2 - sed -i '/BPF_CFLAGS += -I$(HEADER_DIR)/ { /${ARCH_INCLUDES}/! s|$| ${ARCH_INCLUDES}| }' submodules/xdp-tools/lib/libxdp/Makefile - } } if ($InstallCoreNetCiDeps) { Download-CoreNet-Deps } @@ -536,11 +527,9 @@ if ($IsLinux) { sudo apt-get install -y liblttng-ust-dev sudo apt-get install -y gdb if ((bash -c 'lsb_release -r') -match '22.04') { - if (!$BuildLibXdpFromSource) { - sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y - sudo apt-get update -y - sudo apt-get install -y libxdp1 libbpf1 - } + sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y + sudo apt-get update -y + sudo apt-get install -y libxdp1 libbpf1 sudo apt-get install -y libnl-3-200 libnl-route-3-200 libnl-genl-3-200 if ($UseXdp) { sudo apt-get -y install iproute2 iptables diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index caf8db8f89..5b01fdc891 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -71,60 +71,12 @@ if("${CX_PLATFORM}" STREQUAL "windows") elseif(LINUX_XDP_ENABLED) find_library(NL_LIB nl-3) find_library(NL_ROUTE_LIB nl-route-3) - if (NOT QUIC_BUILD_LIBXDP_FROM_SOURCE) - target_include_directories(platform PRIVATE /usr/include/xdp) - target_include_directories(platform PRIVATE /usr/include/bpf) - set(XDP_PROG_INCLUDE_DIR "-I/usr/include/bpf") + find_library(XDP_LIB libxdp.so) + find_library(BPF_LIB libbpf.so) + target_include_directories(platform PRIVATE /usr/include/xdp) + target_include_directories(platform PRIVATE /usr/include/bpf) + set(XDP_PROG_INCLUDE_DIR "-I/usr/include/bpf") - find_library(XDP_LIB libxdp.so) - find_library(BPF_LIB libbpf.so) - else () - # XDP Tools and libbpf paths - set(XDP_TOOLS_DIR ${PROJECT_SOURCE_DIR}/submodules/xdp-tools) - - # Include directories for libxdp.so and libbpf.so - target_include_directories(platform PRIVATE ${XDP_TOOLS_DIR}/headers/xdp) # libxdp.h, xsk.h - target_include_directories(platform PRIVATE ${XDP_TOOLS_DIR}/lib/libbpf/src) # libbpf.h - set(XDP_PROG_INCLUDE_DIR "-I${PROJECT_SOURCE_DIR}/submodules/xdp-tools/lib/libbpf/src;-I${PROJECT_SOURCE_DIR}/submodules/xdp-tools/lib") - - set(LIBXDP_DIR ${XDP_TOOLS_DIR}/lib/libxdp) - set(LIBBPF_DIR ${XDP_TOOLS_DIR}/lib/libbpf/src) - - # Custom command to build XDP Tools - add_custom_command( - OUTPUT ${LIBXDP_DIR}/libxdp.so ${LIBBPF_DIR}/libbpf.so ${QUIC_OUTPUT_DIR}/xdp-dispatcher.o - COMMAND ./configure - COMMAND make - # Experimental! - # xdp-dispatcher.o need to be placed at - # - "./" (libxdp Debug build) - # - "/usr/lib/bpf" - # - Specified by LIBXDP_OBJECT_PATH - COMMAND cp ${XDP_TOOLS_DIR}/lib/libxdp/xdp-dispatcher.o ${QUIC_OUTPUT_DIR}/ - WORKING_DIRECTORY ${XDP_TOOLS_DIR} - ) - - # Add custom target and make platform depend on it - add_custom_target(xdp_tools DEPENDS ${LIBXDP_DIR}/libxdp.so ${LIBBPF_DIR}/libbpf.so) - add_dependencies(platform xdp_tools) - - if (BUILD_SHARED_LIBS) - add_custom_target( - CopyLibsAndLinks ALL - COMMAND cp -P ${LIBXDP_DIR}/*.so* ${QUIC_OUTPUT_DIR}/ - COMMAND cp -P ${LIBBPF_DIR}/*.so* ${QUIC_OUTPUT_DIR}/ - DEPENDS xdp_tools - ) - set_target_properties(platform PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) - set_target_properties(platform PROPERTIES INSTALL_RPATH "${QUIC_OUTPUT_DIR}/libxdp.so;${QUIC_OUTPUT_DIR}/libbpf.so") - add_dependencies(platform CopyLibsAndLinks) - set(XDP_LIB ${QUIC_OUTPUT_DIR}/libxdp.so) - set(BPF_LIB ${QUIC_OUTPUT_DIR}/libbpf.so) - else() - set(XDP_LIB ${LIBXDP_DIR}/libxdp.so) # replaced to .a later - set(BPF_LIB ${LIBBPF_DIR}/libbpf.so) - endif() - endif() # building XDP program add_custom_command( OUTPUT ${QUIC_OUTPUT_DIR}/datapath_raw_xdp_kern.o diff --git a/submodules/xdp-tools b/submodules/xdp-tools deleted file mode 160000 index a8e8c7bb7a..0000000000 --- a/submodules/xdp-tools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a8e8c7bb7ab6447594a9feb52e51d05fc127d780