Skip to content

Commit a0810cd

Browse files
authored
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.
1 parent d0ba3d3 commit a0810cd

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

.cirrus.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
freebsd_instance:
2-
image: freebsd-13-2-release-amd64
2+
image: freebsd-14-3-release-amd64-ufs
33

44
env:
55
RUST_BACKTRACE: full
@@ -9,6 +9,7 @@ task:
99
setup_script:
1010
- fetch https://sh.rustup.rs -o rustup.sh
1111
- sh rustup.sh -y --profile minimal
12+
- kldload cc_newreno # For the tcp_congestion test
1213
cargo_cache:
1314
folder: $HOME/.cargo/registry
1415
build_script:

tests/socket.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,23 +1769,29 @@ fn tcp_congestion() {
17691769
"expected {origin_tcp_ca:?} but get {cur_tcp_ca:?}"
17701770
);
17711771
let cur_tcp_ca = cur_tcp_ca.splitn(2, |num| *num == 0).next().unwrap();
1772-
const OPTIONS: [&[u8]; 2] = [
1773-
b"cubic",
1772+
const OPTIONS: [&str; 2] = [
1773+
"cubic",
17741774
#[cfg(target_os = "linux")]
1775-
b"reno",
1775+
"reno",
17761776
#[cfg(target_os = "freebsd")]
1777-
b"newreno",
1777+
"newreno",
17781778
];
17791779
// Set a new tcp ca
1780-
#[cfg(target_os = "linux")]
1781-
let new_tcp_ca = if cur_tcp_ca == OPTIONS[0] {
1782-
OPTIONS[1]
1780+
let new_tcp_ca = if cur_tcp_ca == OPTIONS[0].as_bytes() {
1781+
OPTIONS[1].as_bytes()
17831782
} else {
1784-
OPTIONS[0]
1783+
OPTIONS[0].as_bytes()
17851784
};
1786-
#[cfg(target_os = "freebsd")]
1787-
let new_tcp_ca = OPTIONS[1];
1788-
socket.set_tcp_congestion(new_tcp_ca).unwrap();
1785+
if let Err(e) = socket.set_tcp_congestion(new_tcp_ca) {
1786+
if e.raw_os_error() == Some(libc::ESRCH) {
1787+
panic!(
1788+
"Could not set the {:?} CC protocol. Is the kernel module loaded?",
1789+
new_tcp_ca
1790+
);
1791+
} else {
1792+
panic!("set_tcp_congestion: {e}");
1793+
}
1794+
}
17891795
// Check if new tcp ca is successfully set
17901796
let cur_tcp_ca = socket.tcp_congestion().unwrap();
17911797
assert_eq!(

0 commit comments

Comments
 (0)