Skip to content

Commit

Permalink
remove BuildLibXdpFromSource
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-GS committed Apr 25, 2024
1 parent 1703841 commit 98a1222
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 89 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <No XDP program loaded!>
Expand All @@ -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.
Expand Down
8 changes: 1 addition & 7 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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"""
Expand Down
19 changes: 4 additions & 15 deletions scripts/prepare-machine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
58 changes: 5 additions & 53 deletions src/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion submodules/xdp-tools
Submodule xdp-tools deleted from a8e8c7

0 comments on commit 98a1222

Please sign in to comment.