Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux XDP support #3849

Merged
merged 179 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 131 commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
420590b
built on Linux
ami-GS May 14, 2023
d63fd7f
ne files
ami-GS May 14, 2023
8cb383d
renaming
ami-GS May 14, 2023
a32d79b
split socket funcs
ami-GS May 14, 2023
ba2b925
refactor from win
ami-GS May 14, 2023
7667acc
build from linux
ami-GS May 14, 2023
5cfd379
more on linux
ami-GS May 14, 2023
05d191a
rename and generate
ami-GS May 14, 2023
11773d7
use libbpf
ami-GS May 19, 2023
7e71548
oops
ami-GS May 19, 2023
2d79d2e
rebase and add new member
ami-GS May 20, 2023
2ca3399
unify CxPlatTryAddSocket
ami-GS May 21, 2023
74ab9cb
pass datapath tests
ami-GS Jun 4, 2023
cf46e48
integrate Ubuntu 22.04 default libbpf v0.5.0
ami-GS Jun 6, 2023
ef8bd89
temporally
ami-GS Jun 27, 2023
8647673
multithread. all test passed
ami-GS Jul 5, 2023
1f2b3fd
secnetperf works
Jul 22, 2023
3483760
update build scripts
ami-GS Sep 11, 2023
b4656a4
nit update
ami-GS Sep 11, 2023
b3805f0
add duonic installer script for linux
ami-GS Sep 11, 2023
3ae0c0a
add xdp-tools directory
ami-GS Sep 11, 2023
1b74349
Merge commit '707c1fab' into dev/daiki/xdp_split_functional
ami-GS Sep 11, 2023
008ab54
Merge commit '88f0269' into dev/daiki/xdp_split_functional
ami-GS Sep 11, 2023
20961da
Merge commit 'dc64ccb47adf847d01f171bd3ccab1818b5d92d8' into dev/daik…
ami-GS Sep 12, 2023
17d9fa0
Merge commit 'f596ae5313a3b925556890482a2839a81c9d0392' into dev/daik…
ami-GS Sep 12, 2023
9a6bcae
Merge commit 'b6633eace10ed493cb234f86e18cc6d9d7526417' into dev/daik…
ami-GS Sep 12, 2023
a2c7477
Merge commit '8af9c3b214e83ea3146f88c072a0220a22a48ee6' into dev/daik…
ami-GS Sep 12, 2023
846aa31
Merge commit 'c885d5f1fdab56a8630aa1ec8a0b0bc41da291ca' into dev/daik…
ami-GS Sep 12, 2023
59aa678
Merge commit 'e6d504407e3a0e739d3da4c3393da43af61ae69f' into dev/daik…
ami-GS Sep 12, 2023
170279d
cleanup
ami-GS Sep 12, 2023
aa8f0d9
fix Windows build
ami-GS Sep 12, 2023
457dd4a
fix windows xdp build
ami-GS Sep 12, 2023
df4c7bd
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Sep 13, 2023
1ffded4
add Github action
ami-GS Sep 13, 2023
d57341d
nit fix
ami-GS Sep 13, 2023
421ea69
fix dependencies for Install-DuoNic
ami-GS Sep 13, 2023
c57ee78
add udpate
ami-GS Sep 13, 2023
ee0e042
add linux xdp dependencies to docker file
ami-GS Sep 15, 2023
a744683
fix installation script
ami-GS Sep 15, 2023
7dc44cd
initialize submodules/xdp-tools recursively
ami-GS Sep 21, 2023
b5a846b
Merge commit 'f9d26ac' into dev/daiki/xdp_split_functional
ami-GS Mar 6, 2024
027e886
Merge commit 'ae3db5cd991ea872efcf9e32dbe63f4f203245af' into dev/daik…
ami-GS Mar 14, 2024
2f1687f
Merge commit '284738a861272c63f31d900c490e9d5e856c8ac2' into dev/daik…
ami-GS Mar 14, 2024
3d1e986
Merge commit '4ef3731d82757451f9b62df0e7b41f32c87a1392' into dev/daik…
ami-GS Mar 14, 2024
6cf52f4
Merge commit '649f971b1bcce59ce0aba2d30a199d19dd91a4d2' into dev/daik…
ami-GS Mar 14, 2024
2f21a23
Merge commit '8e1eb1a74b6baed0af7dad899b31baf970051d26' into dev/daik…
ami-GS Mar 14, 2024
f569699
Merge commit '6e1c3d6af6ecade0979ec3430221c8920e562e91' into dev/daik…
ami-GS Mar 14, 2024
a122ae7
Merge commit 'fe9c2971a3abb432f92fff86664f1f131fe728b1' into dev/daik…
ami-GS Mar 14, 2024
bbe0af7
Merge commit 'e73ce1082364c697f89bfaf81c67b3158b9987c0' into dev/daik…
ami-GS Mar 14, 2024
e803c64
Merge commit '9483184dd39559f20daf57f95fdbcb14c367ff01' into dev/daik…
ami-GS Mar 14, 2024
6dd87ff
Merge commit 'cacfccae195ab36f91fd7e2c27ab56a863935ba3' into dev/daik…
ami-GS Mar 15, 2024
1dd8e52
temporal fix
ami-GS Mar 15, 2024
23b7b06
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Mar 18, 2024
b3743dc
make XDP optional
ami-GS Mar 19, 2024
f34a3e8
use ShutdownSqe
ami-GS Mar 19, 2024
560730b
fix yaml files
ami-GS Mar 20, 2024
8c8676f
remove gcc-multilib and include explicitly
ami-GS Mar 21, 2024
d69e762
fix tcp socket to allocate raw
ami-GS Mar 21, 2024
943d91f
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Mar 22, 2024
649b948
install xdp deps for linux
ami-GS Mar 22, 2024
d7a50b4
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Mar 22, 2024
a2b332e
libxdp bug workaround
ami-GS Mar 23, 2024
baf452e
oops
ami-GS Mar 23, 2024
1ff6ba3
fix idempotency and add one more dep
ami-GS Mar 23, 2024
29f9898
TODO: remove this
ami-GS Mar 23, 2024
eab2f7f
enable x86_64 and Ubuntu22.04
ami-GS Mar 24, 2024
1802e4e
fix type mismatch of uint16_t and UINT16
ami-GS Mar 25, 2024
b4c7ce6
add aarch64
ami-GS Mar 25, 2024
e375786
fix
ami-GS Mar 25, 2024
35b63f1
use flag
ami-GS Mar 25, 2024
c48bdbb
change arch check and file copy
ami-GS Mar 25, 2024
92a0b8c
fix static build and android
ami-GS Mar 25, 2024
c074126
update clog
ami-GS Mar 25, 2024
05d86a8
clog fix
ami-GS Mar 25, 2024
7999808
fix Clang link issue
ami-GS Mar 25, 2024
063f325
fix CodeCheck and prepare-machine for build
ami-GS Mar 25, 2024
bdd0161
disable ANDROID for xdp
ami-GS Mar 26, 2024
cdaf797
fix clog
ami-GS Mar 26, 2024
d1639dd
Support XDP from 'test.ps1 -UseXdp'
ami-GS Mar 26, 2024
dd6a74d
link libxdp from artifact
ami-GS Mar 26, 2024
5acb167
fix dependency
ami-GS Mar 26, 2024
671e112
fix dep
ami-GS Mar 26, 2024
1d69ad9
update xdp-tools to v1.4.2
ami-GS Mar 26, 2024
ebb21b9
fix runtime deps
ami-GS Mar 26, 2024
7106913
fix deps
ami-GS Mar 27, 2024
8fa7f5c
Fix Umem addressing and make Rx path async to efficiently fill FQ
ami-GS Mar 27, 2024
2983028
fix CodeQL analyze deps
ami-GS Mar 28, 2024
e3be961
fix Analyze
ami-GS Mar 28, 2024
7f68f6e
fix analyze
ami-GS Mar 28, 2024
d3c7eb6
linux xdp to use sudo
ami-GS Mar 28, 2024
2100f5e
change 'if' order
ami-GS Mar 28, 2024
360c28a
path fix?
ami-GS Mar 28, 2024
d434b3d
sudo pwsh
ami-GS Mar 28, 2024
89a361c
add retry for xsk_socket__create when returns -EBUSY
ami-GS Mar 29, 2024
aa8cf57
cleanup xdp program before running
ami-GS Mar 29, 2024
70d4622
Fix cargo build --all
ami-GS Mar 29, 2024
5d9b1e8
fix cargo test dynamic linking
ami-GS Mar 31, 2024
9490d94
remove Sanitize for initial commit
ami-GS Mar 31, 2024
d17770c
generate artifact
ami-GS Mar 31, 2024
e30e083
fix yml syntax issue
ami-GS Apr 1, 2024
19f7abc
fix CodeQl Analysys
ami-GS Apr 1, 2024
3cae069
forget to add Partition declaration
ami-GS Apr 1, 2024
e694653
Use Rundown to wait for deleting socket before binding next
ami-GS Apr 2, 2024
2c41090
fix Rundown for all xdp socket
ami-GS Apr 2, 2024
50844d2
Fix EBUSY issue when binding xdp socket
ami-GS Apr 3, 2024
c9fd1e3
explictly disable port sharing test
ami-GS Apr 3, 2024
90f81b6
refactoring and cleanup
ami-GS Apr 4, 2024
d64dbd1
fix pipeline. else for normal linux socket
ami-GS Apr 4, 2024
02ffcca
Fix cargo linking issue?
ami-GS Apr 4, 2024
ed95167
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Apr 4, 2024
10301b3
disable xdp for cargo build
ami-GS Apr 5, 2024
06acce7
fix codeql
ami-GS Apr 5, 2024
2d17796
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Apr 5, 2024
d8d122b
rollback build.rs
ami-GS Apr 5, 2024
4c878e0
fix package runtime link and codeql
ami-GS Apr 5, 2024
faedae1
wrap packet dump function to DEBUG macro
ami-GS Apr 5, 2024
b1633e6
check dependency
ami-GS Apr 5, 2024
0bf636f
another check
ami-GS Apr 5, 2024
293f8bd
leave only LD_LIBRARY_PATH
ami-GS Apr 5, 2024
6b49bb6
iterate attach mode
ami-GS Apr 5, 2024
8aa3402
fix codeql
ami-GS Apr 5, 2024
d56ce17
add IP address check in XDP prog
ami-GS Apr 8, 2024
8c8f463
break is enough & avoid compiler bug
ami-GS Apr 8, 2024
c305f11
fix CodeCheck
ami-GS Apr 8, 2024
0222e70
Fix use of RxHeadroom
ami-GS Apr 8, 2024
606c3b8
fix umem leak when failed to initialize
ami-GS Apr 8, 2024
0c782c8
use pool alloc for Interface
ami-GS Apr 8, 2024
51cdebc
fix ipv4 check
ami-GS Apr 8, 2024
d3dc703
remove workaround
ami-GS Apr 9, 2024
b4decc6
cleanup. from snake case to pascal case
ami-GS Apr 9, 2024
d1588b6
fix clog
ami-GS Apr 9, 2024
6cd580c
try ubuntu20.04 and enable stress test
ami-GS Apr 9, 2024
706e4da
few fix of stress test yml
ami-GS Apr 10, 2024
56a7fb1
integrate package libxdp linking
ami-GS Apr 10, 2024
600ad66
fix RX parse error case
ami-GS Apr 10, 2024
ca7bde5
disable ubuntu20.04
ami-GS Apr 12, 2024
4569402
remove 2 env variable to run
ami-GS Apr 13, 2024
23a9291
add document
ami-GS Apr 13, 2024
f96feab
fix ForBuild && clog
ami-GS Apr 13, 2024
4b829ce
stop installing deps on Ubuntu 20.04
ami-GS Apr 13, 2024
7ce0f8d
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Apr 15, 2024
31d817f
fix build
ami-GS Apr 16, 2024
1d43c09
fix libc6-dev-i386 side effect
ami-GS Apr 16, 2024
ae95b04
Add one more dependency (libzstd) for static build
ami-GS Apr 16, 2024
e27243f
new line fix
ami-GS Apr 16, 2024
05376dc
always install libc6-dev-i386
ami-GS Apr 16, 2024
6c792c8
fix install order
ami-GS Apr 16, 2024
561044e
fix CMakeLists.txt to cover qns.Dockerfile case
ami-GS Apr 16, 2024
2f4f171
remove env var dep, update doc
ami-GS Apr 16, 2024
c88fe20
fix stress.yml
ami-GS Apr 16, 2024
7f6fbd0
add env var for xdp knob and fix stress
ami-GS Apr 17, 2024
2b25b39
fix stress
ami-GS Apr 17, 2024
d31a0f5
update clog
ami-GS Apr 17, 2024
57bfa9f
update doc
ami-GS Apr 17, 2024
714a655
Fix doc appearance and words
ami-GS Apr 17, 2024
6768679
add UseXdp
ami-GS Apr 17, 2024
f0dab8b
Update docs/BUILD.md
ami-GS Apr 19, 2024
bbe0a5a
Update docs/BUILD.md
ami-GS Apr 19, 2024
ad74b33
use SKB mode for now
ami-GS Apr 19, 2024
af18bef
move Linux XDP logging to TSG.md
ami-GS Apr 19, 2024
9a7acdf
stop warning print from libxdp/libbpf
ami-GS Apr 19, 2024
14a8fd7
move CxPlat definitions to each plat
ami-GS Apr 19, 2024
e961a3b
initial commit
ami-GS Apr 21, 2024
8ecc440
common xdp utilities
ami-GS Apr 21, 2024
5f1da03
move sudo inside scripts
ami-GS Apr 22, 2024
6d2339c
fix comments
ami-GS Apr 22, 2024
037ea20
Merge branch 'dev/daiki/xdp_merge' into dev/daiki/xdp_split_functional
ami-GS Apr 22, 2024
c87e720
fix clog
ami-GS Apr 22, 2024
ed69f0a
Merge branch 'main' into dev/daiki/xdp_split_functional
ami-GS Apr 22, 2024
e560f3f
fix ifdef syntax
ami-GS Apr 22, 2024
2cfa516
fix annotations
ami-GS Apr 22, 2024
9cd42d0
all arch to build dataptah_xplat.c
ami-GS Apr 22, 2024
17825c0
fix mac build
ami-GS Apr 22, 2024
74eed9f
fix lisence of ebpf prog
ami-GS Apr 22, 2024
eebc505
fix spin.ps1 to propagate parameter
ami-GS Apr 22, 2024
4eda469
Ether and IPv6 was not set appropriately
ami-GS Apr 24, 2024
8924bed
Update docs/TSG.md
nibanks Apr 25, 2024
1703841
remove warning supression
ami-GS Apr 25, 2024
98a1222
remove BuildLibXdpFromSource
ami-GS Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build-reuse-unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ on:
required: false
default: ''
type: string
xdp:
required: false
default: ''
type: string
sanitize:
required: false
default: ''
Expand Down Expand Up @@ -95,7 +99,7 @@ jobs:
chown -R $(id -u):$(id -g) $PWD
- name: Prepare Machine
shell: pwsh
run: scripts/prepare-machine.ps1 ${{ inputs.plat == 'linux' && '-ForContainerBuild' || '-ForBuild' }} -Tls ${{ inputs.tls }}
run: scripts/prepare-machine.ps1 ${{ inputs.plat == 'linux' && '-ForContainerBuild' || '-ForBuild' }} -Tls ${{ inputs.tls }} ${{ inputs.xdp }}
- name: Build For Test
if: inputs.build == '-Test'
shell: pwsh
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ jobs:
sudo apt-add-repository ppa:lttng/stable-2.13
sudo apt-get update
sudo apt-get install -y liblttng-ust-dev libnuma-dev
sudo apt-get install -y libnl-3-dev libnl-genl-3-dev libnl-route-3-dev zlib1g-dev zlib1g pkg-config m4 clang libpcap-dev libelf-dev
sudo apt-get -y install --no-install-recommends libc6-dev-i386
sudo sh scripts/install-powershell-docker.sh
sed -i '/BPF_CFLAGS += -I$(HEADER_DIR)/ { /${ARCH_INCLUDES}/! s|$| ${ARCH_INCLUDES}| }' submodules/xdp-tools/lib/libxdp/Makefile
mkdir build
cd build
cmake ..
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", systemcrypto: "-UseSystemOpenSSLCrypto", sanitize: "-Sanitize", build: "-Test" },
]
uses: ./.github/workflows/build-reuse-unix.yml
Expand All @@ -96,6 +97,7 @@ jobs:
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", xdp: "-UseXdp", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", systemcrypto: "-UseSystemOpenSSLCrypto", sanitize: "-Sanitize", build: "-Test" },
{ config: "Debug", plat: "windows", os: "windows-2019", arch: "x64", tls: "openssl", build: "-Test" },
{ config: "Debug", plat: "windows", os: "windows-2019", arch: "x64", tls: "openssl3", build: "-Test" },
Expand Down Expand Up @@ -142,13 +144,18 @@ jobs:
$ManifestPath = ".\src\manifest\MsQuicEtw.man"
wevtutil.exe um $ManifestPath
wevtutil.exe im $ManifestPath /rf:$($MsQuicDll) /mf:$($MsQuicDll)
- name: Test
if: matrix.vec.os == 'ubuntu-22.04' && matrix.vec.xdp == '-UseXdp'
shell: bash
timeout-minutes: 120
run: sudo pwsh scripts/test.ps1 -Config ${{ matrix.vec.config }} -Arch ${{ matrix.vec.arch }} -Tls ${{ matrix.vec.tls }} -OsRunner ${{ matrix.vec.os }} -GHA -LogProfile Full.Light -GenerateXmlResults ${{ matrix.vec.xdp }} ${{ matrix.vec.qtip }}
- name: Test
if: matrix.vec.os == 'WinServerPrerelease'
shell: pwsh
timeout-minutes: 120
run: scripts/test.ps1 -Config ${{ matrix.vec.config }} -Arch ${{ matrix.vec.arch }} -Tls ${{ matrix.vec.tls }} -GHA -LogProfile Full.Light -GenerateXmlResults ${{ matrix.vec.xdp }} ${{ matrix.vec.qtip }}
- name: Test
if: matrix.vec.os != 'WinServerPrerelease'
if: matrix.vec.os != 'WinServerPrerelease' && !(matrix.vec.os == 'ubuntu-22.04' && matrix.vec.xdp == '-UseXdp')
shell: pwsh
timeout-minutes: 120
run: scripts/test.ps1 -Config ${{ matrix.vec.config }} -Arch ${{ matrix.vec.arch }} -Tls ${{ matrix.vec.tls }} -OsRunner ${{ matrix.vec.os }} -GHA -LogProfile Full.Light -GenerateXmlResults ${{ matrix.vec.xdp }} ${{ matrix.vec.qtip }}
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
[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
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ elseif (APPLE)
set(CX_PLATFORM "darwin")
elseif (UNIX)
set(CX_PLATFORM "linux")
find_program(LSB_RELEASE lsb_release)
execute_process(COMMAND ${LSB_RELEASE} -rs
OUTPUT_VARIABLE UBUNTU_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
message(STATUS "QUIC Platform: ${CX_PLATFORM}")

Expand Down Expand Up @@ -434,13 +439,13 @@ if (NOT MSVC AND NOT APPLE AND NOT ANDROID)
endif()
endif()

if(WIN32)
if (CMAKE_GENERATOR_PLATFORM STREQUAL "")
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
else()
string(TOLOWER ${CMAKE_GENERATOR_PLATFORM} SYSTEM_PROCESSOR)
endif()
if (CMAKE_GENERATOR_PLATFORM STREQUAL "")
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
else()
string(TOLOWER ${CMAKE_GENERATOR_PLATFORM} SYSTEM_PROCESSOR)
endif()

if(WIN32)
# Generate the MsQuicEtw header file.
file(MAKE_DIRECTORY ${QUIC_BUILD_DIR}/inc)

Expand Down
1 change: 1 addition & 0 deletions scripts/DotNetTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if ($IsWindows) {

# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent
$env:LD_LIBRARY_PATH = $RootArtifactDir

dotnet build (Join-Path $RootDir src cs)
dotnet run --project (Join-Path $RootDir src cs tool) -- (Join-Path $RootArtifactDir $LibName)
5 changes: 3 additions & 2 deletions scripts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ fn main() {
config
.define("QUIC_ENABLE_LOGGING", logging_enabled)
.define("QUIC_TLS", "openssl")
.define("QUIC_OUTPUT_DIR", "../lib");
.define("QUIC_OUTPUT_DIR", "../lib")
.define("CARGO_BUILD", "on");

match target.as_str() {
"x86_64-apple-darwin" => config
Expand All @@ -34,4 +35,4 @@ fn main() {
let dst = config.build();
let lib_path = Path::join(Path::new(&dst), Path::new(path_extra));
println!("cargo:rustc-link-search=native={}", lib_path.display());
}
}
ami-GS marked this conversation as resolved.
Show resolved Hide resolved
102 changes: 102 additions & 0 deletions scripts/duonic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash

# Set the number of NIC pairs
NumNicPairs=1

if [ "$1" == "install" ]; then
# Configure each pair separately with its own hard-coded subnet, ie 192.168.x.0/24 and fc00::x/112
for ((i=1; i<=NumNicPairs; i++)); do
echo "Plumbing IP config for pair $i"

# Generate the "ID" of the NICs, eg 1 and 2 for the first pair
nic1="duo$((i * 2 - 1))"
nic2="duo$((i * 2))"

# Create veth pair
sudo ip link add ${nic1} type veth peer name ${nic2}

# Set the veth interfaces up
sudo ip link set ${nic1} up
sudo ip link set ${nic2} up

# Assign IPv4 addresses
sudo ip addr add 192.168.${i}.11/24 dev ${nic1}
sudo ip addr add 192.168.${i}.12/24 dev ${nic2}

# Assign IPv6 addresses
sudo ip -6 addr add fc00::${i}:11/112 dev ${nic1}
sudo ip -6 addr add fc00::${i}:12/112 dev ${nic2}

# Add static neighbor entries (ARP)
sudo ip neigh add 192.168.${i}.12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1} nud permanent
sudo ip neigh add 192.168.${i}.11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2} nud permanent

# Add static neighbor entries (IPv6)
sudo ip -6 neigh add fc00::${i}:12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1} nud permanent
sudo ip -6 neigh add fc00::${i}:11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2} nud permanent

