mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-22 19:24:08 +00:00
feat(quinn-udp): support illumos
This commit is contained in:
committed by
Dirkjan Ochtman
parent
f18890960d
commit
e318cc4a80
@@ -82,6 +82,24 @@ jobs:
|
||||
export PATH=$HOME/.rust_solaris/bin:$PATH
|
||||
cargo build --all-targets && cargo test && cargo test --manifest-path fuzz/Cargo.toml && cargo test -p quinn-udp --benches
|
||||
|
||||
test-illumos:
|
||||
name: test on illumos
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: test on Illumos
|
||||
uses: vmactions/omnios-vm@v1
|
||||
with:
|
||||
usesh: true
|
||||
mem: 4096
|
||||
copyback: false
|
||||
prepare: |
|
||||
pkg install gcc14 curl pkg-config glib2
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
||||
run: |
|
||||
. "$HOME/.cargo/env"
|
||||
cargo build --all-targets && cargo test && cargo test --manifest-path fuzz/Cargo.toml && cargo test -p quinn-udp --benches
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
@@ -19,6 +19,12 @@ fn main() {
|
||||
target_os = "netbsd"
|
||||
)
|
||||
},
|
||||
solarish: {
|
||||
any(
|
||||
target_os = "solaris",
|
||||
target_os = "illumos"
|
||||
)
|
||||
},
|
||||
// Convenience aliases
|
||||
apple_fast: { all(apple, feature = "fast-apple-datapath") },
|
||||
apple_slow: { all(apple, not(feature = "fast-apple-datapath")) },
|
||||
|
||||
+10
-21
@@ -1,4 +1,4 @@
|
||||
#[cfg(not(any(apple, target_os = "openbsd", target_os = "solaris")))]
|
||||
#[cfg(not(any(apple, target_os = "openbsd", solarish)))]
|
||||
use std::ptr;
|
||||
use std::{
|
||||
io::{self, IoSliceMut},
|
||||
@@ -15,8 +15,7 @@ use std::{
|
||||
use socket2::SockRef;
|
||||
|
||||
use super::{
|
||||
cmsg, log::debug, log_sendmsg_error, EcnCodepoint, RecvMeta, Transmit, UdpSockRef,
|
||||
IO_ERROR_LOG_INTERVAL,
|
||||
cmsg, log_sendmsg_error, EcnCodepoint, RecvMeta, Transmit, UdpSockRef, IO_ERROR_LOG_INTERVAL,
|
||||
};
|
||||
|
||||
// Adapted from https://github.com/apple-oss-distributions/xnu/blob/8d741a5de7ff4191bf97d57b9f54c2f6d4a15585/bsd/sys/socket_private.h
|
||||
@@ -91,7 +90,7 @@ impl UdpSocketState {
|
||||
|| cfg!(bsd)
|
||||
|| cfg!(apple)
|
||||
|| cfg!(target_os = "android")
|
||||
|| cfg!(target_os = "solaris")
|
||||
|| cfg!(solarish)
|
||||
{
|
||||
cmsg_platform_space +=
|
||||
unsafe { libc::CMSG_SPACE(mem::size_of::<libc::in6_pktinfo>() as _) as usize };
|
||||
@@ -114,12 +113,12 @@ impl UdpSocketState {
|
||||
|
||||
// mac and ios do not support IP_RECVTOS on dual-stack sockets :(
|
||||
// older macos versions also don't have the flag and will error out if we don't ignore it
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", target_os = "solaris")))]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))]
|
||||
if is_ipv4 || !io.only_v6()? {
|
||||
if let Err(_err) =
|
||||
set_socket_option(&*io, libc::IPPROTO_IP, libc::IP_RECVTOS, OPTION_ON)
|
||||
{
|
||||
debug!("Ignoring error setting IP_RECVTOS on socket: {_err:?}");
|
||||
crate::log::debug!("Ignoring error setting IP_RECVTOS on socket: {_err:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +161,7 @@ impl UdpSocketState {
|
||||
)?;
|
||||
}
|
||||
}
|
||||
#[cfg(any(bsd, apple, target_os = "solaris"))]
|
||||
#[cfg(any(bsd, apple, solarish))]
|
||||
// IP_RECVDSTADDR == IP_SENDSRCADDR on FreeBSD
|
||||
// macOS uses only IP_RECVDSTADDR, no IP_SENDSRCADDR on macOS (the same on Solaris)
|
||||
// macOS also supports IP_PKTINFO
|
||||
@@ -446,12 +445,7 @@ fn send(state: &UdpSocketState, io: SockRef<'_>, transmit: &Transmit<'_>) -> io:
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
apple,
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "solaris"
|
||||
)))]
|
||||
#[cfg(not(any(apple, target_os = "openbsd", target_os = "netbsd", solarish)))]
|
||||
fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) -> io::Result<usize> {
|
||||
let mut names = [MaybeUninit::<libc::sockaddr_storage>::uninit(); BATCH_SIZE];
|
||||
let mut ctrls = [cmsg::Aligned(MaybeUninit::<[u8; CMSG_LEN]>::uninit()); BATCH_SIZE];
|
||||
@@ -518,12 +512,7 @@ fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) ->
|
||||
Ok(msg_count as usize)
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "solaris",
|
||||
apple_slow
|
||||
))]
|
||||
#[cfg(any(target_os = "openbsd", target_os = "netbsd", solarish, apple_slow))]
|
||||
fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) -> io::Result<usize> {
|
||||
let mut name = MaybeUninit::<libc::sockaddr_storage>::uninit();
|
||||
let mut ctrl = cmsg::Aligned(MaybeUninit::<[u8; CMSG_LEN]>::uninit());
|
||||
@@ -616,7 +605,7 @@ fn prepare_msg(
|
||||
};
|
||||
encoder.push(libc::IPPROTO_IP, libc::IP_PKTINFO, pktinfo);
|
||||
}
|
||||
#[cfg(any(bsd, apple, target_os = "solaris"))]
|
||||
#[cfg(any(bsd, apple, solarish))]
|
||||
{
|
||||
if encode_src_ip {
|
||||
let addr = libc::in_addr {
|
||||
@@ -693,7 +682,7 @@ fn decode_recv(
|
||||
ecn_bits = cmsg::decode::<u8, libc::cmsghdr>(cmsg);
|
||||
},
|
||||
// FreeBSD uses IP_RECVTOS here, and we can be liberal because cmsgs are opt-in.
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", target_os = "solaris")))]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))]
|
||||
(libc::IPPROTO_IP, libc::IP_RECVTOS) => unsafe {
|
||||
ecn_bits = cmsg::decode::<u8, libc::cmsghdr>(cmsg);
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", target_os = "solaris")))]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))]
|
||||
use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
|
||||
use std::{
|
||||
io::IoSliceMut,
|
||||
@@ -51,7 +51,7 @@ fn ecn_v6() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", target_os = "solaris")))]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))]
|
||||
fn ecn_v4() {
|
||||
let send = Socket::from(UdpSocket::bind((Ipv4Addr::LOCALHOST, 0)).unwrap());
|
||||
let recv = Socket::from(UdpSocket::bind((Ipv4Addr::LOCALHOST, 0)).unwrap());
|
||||
@@ -71,7 +71,7 @@ fn ecn_v4() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", target_os = "solaris")))]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))]
|
||||
fn ecn_v6_dualstack() {
|
||||
let recv = socket2::Socket::new(
|
||||
socket2::Domain::IPV6,
|
||||
@@ -117,7 +117,7 @@ fn ecn_v6_dualstack() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", target_os = "solaris")))]
|
||||
#[cfg(not(any(target_os = "openbsd", target_os = "netbsd", solarish)))]
|
||||
fn ecn_v4_mapped_v6() {
|
||||
let send = socket2::Socket::new(
|
||||
socket2::Domain::IPV6,
|
||||
|
||||
+4
-1
@@ -387,7 +387,10 @@ async fn zero_rtt() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(target_os = "solaris", ignore = "Fails on Solaris")]
|
||||
#[cfg_attr(
|
||||
any(target_os = "solaris", target_os = "illumos"),
|
||||
ignore = "Fails on Solaris and Illumos"
|
||||
)]
|
||||
fn echo_v6() {
|
||||
run_echo(EchoArgs {
|
||||
client_addr: SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), 0),
|
||||
|
||||
Reference in New Issue
Block a user