From cef0107d53a8b7d69c42a929979ad2545d8f7b1f Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 28 Oct 2025 07:21:13 -0600 Subject: [PATCH 1/2] Update FreeBSD CI environment To the latest stable release: 14.3. And fix the tcp_congestion test: * On FreeBSD 14 or later, it requires the cc_newreno kernel module to be loaded. By default it is not. * If newreno happens to be the default, switch to cubic for the second part of the test, just as on Linux. --- .cirrus.yml | 3 ++- tests/socket.rs | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index dc68cea5..57a00d4f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,5 +1,5 @@ freebsd_instance: - image: freebsd-13-2-release-amd64 + image: freebsd-14-3-release-amd64-ufs env: RUST_BACKTRACE: full @@ -9,6 +9,7 @@ task: setup_script: - fetch https://sh.rustup.rs -o rustup.sh - sh rustup.sh -y --profile minimal + - kldload cc_newreno # For the tcp_congestion test cargo_cache: folder: $HOME/.cargo/registry build_script: diff --git a/tests/socket.rs b/tests/socket.rs index 34d9883e..7674b13b 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -1769,23 +1769,29 @@ fn tcp_congestion() { "expected {origin_tcp_ca:?} but get {cur_tcp_ca:?}" ); let cur_tcp_ca = cur_tcp_ca.splitn(2, |num| *num == 0).next().unwrap(); - const OPTIONS: [&[u8]; 2] = [ - b"cubic", + const OPTIONS: [&str; 2] = [ + "cubic", #[cfg(target_os = "linux")] - b"reno", + "reno", #[cfg(target_os = "freebsd")] - b"newreno", + "newreno", ]; // Set a new tcp ca - #[cfg(target_os = "linux")] - let new_tcp_ca = if cur_tcp_ca == OPTIONS[0] { - OPTIONS[1] + let new_tcp_ca = if cur_tcp_ca == OPTIONS[0].as_bytes() { + OPTIONS[1].as_bytes() } else { - OPTIONS[0] + OPTIONS[0].as_bytes() }; - #[cfg(target_os = "freebsd")] - let new_tcp_ca = OPTIONS[1]; - socket.set_tcp_congestion(new_tcp_ca).unwrap(); + if let Err(e) = socket.set_tcp_congestion(new_tcp_ca) { + if e.raw_os_error() == Some(libc::ESRCH) { + panic!( + "Could not set the {:?} CC protocol. Is the kernel module loaded?", + OPTIONS[1] + ); + } else { + panic!("set_tcp_congestion: {e}"); + } + } // Check if new tcp ca is successfully set let cur_tcp_ca = socket.tcp_congestion().unwrap(); assert_eq!( From 4ba865b28894057200f836a23cbb0b473eebbdd9 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 28 Oct 2025 07:43:42 -0600 Subject: [PATCH 2/2] Apply suggestion from @Darksonn Co-authored-by: Alice Ryhl --- tests/socket.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/socket.rs b/tests/socket.rs index 7674b13b..d34083cc 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -1786,7 +1786,7 @@ fn tcp_congestion() { if e.raw_os_error() == Some(libc::ESRCH) { panic!( "Could not set the {:?} CC protocol. Is the kernel module loaded?", - OPTIONS[1] + new_tcp_ca ); } else { panic!("set_tcp_congestion: {e}");