# Configure routing rules for IPv4
sudo ip route add 192.168.${i}.12/32 dev ${nic1} metric 0
sudo ip route add 192.168.${i}.11/32 dev ${nic2} metric 0



# Configure routing rules for IPv6
sudo ip -6 route add fc00::${i}:12/128 dev ${nic1} metric 0
sudo ip -6 route add fc00::${i}:11/128 dev ${nic2} metric 0

# Configure firewall rules for IPv4
sudo iptables -A INPUT -p all -s 192.168.${i}.0/24 -i ${nic1} -j ACCEPT
sudo iptables -A INPUT -p all -s 192.168.${i}.0/24 -i ${nic2} -j ACCEPT

# Configure firewall rules for IPv6
sudo ip6tables -A INPUT -p all -s fc00::${i}:0/112 -i ${nic1} -j ACCEPT
sudo ip6tables -A INPUT -p all -s fc00::${i}:0/112 -i ${nic2} -j ACCEPT

sleep 2
sudo ip route change 192.168.${i}.12 dev duo1 src 192.168.${i}.11
sudo ip route change 192.168.${i}.11 dev duo2 src 192.168.${i}.12

sudo ip -6 route change fc00::${i}:12 dev duo1 src fc00::${i}:11
sudo ip -6 route change fc00::${i}:11 dev duo2 src fc00::${i}:12
done
elif [ "$1" == "uninstall" ]; then
# Cleanup each pair separately
for ((i=1; i<=NumNicPairs; i++)); do
echo "Cleaning up pair $i"

