Skip to content

Commit 5052f34

Browse files
ami-GSami-GSnibanks
authored
Linux XDP support (#3849)
* built on Linux * ne files * renaming * split socket funcs * refactor from win * build from linux * more on linux * rename and generate * use libbpf * oops * rebase and add new member * unify CxPlatTryAddSocket * pass datapath tests * integrate Ubuntu 22.04 default libbpf v0.5.0 * temporally * multithread. all test passed * secnetperf works * update build scripts * nit update * add duonic installer script for linux * add xdp-tools directory * cleanup * fix Windows build * fix windows xdp build * add Github action * nit fix * fix dependencies for Install-DuoNic * add udpate * add linux xdp dependencies to docker file * fix installation script * initialize submodules/xdp-tools recursively * temporal fix * make XDP optional * use ShutdownSqe * fix yaml files * remove gcc-multilib and include explicitly * fix tcp socket to allocate raw * install xdp deps for linux * libxdp bug workaround * oops * fix idempotency and add one more dep * TODO: remove this * enable x86_64 and Ubuntu22.04 * fix type mismatch of uint16_t and UINT16 * add aarch64 * fix * use flag * change arch check and file copy * fix static build and android * update clog * clog fix * fix Clang link issue * fix CodeCheck and prepare-machine for build * disable ANDROID for xdp * fix clog * Support XDP from 'test.ps1 -UseXdp' * link libxdp from artifact * fix dependency * fix dep * update xdp-tools to v1.4.2 * fix runtime deps * fix deps * Fix Umem addressing and make Rx path async to efficiently fill FQ * fix CodeQL analyze deps * fix Analyze * fix analyze * linux xdp to use sudo * change 'if' order * path fix? * sudo pwsh * add retry for xsk_socket__create when returns -EBUSY * cleanup xdp program before running * Fix cargo build --all * fix cargo test dynamic linking * remove Sanitize for initial commit * generate artifact * fix yml syntax issue * fix CodeQl Analysys * forget to add Partition declaration * Use Rundown to wait for deleting socket before binding next * fix Rundown for all xdp socket * Fix EBUSY issue when binding xdp socket * explictly disable port sharing test * refactoring and cleanup * fix pipeline. else for normal linux socket * Fix cargo linking issue? * disable xdp for cargo build * fix codeql * rollback build.rs * fix package runtime link and codeql * wrap packet dump function to DEBUG macro * check dependency * another check * leave only LD_LIBRARY_PATH * iterate attach mode * fix codeql * add IP address check in XDP prog * break is enough & avoid compiler bug * fix CodeCheck * Fix use of RxHeadroom * fix umem leak when failed to initialize * use pool alloc for Interface * fix ipv4 check * remove workaround * cleanup. from snake case to pascal case * fix clog * try ubuntu20.04 and enable stress test * few fix of stress test yml * integrate package libxdp linking * fix RX parse error case * disable ubuntu20.04 * remove 2 env variable to run * add document * fix ForBuild && clog * stop installing deps on Ubuntu 20.04 * fix build * fix libc6-dev-i386 side effect * Add one more dependency (libzstd) for static build * new line fix * always install libc6-dev-i386 * fix install order * fix CMakeLists.txt to cover qns.Dockerfile case * remove env var dep, update doc * fix stress.yml * add env var for xdp knob and fix stress * fix stress * update clog * update doc * Fix doc appearance and words * add UseXdp * Update docs/BUILD.md Co-authored-by: Nick Banks <[email protected]> * Update docs/BUILD.md Co-authored-by: Nick Banks <[email protected]> * use SKB mode for now * move Linux XDP logging to TSG.md * stop warning print from libxdp/libbpf * move CxPlat definitions to each plat * initial commit * common xdp utilities * move sudo inside scripts * fix comments * fix clog * fix ifdef syntax * fix annotations * all arch to build dataptah_xplat.c * fix mac build * fix lisence of ebpf prog * fix spin.ps1 to propagate parameter * Ether and IPv6 was not set appropriately * Update docs/TSG.md * remove warning supression * remove BuildLibXdpFromSource --------- Co-authored-by: ami-GS <azureuser@node1.s4l0gsbs5l2efgb53yvjusshdg.xx.internal.cloudapp.net> Co-authored-by: Nick Banks <[email protected]>
1 parent 131cace commit 5052f34

File tree

63 files changed

+6677
-2670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+6677
-2670
lines changed

.github/workflows/build-reuse-unix.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ on:
6565
required: false
6666
default: ''
6767
type: string
68+
xdp:
69+
required: false
70+
default: ''
71+
type: string
6872
sanitize:
6973
required: false
7074
default: ''
@@ -95,7 +99,7 @@ jobs:
9599
chown -R $(id -u):$(id -g) $PWD
96100
- name: Prepare Machine
97101
shell: pwsh
98-
run: scripts/prepare-machine.ps1 ${{ inputs.plat == 'linux' && '-ForContainerBuild' || '-ForBuild' }} -Tls ${{ inputs.tls }}
102+
run: scripts/prepare-machine.ps1 ${{ inputs.plat == 'linux' && '-ForContainerBuild' || '-ForBuild' }} -Tls ${{ inputs.tls }} ${{ inputs.xdp }}
99103
- name: Build For Test
100104
if: inputs.build == '-Test'
101105
shell: pwsh

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ jobs:
3939
# Install dependencies and build submodules before starting analysis.
4040
- run: |
4141
sudo apt-add-repository ppa:lttng/stable-2.13
42+
sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y
4243
sudo apt-get update
4344
sudo apt-get install -y liblttng-ust-dev libnuma-dev
45+
sudo apt-get install -y libxdp-dev libbpf-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev zlib1g-dev zlib1g pkg-config m4 clang libpcap-dev libelf-dev
46+
sudo apt-get install -y --no-install-recommends libc6-dev-i386
4447
sudo sh scripts/install-powershell-docker.sh
4548
mkdir build
4649
cd build

.github/workflows/stress.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
{ config: "Debug", plat: "macos", os: "macos-12", arch: "x64", tls: "openssl3", build: "-Test" },
5252
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
5353
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
54+
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", build: "-Test" },
5455
]
5556
uses: ./.github/workflows/build-reuse-unix.yml
5657
with:
@@ -72,6 +73,7 @@ jobs:
7273
vec: [
7374
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
7475
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
76+
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", xdp: "-UseXdp", build: "-Test" },
7577
{ config: "Debug", plat: "macos", os: "macos-12", arch: "x64", tls: "openssl", build: "-Test" },
7678
{ config: "Debug", plat: "macos", os: "macos-12", arch: "x64", tls: "openssl3", build: "-Test" },
7779
{ config: "Debug", plat: "windows", os: "windows-2022", arch: "x64", tls: "schannel", sanitize: "-Sanitize", build: "-Test" },

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
7272
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
7373
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
74+
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", build: "-Test" },
7475
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", systemcrypto: "-UseSystemOpenSSLCrypto", sanitize: "-Sanitize", build: "-Test" },
7576
]
7677
uses: ./.github/workflows/build-reuse-unix.yml
@@ -96,6 +97,7 @@ jobs:
9697
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
9798
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
9899
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", sanitize: "-Sanitize", build: "-Test" },
100+
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", xdp: "-UseXdp", build: "-Test" },
99101
{ config: "Debug", plat: "linux", os: "ubuntu-22.04", arch: "x64", tls: "openssl3", systemcrypto: "-UseSystemOpenSSLCrypto", sanitize: "-Sanitize", build: "-Test" },
100102
{ config: "Debug", plat: "windows", os: "windows-2019", arch: "x64", tls: "openssl", build: "-Test" },
101103
{ config: "Debug", plat: "windows", os: "windows-2019", arch: "x64", tls: "openssl3", build: "-Test" },

CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ elseif (APPLE)
6464
set(CX_PLATFORM "darwin")
6565
elseif (UNIX)
6666
set(CX_PLATFORM "linux")
67+
file(STRINGS "/etc/lsb-release" LSB_RELEASE_CONTENT)
68+
string(REGEX MATCH "DISTRIB_RELEASE=([0-9]+\\.[0-9]+)" _ ${LSB_RELEASE_CONTENT})
69+
set(UBUNTU_VERSION ${CMAKE_MATCH_1})
6770
endif()
6871
message(STATUS "QUIC Platform: ${CX_PLATFORM}")
6972

@@ -434,13 +437,13 @@ if (NOT MSVC AND NOT APPLE AND NOT ANDROID)
434437
endif()
435438
endif()
436439

437-
if(WIN32)
438-
if (CMAKE_GENERATOR_PLATFORM STREQUAL "")
439-
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
440-
else()
441-
string(TOLOWER ${CMAKE_GENERATOR_PLATFORM} SYSTEM_PROCESSOR)
442-
endif()
440+
if (CMAKE_GENERATOR_PLATFORM STREQUAL "")
441+
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
442+
else()
443+
string(TOLOWER ${CMAKE_GENERATOR_PLATFORM} SYSTEM_PROCESSOR)
444+
endif()
443445

