Skip to content

Commit cd65470

Browse files
dignifiedquireflub
andauthored
feat: support {Free|Net|Open}BSD (#2311)
Adds support for `iroh` on `NetBSD`, `FreeBSD` and `OpenBSD`. ## Status - NetBsd - [x] Compiles - [ ] Tests passing - [ ] Iroh: mostly passing, failures are only due to shellrow/netdev#69 - [x] Quinn - [x] Implementation adapted - FreeBsd - [x] Compiles - [ ] Tests passing - [ ] Iroh: mostly passing, failures are only due to shellrow/netdev#69 - [x] Quinn - [x] Implementation adapted - OpenBsd - [x] Compiles - [ ] Tests passing - [ ] Iroh: mostly passing, failures are only due to shellrow/netdev#69 - [x] Quinn - [x] Implementation adapted ## Caveats - Build only in CI for now ## Related Issues - shellrow/netdev#69 - n0-computer/quinn#9 ## References - https://github.com/freebsd/freebsd-ports/blob/78ad38f04f51/games/jumpy/files/patch-iroh - rust-lang/libc#3711 Closes #2306 --------- Co-authored-by: Floris Bruynooghe <flub@n0.computer>
1 parent 1e31dcf commit cd65470

File tree

13 files changed

+861
-152
lines changed

13 files changed

+861
-152
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,23 @@ jobs:
2525
if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')"
2626
uses: './.github/workflows/tests.yaml'
2727

28-
cross:
28+
cross_build:
29+
name: Cross Build Only
2930
if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')"
3031
timeout-minutes: 30
31-
name: Cross compile
3232
runs-on: [self-hosted, linux, X64]
3333
strategy:
3434
fail-fast: false
3535
matrix:
3636
target:
37-
- i686-unknown-linux-gnu
37+
# cross tests are currently broken vor armv7 and aarch64
38+
# see https://github.com/cross-rs/cross/issues/1311
3839
- armv7-linux-androideabi
3940
- aarch64-linux-android
41+
# Freebsd execution fails in cross
42+
# - i686-unknown-freebsd # Linking fails :/
43+
- x86_64-unknown-freebsd
44+
- x86_64-unknown-netbsd
4045
steps:
4146
- name: Checkout
4247
uses: actions/checkout@v4
@@ -59,15 +64,39 @@ jobs:
5964
# cross tests are currently broken vor armv7 and aarch64
6065
# see https://github.com/cross-rs/cross/issues/1311. So on
6166
# those platforms we only build but do not run tests.
62-
if: matrix.target != 'i686-unknown-linux-gnu'
6367
run: cross build --all --target ${{ matrix.target }}
6468
env:
6569
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}}
6670

71+
cross_test:
72+
name: Cross Test
73+
if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')"
74+
timeout-minutes: 30
75+
runs-on: [self-hosted, linux, X64]
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
target:
80+
- i686-unknown-linux-gnu
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v4
84+
with:
85+
submodules: recursive
86+
87+
- name: Install rust stable
88+
uses: dtolnay/rust-toolchain@stable
89+
90+
- name: Cleanup Docker
91+
continue-on-error: true
92+
run: |
93+
docker kill $(docker ps -q)
94+
95+
- name: Install cross
96+
# See https://github.com/cross-rs/cross/issues/1222
97+
run: cargo install cross --git https://github.com/cross-rs/cross
98+
6799
- name: test
68-
# cross tests are currently broken vor armv7 and aarch64
69-
# see https://github.com/cross-rs/cross/issues/1311
70-
if: matrix.target == 'i686-unknown-linux-gnu'
71100
run: cross test --all --target ${{ matrix.target }} -- --test-threads=12
72101
env:
73102
RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG' }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh-net/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ parking_lot = "0.12.1"
4949
pin-project = "1"
5050
pkarr = { version = "1.1.4", default-features = false, features = ["async", "relay"] }
5151
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
52-
quinn = { package = "iroh-quinn", version = "0.10.4" }
53-
quinn-proto = { package = "iroh-quinn-proto", version = "0.10.7" }
54-
quinn-udp = { package = "iroh-quinn-udp", version = "0.4" }
52+
quinn = { package = "iroh-quinn", version = "0.10.5" }
53+
quinn-proto = { package = "iroh-quinn-proto", version = "0.10.8" }
54+
quinn-udp = { package = "iroh-quinn-udp", version = "0.4.2" }
5555
rand = "0.8"
5656
rand_core = "0.6.4"
57-
rcgen = "0.11"
57+
rcgen = "0.12"
5858
reqwest = { version = "0.12.4", default-features = false, features = ["rustls-tls"] }
5959
ring = "0.17"
6060
rustls = { version = "0.21.11", default-features = false, features = ["dangerous_configuration"] }