# Generate the "ID" of the NICs, eg 1 and 2 for the first pair
nic1="duo$((i * 2 - 1))"
nic2="duo$((i * 2))"

# Delete firewall rules for IPv4
sudo iptables -D INPUT -p all -s 192.168.${i}.0/24 -i ${nic1} -j ACCEPT
sudo iptables -D INPUT -p all -s 192.168.${i}.0/24 -i ${nic2} -j ACCEPT

# Delete firewall rules for IPv6
sudo ip6tables -D INPUT -p all -s fc00::${i}:0/112 -i ${nic1} -j ACCEPT
sudo ip6tables -D INPUT -p all -s fc00::${i}:0/112 -i ${nic2} -j ACCEPT

# Remove routing rules for IPv4
sudo ip route del 192.168.${i}.12/32 dev ${nic1}
sudo ip route del 192.168.${i}.11/32 dev ${nic2}

# Remove routing rules for IPv6
sudo ip -6 route del fc00::${i}:12/128 dev ${nic1}
sudo ip -6 route del fc00::${i}:11/128 dev ${nic2}

# Remove static neighbor entries (ARP)
sudo ip neigh del 192.168.${i}.12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1}
sudo ip neigh del 192.168.${i}.11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2}

# Remove static neighbor entries (IPv6)
sudo ip -6 neigh del fc00::${i}:12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1}
sudo ip -6 neigh del fc00::${i}:11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2}

