Skip to content

Commit

Permalink
Linux XDP support (#3849)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Apr 25, 2024
1 parent 131cace commit 5052f34
Show file tree
Hide file tree
Showing 63 changed files with 6,677 additions and 2,670 deletions.
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 @@ -39,8 +39,11 @@ jobs:
# Install dependencies and build submodules before starting analysis.
- run: |
sudo apt-add-repository ppa:lttng/stable-2.13
sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y
sudo apt-get update
sudo apt-get install -y liblttng-ust-dev libnuma-dev
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
sudo apt-get install -y --no-install-recommends libc6-dev-i386
sudo sh scripts/install-powershell-docker.sh
mkdir build
cd build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/stress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
{ config: "Debug", plat: "macos", os: "macos-12", arch: "x64", tls: "openssl3", build: "-Test" },
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
{ 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: "openssl3", build: "-Test" },
]
uses: ./.github/workflows/build-reuse-unix.yml
with:
Expand All @@ -72,6 +73,7 @@ jobs:
vec: [
{ config: "Debug", plat: "linux", os: "ubuntu-20.04", arch: "x64", tls: "openssl", sanitize: "-Sanitize", build: "-Test" },
{ 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: "openssl3", xdp: "-UseXdp", build: "-Test" },
{ config: "Debug", plat: "macos", os: "macos-12", arch: "x64", tls: "openssl", build: "-Test" },
{ config: "Debug", plat: "macos", os: "macos-12", arch: "x64", tls: "openssl3", build: "-Test" },
{ config: "Debug", plat: "windows", os: "windows-2022", arch: "x64", tls: "schannel", sanitize: "-Sanitize", build: "-Test" },
Expand Down
2 changes: 2 additions & 0 deletions .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
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ elseif (APPLE)
set(CX_PLATFORM "darwin")
elseif (UNIX)
set(CX_PLATFORM "linux")
file(STRINGS "/etc/lsb-release" LSB_RELEASE_CONTENT)
string(REGEX MATCH "DISTRIB_RELEASE=([0-9]+\\.[0-9]+)" _ ${LSB_RELEASE_CONTENT})
set(UBUNTU_VERSION ${CMAKE_MATCH_1})
endif()
message(STATUS "QUIC Platform: ${CX_PLATFORM}")

Expand Down Expand Up @@ -434,13 +437,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
53 changes: 53 additions & 0 deletions docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,59 @@ sudo dnf install openssl-devel
sudo dnf install libatomic
```

#### Linux XDP
Linux XDP is experimentally supported on amd64 && Ubuntu 22.04LTS.
Commands below automatically install dependencies and setup runtime environment.
```sh
pwsh ./scripts/prepare-machine.ps1 -UseXdp
pwsh ./scripts/build.ps1
export MSQUIC_ENABLE_XDP=1
```

`./scripts/prepare-machine.ps1` internally does the below commands:
```sh
# for libxdp v1.4.2
sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y

# install runtime dependencies
sudo apt-get install -y libxdp1 libbpf1 libnl-3-200 libnl-route-3-200 libnl-genl-3-200

# install build dependencies
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

# Optional. This is required when you run test with duonic (XDP capable virtual nic pair)
sudo apt-get -y install iproute2 iptables
sudo ./scripts/duonic.sh install
```

Test
```sh
# "sudo" and MSQUIC_ENABLE_XDP=1 required
# You can explicitly specify directory of datapath_raw_xdp_kern.o by MSQUIC_XDP_OBJECT_PATH
# By default, libmsquic.so searchs for same directory as its executable
# If something failed, fallback to normal socket
sudo MSQUIC_ENABLE_XDP=1 ./artifacts/bin/linux/x64_Debug_openssl3/msquictest --duoNic
```

**Q&A**
- 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 ./xdp-tools/xdp-dump/xdpdump --list-interfaces
Interface Prio Program name Mode ID Tag Chain actions
--------------------------------------------------------------------------------------
lo <No XDP program loaded!>
eth0 <No XDP program loaded!>
docker0 <No XDP program loaded!>
duo2 xdp_dispatcher native 608211 4d7e87c0d30db711
=> 50 xdp_main 608220 c8fcabdd9e3895f3 XDP_PASS
duo1 xdp_dispatcher native 608225 4d7e87c0d30db711
=> 50 xdp_main 608228 c8fcabdd9e3895f3 XDP_PASS
```

- 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**.

### macOS
The build needs CMake and compiler.

Expand Down
20 changes: 20 additions & 0 deletions docs/TSG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ This document is meant to be a step-by-step guide for trouble shooting any issue

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

### Linux XDP logging?
For XDP layer, enable `DEBUG` flag in `src/platform/CMakeLists.txt`.
You can see incomming packets information by `sudo cat /sys/kernel/debug/tracing/trace_pipe`.
**Your workload must become too slow.**
```
msquictest-3797496 [005] ..s1. 2079546.776875: bpf_trace_printk: ========> To ifacename : [duo2], RxQueueID:0
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
msquictest-3797496 [005] ..s1. 2079546.776876: bpf_trace_printk: Ipv4 TotalLen:[230] Src: 192.168.1.11 => Dst: 192.168.1.12
msquictest-3797496 [005] ..s1. 2079546.776877: bpf_trace_printk: UDP[202]: SRC: 43829 DST:58141
msquictest-3797496 [005] ..s1. 2079546.776877: bpf_trace_printk: [ec 00 00 00 01 00 09 c0 30 3d 49 a2]
msquictest-3797496 [005] ..s1. 2079546.776878: bpf_trace_printk: Redirect to QUIC service. IpMatch:1, PortMatch:1, SocketExists:1, Redirection:4
msquictest-3797496 [005] ..s1. 2079546.777235: bpf_trace_printk: ========> To ifacename : [duo1], RxQueueID:0
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
msquictest-3797496 [005] ..s1. 2079546.777323: bpf_trace_printk: Ipv4 TotalLen:[1248] Src: 192.168.1.12 => Dst: 192.168.1.11
msquictest-3797496 [005] ..s1. 2079546.777323: bpf_trace_printk: UDP[1220]: SRC: 58141 DST:43829
msquictest-3797496 [005] ..s1. 2079546.777324: bpf_trace_printk: [c0 00 00 00 01 09 c0 30 3d 49 a2 56]
msquictest-3797496 [005] ..s1. 2079546.777325: bpf_trace_printk: Redirect to QUIC service. IpMatch:1, PortMatch:1, SocketExists:1, Redirection:4
```

## Understanding Error Codes

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)).
Expand Down
3 changes: 2 additions & 1 deletion 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("QUIC_CARGO_BUILD", "on");

