From 87c577ef32fa320fc6f130d01063f5b77a9b019a Mon Sep 17 00:00:00 2001 From: Brando Date: Fri, 18 Aug 2023 15:38:48 -0700 Subject: [PATCH 01/10] Adding to missing macros --- src/unix/linux_like/linux/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 4f9ae623a843..2bdad518ff39 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1829,6 +1829,8 @@ pub const IFLA_INFO_SLAVE_DATA: ::c_ushort = 5; // linux/if_tun.h pub const IFF_TUN: ::c_int = 0x0001; pub const IFF_TAP: ::c_int = 0x0002; +pub const IFF_NAPI: ::c_int = 0x0010; +pub const IFF_NAPI_FRAGS: ::c_int = 0x0020; pub const IFF_NO_PI: ::c_int = 0x1000; // Read queue size pub const TUN_READQ_SIZE: ::c_short = 500; @@ -1846,6 +1848,18 @@ pub const IFF_DETACH_QUEUE: ::c_int = 0x0400; // read-only flag pub const IFF_PERSIST: ::c_int = 0x0800; pub const IFF_NOFILTER: ::c_int = 0x1000; +// Socket options +pub const TUN_TX_TIMESTAMP: ::c_int = 1; +// Features for GSO (TUNSETOFFLOAD) +pub const TUN_F_CSUM: ::c_ushort = 0x01; /* You can hand me unchecksummed packets. */ +pub const TUN_F_TSO4: ::c_ushort = 0x02; /* I can handle TSO for IPv4 packets */ +pub const TUN_F_TSO6: ::c_ushort = 0x04; /* I can handle TSO for IPv6 packets */ +pub const TUN_F_TSO_ECN: ::c_ushort = 0x08; /* I can handle TSO with ECN bits. */ +pub const TUN_F_UFO: ::c_ushort = 0x10; /* I can handle UFO packets */ +// Protocol info prepended to the packets (when IFF_NO_PI is not set) +pub const TUN_PKT_STRIP: ::c_int = 0x0001; +// Accept all multicast packets +pub const TUN_FLT_ALLMULTI: ::c_int = 0x0001; // Since Linux 3.1 pub const SEEK_DATA: ::c_int = 3; From 45b1d00b17ef1fbc3626c1d7af1baa3cb16632a6 Mon Sep 17 00:00:00 2001 From: Brando Date: Wed, 27 Sep 2023 10:01:25 -0700 Subject: [PATCH 02/10] Adding to semver --- libc-test/semver/linux.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index b4091a707047..1e3a56a699a6 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -895,6 +895,14 @@ IFF_MULTICAST IFF_MULTI_QUEUE IFF_NOARP IFF_NOFILTER +TUN_TX_TIMESTAMP +TUN_F_CSUM +TUN_F_TSO4 +TUN_F_TSO6 +TUN_F_TSO_ECN +TUN_F_UFO +TUN_PKT_STRIP +TUN_FLT_ALLMULTI IFF_NOTRAILERS IFF_NO_PI IFF_ONE_QUEUE @@ -906,6 +914,8 @@ IFF_RUNNING IFF_SLAVE IFF_TAP IFF_TUN +IFF_NAPI +IFF_NAPI_FRAGS IFF_TUN_EXCL IFF_UP IFF_VNET_HDR From 8dc0a3247ff562e3d706e9b42a3ce34c95de7fea Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 16 Sep 2023 19:08:13 -0600 Subject: [PATCH 03/10] Revert "Disable FreeBSD 14 CI temporarily" This reverts commit c9643c8768541b18017bbff90b0d6c582e402ed9. New FreeBSD images have been available in gcloud since July. Update the testing image to the latest, 14.0-BETA2 --- .cirrus.yml | 4 +--- ci/build.sh | 14 ++++++-------- ci/install-rust.sh | 3 --- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index dcfff6720629..4e5c9e74a0ad 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -29,9 +29,7 @@ task: task: name: nightly x86_64-unknown-freebsd-14 freebsd_instance: - # FIXME: FreeBSD 14 CI fails due to pkg installation. - # Use 14 again once a new image is available on Cirrus CI. - image_family: freebsd-13-2 + image: freebsd-14-0-beta2-amd64 setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh diff --git a/ci/build.sh b/ci/build.sh index 2a9d68f53859..4f339a603ad3 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -102,6 +102,12 @@ i686-linux-android \ i686-unknown-freebsd \ i686-unknown-linux-gnu \ i686-unknown-linux-musl \ +mips-unknown-linux-gnu \ +mips-unknown-linux-musl \ +mips64-unknown-linux-gnuabi64 \ +mips64el-unknown-linux-gnuabi64 \ +mipsel-unknown-linux-gnu \ +mipsel-unknown-linux-musl \ powerpc-unknown-linux-gnu \ powerpc64-unknown-linux-gnu \ powerpc64le-unknown-linux-gnu \ @@ -112,14 +118,6 @@ x86_64-unknown-linux-musl \ x86_64-unknown-netbsd \ " -# FIXME: builds of MIPS targets are currently broken on nightly. -# mips-unknown-linux-gnu \ -# mips-unknown-linux-musl \ -# mips64-unknown-linux-gnuabi64 \ -# mips64el-unknown-linux-gnuabi64 \ -# mipsel-unknown-linux-gnu \ -# mipsel-unknown-linux-musl \ - RUST_GT_1_13_LINUX_TARGETS="\ arm-unknown-linux-musleabi \ arm-unknown-linux-musleabihf \ diff --git a/ci/install-rust.sh b/ci/install-rust.sh index 3ce81e629993..5b50c624cbd6 100644 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -12,9 +12,6 @@ else # https://github.com/rust-lang/rust/issues/103673 contains related information. case "$TARGET" in *android*) toolchain=nightly-2022-10-09;; - # FIXME: Unpin once mips' components are available on nightly. - # https://rust-lang.github.io/rustup-components-history/mips-unknown-linux-gnu.html - *mips*) toolchain=nightly-2023-07-04;; *) toolchain=nightly;; esac fi From 2f43f142b764ae5a38a658c74984d7948f33b72f Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 3 Oct 2023 19:58:42 -0600 Subject: [PATCH 04/10] WIP making changes for FreeBSD 14.0-beta2 --- libc-test/build.rs | 8 +++++++- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index ffb972cb4145..f213cfe386ec 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2196,6 +2196,12 @@ fn test_freebsd(target: &str) { // should've been used anywhere anyway. "TDF_UNUSED23" => true, + // Removed in FreeBSD 14 (git a6b55ee6be1) + "IFF_KNOWSEPOCH" => true, + + // Removed in FreeBSD 14 (git 7ff9ae90f0b) + "IFF_NOGROUP" => true, + // FIXME: These are deprecated - remove in a couple of releases. // These symbols are not stable across OS-versions. They were // changed for FreeBSD 14 in git revisions b62848b0c3f and @@ -2277,7 +2283,7 @@ fn test_freebsd(target: &str) { // Added in freebsd 14. "IFCAP_MEXTPG" if Some(14) > freebsd_ver => true, // Added in freebsd 13. - "IFF_KNOWSEPOCH" | "IFCAP_TXTLS4" | "IFCAP_TXTLS6" | "IFCAP_VXLAN_HWCSUM" + "IFCAP_TXTLS4" | "IFCAP_TXTLS6" | "IFCAP_VXLAN_HWCSUM" | "IFCAP_VXLAN_HWTSO" | "IFCAP_TXTLS_RTLMT" | "IFCAP_TXTLS" if Some(13) > freebsd_ver => { diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 5fba1447d7ba..d5b7def5f09f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3172,6 +3172,7 @@ pub const IFF_LOOPBACK: ::c_int = 0x8; /// (i) is a point-to-point link pub const IFF_POINTOPOINT: ::c_int = 0x10; /// (i) calls if_input in net epoch +#[deprecated(since = "0.2.149", note = "Removed in FreeBSD 14")] pub const IFF_KNOWSEPOCH: ::c_int = 0x20; /// (d) resources allocated pub const IFF_RUNNING: ::c_int = 0x40; @@ -3219,6 +3220,7 @@ pub const IFF_DYING: ::c_int = 0x200000; /// (n) interface is being renamed pub const IFF_RENAMING: ::c_int = 0x400000; /// interface is not part of any groups +#[deprecated(since = "0.2.149", note = "Removed in FreeBSD 14")] pub const IFF_NOGROUP: ::c_int = 0x800000; /// link invalid/unknown From eb3ff113fc6eb00cc549ca95fbae73ca0d1b0487 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 18 Oct 2023 12:20:20 -0600 Subject: [PATCH 05/10] Update FreeBSD 14 CI image to 14.0-RC1 And update the definition of struct tcp_info for FreeBSD 14. --- .cirrus.yml | 2 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 4e5c9e74a0ad..3a42cc356c25 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -29,7 +29,7 @@ task: task: name: nightly x86_64-unknown-freebsd-14 freebsd_instance: - image: freebsd-14-0-beta2-amd64 + image: freebsd-14-0-rc1-amd64 setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index d5b7def5f09f..797eee798a94 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -998,6 +998,8 @@ s! { pub pcbcnt: u32, } + // Note: this structure will change in a backwards-incompatible way in + // FreeBSD 15. pub struct tcp_info { pub tcpi_state: u8, pub __tcpi_ca_state: u8, @@ -1055,7 +1057,21 @@ s! { #[cfg(freebsd14)] pub __tcpi_received_ce_bytes: u32, #[cfg(freebsd14)] - pub __tcpi_pad: [u32; 19], + pub tcpi_total_tlp: u32, + #[cfg(freebsd14)] + pub tcpi_total_tlp_bytes: u64, + #[cfg(freebsd14)] + pub tcpi_snd_una: u32, + #[cfg(freebsd14)] + pub tcpi_snd_max: u32, + #[cfg(freebsd14)] + pub tcpi_rcv_numsacks: u32, + #[cfg(freebsd14)] + pub tcpi_rcv_adv: u32, + #[cfg(freebsd14)] + pub tcpi_dupacks: u32, + #[cfg(freebsd14)] + pub __tcpi_pad: [u32; 10], #[cfg(not(freebsd14))] pub __tcpi_pad: [u32; 26], } From 01bfa0cdc55dab6a99fd90ea11f65fe10fe58c93 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 18 Oct 2023 13:26:02 -0600 Subject: [PATCH 06/10] cargo fmt --- libc-test/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f213cfe386ec..64101f48cfaa 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2283,8 +2283,8 @@ fn test_freebsd(target: &str) { // Added in freebsd 14. "IFCAP_MEXTPG" if Some(14) > freebsd_ver => true, // Added in freebsd 13. - "IFCAP_TXTLS4" | "IFCAP_TXTLS6" | "IFCAP_VXLAN_HWCSUM" - | "IFCAP_VXLAN_HWTSO" | "IFCAP_TXTLS_RTLMT" | "IFCAP_TXTLS" + "IFCAP_TXTLS4" | "IFCAP_TXTLS6" | "IFCAP_VXLAN_HWCSUM" | "IFCAP_VXLAN_HWTSO" + | "IFCAP_TXTLS_RTLMT" | "IFCAP_TXTLS" if Some(13) > freebsd_ver => { true From 84b65654fb87d10fcdb0ed964ccef3520207bf2c Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 18 Oct 2023 13:42:31 -0600 Subject: [PATCH 07/10] Increase size of cpuset_t on FreeBSD 14 See https://github.com/freebsd/freebsd-src/commit/d1639e43c589644510198dc53aef87e8908a1507 --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 797eee798a94..52203906cc36 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -365,9 +365,13 @@ s! { } pub struct cpuset_t { - #[cfg(target_pointer_width = "64")] + #[cfg(all(freebsd14, target_pointer_width = "64"))] + __bits: [::c_long; 16], + #[cfg(all(freebsd14, target_pointer_width = "32"))] + __bits: [::c_long; 32], + #[cfg(all(not(freebsd14), target_pointer_width = "64"))] __bits: [::c_long; 4], - #[cfg(target_pointer_width = "32")] + #[cfg(all(not(freebsd14), target_pointer_width = "32"))] __bits: [::c_long; 8], } @@ -2615,7 +2619,13 @@ pub const DEVSTAT_N_TRANS_FLAGS: ::c_int = 4; pub const DEVSTAT_NAME_LEN: ::c_int = 16; // sys/cpuset.h -pub const CPU_SETSIZE: ::c_int = 256; +cfg_if! { + if #[cfg(freebsd14)] { + pub const CPU_SETSIZE: ::c_int = 1024; + } else { + pub const CPU_SETSIZE: ::c_int = 256; + } +} pub const SIGEV_THREAD_ID: ::c_int = 4; From 2c3bf6fb5f716a165d5fdc906c13852316cc644e Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Thu, 19 Oct 2023 20:00:47 -0600 Subject: [PATCH 08/10] include sys/timerfd.h in libc-test for FreeBSD. --- libc-test/build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 64101f48cfaa..511317c40166 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1987,6 +1987,10 @@ fn test_freebsd(target: &str) { Some(n) if n >= 13 => true, _ => false, }; + let freebsd14 = match freebsd_ver { + Some(n) if n >= 14 => true, + _ => false, + }; headers! { cfg: "aio.h", @@ -2074,6 +2078,7 @@ fn test_freebsd(target: &str) { "sys/sysctl.h", "sys/thr.h", "sys/time.h", + [freebsd14]:"sys/timerfd.h", "sys/times.h", "sys/timex.h", "sys/types.h", From aa992ce18f7b81bee8fb6e70d6aa3a70ab29c3ea Mon Sep 17 00:00:00 2001 From: Jonathan Dygert Date: Wed, 25 Oct 2023 10:37:21 -0400 Subject: [PATCH 09/10] Add vxworks mmap/shm --- src/vxworks/mod.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index c337a82793e6..21d33a4e5edd 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1018,6 +1018,21 @@ pub const O_WRONLY: ::c_int = 0x0001; pub const O_RDONLY: ::c_int = 0; pub const O_NONBLOCK: ::c_int = 0x4000; +// mman.h +pub const PROT_NONE: ::c_int = 0x0000; +pub const PROT_READ: ::c_int = 0x0001; +pub const PROT_WRITE: ::c_int = 0x0002; +pub const PROT_EXEC: ::c_int = 0x0004; + +pub const MAP_SHARED: ::c_int = 0x0001; +pub const MAP_PRIVATE: ::c_int = 0x0002; +pub const MAP_ANON: ::c_int = 0x0004; +pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; +pub const MAP_FIXED: ::c_int = 0x0010; +pub const MAP_CONTIG: ::c_int = 0x0020; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} impl ::Copy for FILE {} @@ -1218,6 +1233,8 @@ extern "C" { ) -> *mut ::c_void; pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; pub fn truncate(path: *const c_char, length: off_t) -> ::c_int; + pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; pub fn pthread_exit(value: *mut ::c_void) -> !; @@ -1909,19 +1926,19 @@ cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; pub use self::aarch64::*; - } else if #[cfg(any(target_arch = "arm"))] { + } else if #[cfg(target_arch = "arm")] { mod arm; pub use self::arm::*; - } else if #[cfg(any(target_arch = "x86"))] { + } else if #[cfg(target_arch = "x86")] { mod x86; pub use self::x86::*; - } else if #[cfg(any(target_arch = "x86_64"))] { + } else if #[cfg(target_arch = "x86_64")] { mod x86_64; pub use self::x86_64::*; - } else if #[cfg(any(target_arch = "powerpc"))] { + } else if #[cfg(target_arch = "powerpc")] { mod powerpc; pub use self::powerpc::*; - } else if #[cfg(any(target_arch = "powerpc64"))] { + } else if #[cfg(target_arch = "powerpc64")] { mod powerpc64; pub use self::powerpc64::*; } else { From 58121b2cc0592f6f55aa1ca4d2518be450730b63 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 25 Oct 2023 10:42:36 -0600 Subject: [PATCH 10/10] Re-disable linux-mips targets Though not mentioned in the commit message, change c9643c8768541b18017bbff90b0d6c582e402ed9 disabled these along with FreeBSD 14. --- ci/build.sh | 14 ++++++++------ ci/install-rust.sh | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 4f339a603ad3..2a9d68f53859 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -102,12 +102,6 @@ i686-linux-android \ i686-unknown-freebsd \ i686-unknown-linux-gnu \ i686-unknown-linux-musl \ -mips-unknown-linux-gnu \ -mips-unknown-linux-musl \ -mips64-unknown-linux-gnuabi64 \ -mips64el-unknown-linux-gnuabi64 \ -mipsel-unknown-linux-gnu \ -mipsel-unknown-linux-musl \ powerpc-unknown-linux-gnu \ powerpc64-unknown-linux-gnu \ powerpc64le-unknown-linux-gnu \ @@ -118,6 +112,14 @@ x86_64-unknown-linux-musl \ x86_64-unknown-netbsd \ " +# FIXME: builds of MIPS targets are currently broken on nightly. +# mips-unknown-linux-gnu \ +# mips-unknown-linux-musl \ +# mips64-unknown-linux-gnuabi64 \ +# mips64el-unknown-linux-gnuabi64 \ +# mipsel-unknown-linux-gnu \ +# mipsel-unknown-linux-musl \ + RUST_GT_1_13_LINUX_TARGETS="\ arm-unknown-linux-musleabi \ arm-unknown-linux-musleabihf \ diff --git a/ci/install-rust.sh b/ci/install-rust.sh index 5b50c624cbd6..3ce81e629993 100644 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -12,6 +12,9 @@ else # https://github.com/rust-lang/rust/issues/103673 contains related information. case "$TARGET" in *android*) toolchain=nightly-2022-10-09;; + # FIXME: Unpin once mips' components are available on nightly. + # https://rust-lang.github.io/rustup-components-history/mips-unknown-linux-gnu.html + *mips*) toolchain=nightly-2023-07-04;; *) toolchain=nightly;; esac fi