# Remove the veth pair
sudo ip link delete ${nic1}
done
else
echo "Usage: $0 {install|uninsatll}"
exit 1
fi
32 changes: 26 additions & 6 deletions scripts/prepare-machine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,18 @@ function Uninstall-Xdp {

# Installs DuoNic from the CoreNet-CI repo.
function Install-DuoNic {
if (!$IsWindows) { return } # Windows only
# Install the DuoNic driver.
Write-Host "Installing DuoNic driver"
$DuoNicPath = Join-Path $SetupPath duonic
$DuoNicScript = (Join-Path $DuoNicPath duonic.ps1)
if (!(Test-Path $DuoNicScript)) { Write-Error "Missing file: $DuoNicScript" }
Invoke-Expression "cmd /c `"pushd $DuoNicPath && pwsh duonic.ps1 -Install`""
if ($IsWindows) {
Write-Host "Installing DuoNic driver"
$DuoNicPath = Join-Path $SetupPath duonic
$DuoNicScript = (Join-Path $DuoNicPath duonic.ps1)
if (!(Test-Path $DuoNicScript)) { Write-Error "Missing file: $DuoNicScript" }
Invoke-Expression "cmd /c `"pushd $DuoNicPath && pwsh duonic.ps1 -Install`""
} elseif ($IsLinux) {
Write-Host "Creating DuoNic endpoints"
$DuoNicScript = Join-Path $PSScriptRoot "duonic.sh"
Invoke-Expression "sudo bash $DuoNicScript install"
}
}