446+
if(WIN32)
444447
# Generate the MsQuicEtw header file.
445448
file(MAKE_DIRECTORY ${QUIC_BUILD_DIR}/inc)
446449

docs/BUILD.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,59 @@ sudo dnf install openssl-devel
181181
sudo dnf install libatomic
182182
```
183183

184+
#### Linux XDP
185+
Linux XDP is experimentally supported on amd64 && Ubuntu 22.04LTS.
186+
Commands below automatically install dependencies and setup runtime environment.
187+
```sh
188+
pwsh ./scripts/prepare-machine.ps1 -UseXdp
189+
pwsh ./scripts/build.ps1
190+
export MSQUIC_ENABLE_XDP=1
191+
```
192+
193+
`./scripts/prepare-machine.ps1` internally does the below commands:
194+
```sh
195+
# for libxdp v1.4.2
196+
sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y
197+
198+
# install runtime dependencies
199+
sudo apt-get install -y libxdp1 libbpf1 libnl-3-200 libnl-route-3-200 libnl-genl-3-200
200+
201+
# install build dependencies
202+
sudo apt-get --no-install-recommends -y install libxdp-dev libbpf-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev zlib1g-dev zlib1g pkg-config m4 clang libpcap-dev libelf-dev libc6-dev-i386
203+
204+
# Optional. This is required when you run test with duonic (XDP capable virtual nic pair)
205+
sudo apt-get -y install iproute2 iptables
206+
sudo ./scripts/duonic.sh install
207+
```
208+
209+
Test
210+
```sh
211+
# "sudo" and MSQUIC_ENABLE_XDP=1 required
212+
# You can explicitly specify directory of datapath_raw_xdp_kern.o by MSQUIC_XDP_OBJECT_PATH
213+
# By default, libmsquic.so searchs for same directory as its executable
214+
# If something failed, fallback to normal socket
215+
sudo MSQUIC_ENABLE_XDP=1 ./artifacts/bin/linux/x64_Debug_openssl3/msquictest --duoNic
216+
```
217+
218+
**Q&A**
219+
- Q: Is this workload really running on XDP?
220+
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.
221+
```
222+
$ sudo ./xdp-tools/xdp-dump/xdpdump --list-interfaces
223+
Interface Prio Program name Mode ID Tag Chain actions
224+
--------------------------------------------------------------------------------------
225+
lo <No XDP program loaded!>
226+
eth0 <No XDP program loaded!>
227+
docker0 <No XDP program loaded!>
228+
duo2 xdp_dispatcher native 608211 4d7e87c0d30db711
229+
=> 50 xdp_main 608220 c8fcabdd9e3895f3 XDP_PASS
230+
duo1 xdp_dispatcher native 608225 4d7e87c0d30db711
231+
=> 50 xdp_main 608228 c8fcabdd9e3895f3 XDP_PASS
232+
```
233+
234+
- Q: Is Ubuntu 20.04LTS supported?
235+
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**.
236+
184237
### macOS
185238
The build needs CMake and compiler.
186239

docs/TSG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ This document is meant to be a step-by-step guide for trouble shooting any issue
3030

3131
See [Tracing](./Diagnostics.md#Built-in-Tracing)
3232

33+
### Linux XDP logging?
34+
For XDP layer, enable `DEBUG` flag in `src/platform/CMakeLists.txt`.
35+
You can see incomming packets information by `sudo cat /sys/kernel/debug/tracing/trace_pipe`.
36+
**Your workload must become too slow.**
37+
```
38+
msquictest-3797496 [005] ..s1. 2079546.776875: bpf_trace_printk: ========> To ifacename : [duo2], RxQueueID:0
39+
msquictest-3797496 [005] ..s1. 2079546.776875: bpf_trace_printk: Eth[244] SRC: 00:00:00:00:00:00 => DST:22:22:22:22:00:02
40+
msquictest-3797496 [005] ..s1. 2079546.776876: bpf_trace_printk: Ipv4 TotalLen:[230] Src: 192.168.1.11 => Dst: 192.168.1.12
41+
msquictest-3797496 [005] ..s1. 2079546.776877: bpf_trace_printk: UDP[202]: SRC: 43829 DST:58141
42+
msquictest-3797496 [005] ..s1. 2079546.776877: bpf_trace_printk: [ec 00 00 00 01 00 09 c0 30 3d 49 a2]
43+
msquictest-3797496 [005] ..s1. 2079546.776878: bpf_trace_printk: Redirect to QUIC service. IpMatch:1, PortMatch:1, SocketExists:1, Redirection:4
44+
45+
msquictest-3797496 [005] ..s1. 2079546.777235: bpf_trace_printk: ========> To ifacename : [duo1], RxQueueID:0
46+
msquictest-3797496 [005] ..s1. 2079546.777310: bpf_trace_printk: Eth[1262] SRC: 00:00:00:00:00:00 => DST:22:22:22:22:00:01
47+
msquictest-3797496 [005] ..s1. 2079546.777323: bpf_trace_printk: Ipv4 TotalLen:[1248] Src: 192.168.1.12 => Dst: 192.168.1.11
48+
msquictest-3797496 [005] ..s1. 2079546.777323: bpf_trace_printk: UDP[1220]: SRC: 58141 DST:43829
49+
msquictest-3797496 [005] ..s1. 2079546.777324: bpf_trace_printk: [c0 00 00 00 01 09 c0 30 3d 49 a2 56]
50+
msquictest-3797496 [005] ..s1. 2079546.777325: bpf_trace_printk: Redirect to QUIC service. IpMatch:1, PortMatch:1, SocketExists:1, Redirection:4
51+
```
52+
3353
## Understanding Error Codes
3454

3555
Some error codes are MsQuic specific (`QUIC_STATUS_*`), and some are simply a passthrough from the platform. You can find the MsQuic specific error codes in the platform specific header ([msquic_posix.h](../src/inc/msquic_posix.h), [msquic_winkernel.h](../src/inc/msquic_winkernel.h), or [msquic_winuser.h](../src/inc/msquic_winuser.h)).

scripts/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ fn main() {
1919
config
2020
.define("QUIC_ENABLE_LOGGING", logging_enabled)
2121
.define("QUIC_TLS", "openssl")
22-
.define("QUIC_OUTPUT_DIR", "../lib");
22+
.define("QUIC_OUTPUT_DIR", "../lib")
23+
.define("QUIC_CARGO_BUILD", "on");
2324

2425
match target.as_str() {
2526
"x86_64-apple-darwin" => config

scripts/clog.inputs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
../src/platform/hashtable.c
1515
../src/platform/datapath_winuser.c
1616
../src/platform/datapath_linux.c
17+
../src/platform/datapath_unix.c
18+
../src/platform/datapath_xplat.c
1719
../src/platform/datapath_raw_dpdk.c
1820
../src/platform/datapath_raw_socket.c
1921
../src/platform/datapath_raw_socket_win.c
@@ -22,6 +24,7 @@
2224
../src/platform/datapath_raw_xdp_linux.c
2325
../src/platform/datapath_raw_win.c
2426
../src/platform/datapath_raw_linux.c
27+
../src/platform/datapath_raw.c
2528
../src/platform/crypt_bcrypt.c
2629
../src/platform/platform_winuser.c
2730
../src/platform/toeplitz.c

scripts/duonic.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
# Set the number of NIC pairs
4+
NumNicPairs=1
5+
6+
if [ "$1" == "install" ]; then
7+
# Configure each pair separately with its own hard-coded subnet, ie 192.168.x.0/24 and fc00::x/112
8+
for ((i=1; i<=NumNicPairs; i++)); do
9+
echo "Plumbing IP config for pair $i"
10+
11+
# Generate the "ID" of the NICs, eg 1 and 2 for the first pair
12+
nic1="duo$((i * 2 - 1))"
13+
nic2="duo$((i * 2))"
14+
15+
# Create veth pair
16+
sudo ip link add ${nic1} type veth peer name ${nic2}
17+
18+
# Set the veth interfaces up
19+
sudo ip link set ${nic1} up
20+
sudo ip link set ${nic2} up
21+
22+
# Assign IPv4 addresses
23+
sudo ip addr add 192.168.${i}.11/24 dev ${nic1}
24+
sudo ip addr add 192.168.${i}.12/24 dev ${nic2}
25+
26+
# Assign IPv6 addresses
27+
sudo ip -6 addr add fc00::${i}:11/112 dev ${nic1}
28+
sudo ip -6 addr add fc00::${i}:12/112 dev ${nic2}
29+
30+
# Add static neighbor entries (ARP)
31+
sudo ip neigh add 192.168.${i}.12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1} nud permanent
32+
sudo ip neigh add 192.168.${i}.11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2} nud permanent
33+
34+
# Add static neighbor entries (IPv6)
35+
sudo ip -6 neigh add fc00::${i}:12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1} nud permanent
36+
sudo ip -6 neigh add fc00::${i}:11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2} nud permanent
37+
38+
# Configure routing rules for IPv4
39+
sudo ip route add 192.168.${i}.12/32 dev ${nic1} metric 0
40+
sudo ip route add 192.168.${i}.11/32 dev ${nic2} metric 0
41+
42+
43+
44+
# Configure routing rules for IPv6
45+
sudo ip -6 route add fc00::${i}:12/128 dev ${nic1} metric 0
46+
sudo ip -6 route add fc00::${i}:11/128 dev ${nic2} metric 0
47+
48+
# Configure firewall rules for IPv4
49+
sudo iptables -A INPUT -p all -s 192.168.${i}.0/24 -i ${nic1} -j ACCEPT
50+
sudo iptables -A INPUT -p all -s 192.168.${i}.0/24 -i ${nic2} -j ACCEPT
51+
52+
# Configure firewall rules for IPv6
53+
sudo ip6tables -A INPUT -p all -s fc00::${i}:0/112 -i ${nic1} -j ACCEPT
54+
sudo ip6tables -A INPUT -p all -s fc00::${i}:0/112 -i ${nic2} -j ACCEPT
55+
56+
sleep 2
57+
sudo ip route change 192.168.${i}.12 dev duo1 src 192.168.${i}.11
58+
sudo ip route change 192.168.${i}.11 dev duo2 src 192.168.${i}.12
59+
60+
sudo ip -6 route change fc00::${i}:12 dev duo1 src fc00::${i}:11
61+
sudo ip -6 route change fc00::${i}:11 dev duo2 src fc00::${i}:12
62+
done
63+
elif [ "$1" == "uninstall" ]; then
64+
# Cleanup each pair separately
65+
for ((i=1; i<=NumNicPairs; i++)); do
66+
echo "Cleaning up pair $i"
67+
68+
# Generate the "ID" of the NICs, eg 1 and 2 for the first pair
69+
nic1="duo$((i * 2 - 1))"
70+
nic2="duo$((i * 2))"
71+
72+
# Delete firewall rules for IPv4
73+
sudo iptables -D INPUT -p all -s 192.168.${i}.0/24 -i ${nic1} -j ACCEPT
74+
sudo iptables -D INPUT -p all -s 192.168.${i}.0/24 -i ${nic2} -j ACCEPT
75+
76+
# Delete firewall rules for IPv6
77+
sudo ip6tables -D INPUT -p all -s fc00::${i}:0/112 -i ${nic1} -j ACCEPT
78+
sudo ip6tables -D INPUT -p all -s fc00::${i}:0/112 -i ${nic2} -j ACCEPT
79+
80+
# Remove routing rules for IPv4
81+
sudo ip route del 192.168.${i}.12/32 dev ${nic1}
82+
sudo ip route del 192.168.${i}.11/32 dev ${nic2}
83+
84+
# Remove routing rules for IPv6
85+
sudo ip -6 route del fc00::${i}:12/128 dev ${nic1}
86+
sudo ip -6 route del fc00::${i}:11/128 dev ${nic2}
87+
88+
# Remove static neighbor entries (ARP)
89+
sudo ip neigh del 192.168.${i}.12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1}
90+
sudo ip neigh del 192.168.${i}.11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2}
91+
92+
# Remove static neighbor entries (IPv6)
93+
sudo ip -6 neigh del fc00::${i}:12 lladdr 22:22:22:22:00:0$((i * 2)) dev ${nic1}
94+
sudo ip -6 neigh del fc00::${i}:11 lladdr 22:22:22:22:00:0$((i * 2 - 1)) dev ${nic2}
95+
96+
# Remove the veth pair
97+
sudo ip link delete ${nic1}
98+
done
99+
else
100+
echo "Usage: $0 {install|uninsatll}"
101+
exit 1
102+
fi

scripts/prepare-machine.ps1

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,18 @@ function Uninstall-Xdp {
228228

229229
# Installs DuoNic from the CoreNet-CI repo.
230230
function Install-DuoNic {
231-
if (!$IsWindows) { return } # Windows only
232231
# Install the DuoNic driver.
233-
Write-Host "Installing DuoNic driver"
234-
$DuoNicPath = Join-Path $SetupPath duonic
235-
$DuoNicScript = (Join-Path $DuoNicPath duonic.ps1)
236-
if (!(Test-Path $DuoNicScript)) { Write-Error "Missing file: $DuoNicScript" }
237-
Invoke-Expression "cmd /c `"pushd $DuoNicPath && pwsh duonic.ps1 -Install`""
232+
if ($IsWindows) {
233+
Write-Host "Installing DuoNic driver"
234+
$DuoNicPath = Join-Path $SetupPath duonic
235+
$DuoNicScript = (Join-Path $DuoNicPath duonic.ps1)
236+
if (!(Test-Path $DuoNicScript)) { Write-Error "Missing file: $DuoNicScript" }
237+
Invoke-Expression "cmd /c `"pushd $DuoNicPath && pwsh duonic.ps1 -Install`""
238+
} elseif ($IsLinux) {
239+
Write-Host "Creating DuoNic endpoints"
240+
$DuoNicScript = Join-Path $PSScriptRoot "duonic.sh"
241+
Invoke-Expression "sudo bash $DuoNicScript install"
242+
}
238243
}
239244

240245
function Update-Path($NewPath) {
@@ -504,6 +509,15 @@ if ($IsLinux) {
504509
sudo apt-get install -y ruby ruby-dev rpm
505510
sudo gem install public_suffix -v 4.0.7
506511
sudo gem install fpm
512+
513+
# XDP dependencies
514+
if ((bash -c 'lsb_release -r') -match '22.04') {
515+
sudo apt-get -y install --no-install-recommends libc6-dev-i386 # for building xdp programs
516+
sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y
517+
sudo apt-get update -y
518+
sudo apt-get -y install libxdp-dev libbpf-dev
519+
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
520+
}
507521
}
508522

509523
if ($ForTest) {
@@ -512,6 +526,16 @@ if ($IsLinux) {
512526
sudo apt-get install -y lttng-tools
513527
sudo apt-get install -y liblttng-ust-dev
514528
sudo apt-get install -y gdb
529+
if ((bash -c 'lsb_release -r') -match '22.04') {
530+
sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y
531+
sudo apt-get update -y
532+
sudo apt-get install -y libxdp1 libbpf1
533+
sudo apt-get install -y libnl-3-200 libnl-route-3-200 libnl-genl-3-200
534+
if ($UseXdp) {
535+
sudo apt-get -y install iproute2 iptables
536+
Install-DuoNic
537+
}
538+
}
515539

516540
# Enable core dumps for the system.
517541
Write-Host "Setting core dump size limit"

scripts/spin.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,8 @@ if (![string]::IsNullOrWhiteSpace($ExtraArtifactDir)) {
187187
}
188188

189189
# Run the script.
190-
Invoke-Expression ($RunExecutable + " " + $Arguments)
190+
if ($IsLinux -and $UseXdp) {
191+
Invoke-Expression ('sudo MSQUIC_ENABLE_XDP=1 pwsh -c "$RunExecutable $Arguments"')
192+
} else {
193+
Invoke-Expression ($RunExecutable + " " + $Arguments)
194+
}

0 commit comments

Comments
 (0)