iroh-net/bench/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ anyhow = "1.0.22"
1010
bytes = "1"
1111
hdrhistogram = { version = "7.2", default-features = false }
1212
iroh-net = { path = ".." }
13-
quinn = "0.10"
1413
rcgen = "0.11.1"
1514
rustls = { version = "0.21.0", default-features = false, features = ["quic"] }
1615
clap = { version = "4", features = ["derive"] }
1716
tokio = { version = "1.0.1", features = ["rt", "sync"] }
1817
tracing = "0.1"
1918
tracing-subscriber = { version = "0.3.0", default-features = false, features = ["env-filter", "fmt", "ansi", "time", "local-time"] }
2019
socket2 = "0.5"
20+
21+
[target.'cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))'.dependencies]
22+
quinn = "0.10"

iroh-net/bench/src/bin/bulk.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use anyhow::Result;
22
use clap::Parser;
33

4-
use iroh_net_bench::{configure_tracing_subscriber, iroh, quinn, rt, s2n, Commands, Opt};
4+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
5+
use iroh_net_bench::quinn;
6+
use iroh_net_bench::{configure_tracing_subscriber, iroh, rt, s2n, Commands, Opt};
57

68
fn main() {
79
let cmd = Commands::parse();
@@ -13,6 +15,7 @@ fn main() {
1315
eprintln!("failed: {e:#}");
1416
}
1517
}
18+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
1619
Commands::Quinn(opt) => {
1720
if let Err(e) = run_quinn(opt) {
1821
eprintln!("failed: {e:#}");
@@ -70,6 +73,7 @@ pub fn run_iroh(opt: Opt) -> Result<()> {
7073
Ok(())
7174
}
7275

76+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
7377
pub fn run_quinn(opt: Opt) -> Result<()> {
7478
let server_span = tracing::error_span!("server");
7579
let runtime = rt();

iroh-net/bench/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use tokio::sync::Semaphore;
1313
use tracing::info;
1414

1515
pub mod iroh;
16+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
1617
pub mod quinn;
1718
pub mod s2n;
1819
pub mod stats;
@@ -21,6 +22,7 @@ pub mod stats;
2122
#[clap(name = "bulk")]
2223
pub enum Commands {
2324
Iroh(Opt),
25+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
2426
Quinn(Opt),
2527
S2n(s2n::Opt),
2628
}
@@ -62,6 +64,7 @@ pub struct Opt {
6264

6365
pub enum EndpointSelector {
6466
Iroh(iroh_net::Endpoint),
67+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
6568
Quinn(::quinn::Endpoint),
6669
}
6770

@@ -71,6 +74,7 @@ impl EndpointSelector {
7174
EndpointSelector::Iroh(endpoint) => {
7275
endpoint.close(0u32.into(), b"").await?;
7376
}
77+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
7478
EndpointSelector::Quinn(endpoint) => {
7579
endpoint.close(0u32.into(), b"");
7680
}
@@ -81,6 +85,7 @@ impl EndpointSelector {
8185

8286
pub enum ConnectionSelector {
8387
Iroh(iroh_net::endpoint::Connection),
88+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
8489
Quinn(::quinn::Connection),
8590
}
8691

@@ -90,6 +95,7 @@ impl ConnectionSelector {
9095
ConnectionSelector::Iroh(connection) => {
9196
println!("{:#?}", connection.stats());
9297
}
98+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
9399
ConnectionSelector::Quinn(connection) => {
94100
println!("{:#?}", connection.stats());
95101
}
@@ -101,6 +107,7 @@ impl ConnectionSelector {
101107
ConnectionSelector::Iroh(connection) => {
102108
connection.close(error_code.into(), reason);
103109
}
110+
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd")))]
104111
ConnectionSelector::Quinn(connection) => {
105112
connection.close(error_code.into(), reason);
106113
}
@@ -193,6 +200,11 @@ pub async fn client_handler(
193200
iroh::handle_client_stream(connection, opt.upload_size, opt.read_unordered)
194201
.await
195202
}
203+
#[cfg(not(any(
204+
target_os = "freebsd",
205+
target_os = "openbsd",
206+
target_os = "netbsd"
207+
)))]
196208
ConnectionSelector::Quinn(connection) => {
197209
quinn::handle_client_stream(connection, opt.upload_size, opt.read_unordered)
198210
.await

0 commit comments

Comments
 (0)