function Update-Path($NewPath) {
Expand Down Expand Up @@ -468,6 +473,12 @@ if ($ForBuild -or $ForContainerBuild) {
}

git submodule update --jobs=8
if ($IsLinux) {
Write-Host "Initializing xdp-tools submodules"
git submodule update --init --recursive --jobs=8 submodules/xdp-tools
# temporal workaround for libxdp v1.4.0
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 @@ -504,6 +515,10 @@ if ($IsLinux) {
sudo apt-get install -y ruby ruby-dev rpm
sudo gem install public_suffix -v 4.0.7
sudo gem install fpm

# XDP dependencies
sudo apt-get -y install libnl-3-dev libnl-genl-3-dev libnl-route-3-dev zlib1g-dev zlib1g pkg-config m4 clang libpcap-dev libelf-dev
sudo apt-get -y install --no-install-recommends libc6-dev-i386
}

if ($ForTest) {
Expand All @@ -512,6 +527,11 @@ if ($IsLinux) {
sudo apt-get install -y lttng-tools
sudo apt-get install -y liblttng-ust-dev
sudo apt-get install -y gdb
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
Install-DuoNic
}

# Enable core dumps for the system.
Write-Host "Setting core dump size limit"
Expand Down
16 changes: 11 additions & 5 deletions scripts/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,23 @@ if ($CodeCoverage) {
}
}

if ($UseXdp) {
# Helper for XDP usage
$DuoNic = $true
}

$BuildConfig = & (Join-Path $PSScriptRoot get-buildconfig.ps1) -Tls $Tls -Arch $Arch -ExtraArtifactDir $ExtraArtifactDir -Config $Config

$Tls = $BuildConfig.Tls
$Arch = $BuildConfig.Arch
$RootArtifactDir = $BuildConfig.ArtifactsDir

if ($UseXdp) {
# Helper for XDP usage
$DuoNic = $true
if ($IsLinux) {
# Temporal feature flag for Linux
$env:MSQUIC_ENABLE_XDP = 1
$env:LIBXDP_OBJECT_PATH = $RootArtifactDir
$env:MSQUIC_XDP_OBJECT_PATH = $RootArtifactDir
}
}

# Root directory of the project.
$RootDir = Split-Path $PSScriptRoot -Parent

Expand Down
Loading
Loading