match target.as_str() {
"x86_64-apple-darwin" => config
Expand Down
3 changes: 3 additions & 0 deletions scripts/clog.inputs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
../src/platform/hashtable.c
../src/platform/datapath_winuser.c
../src/platform/datapath_linux.c
../src/platform/datapath_unix.c
../src/platform/datapath_xplat.c
../src/platform/datapath_raw_dpdk.c
../src/platform/datapath_raw_socket.c
../src/platform/datapath_raw_socket_win.c
Expand All @@ -22,6 +24,7 @@
../src/platform/datapath_raw_xdp_linux.c
../src/platform/datapath_raw_win.c
../src/platform/datapath_raw_linux.c
../src/platform/datapath_raw.c
../src/platform/crypt_bcrypt.c
../src/platform/platform_winuser.c
../src/platform/toeplitz.c
Expand Down
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
36 changes: 30 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 @@ -504,6 +509,15 @@ 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
if ((bash -c 'lsb_release -r') -match '22.04') {
sudo apt-get -y install --no-install-recommends libc6-dev-i386 # for building xdp programs
sudo apt-add-repository "deb http://mirrors.kernel.org/ubuntu noble main" -y
sudo apt-get update -y
sudo apt-get -y install libxdp-dev libbpf-dev
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
}
}

if ($ForTest) {
Expand All @@ -512,6 +526,16 @@ if ($IsLinux) {
sudo apt-get install -y lttng-tools
sudo apt-get install -y liblttng-ust-dev
sudo apt-get install -y gdb
if ((bash -c 'lsb_release -r') -match '22.04') {
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
Install-DuoNic
}
}

# Enable core dumps for the system.
Write-Host "Setting core dump size limit"
Expand Down
6 changes: 5 additions & 1 deletion scripts/spin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,8 @@ if (![string]::IsNullOrWhiteSpace($ExtraArtifactDir)) {
}

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

0 comments on commit 5052f34

Please sign in to comment.