From 6fd74181586a4e2a2cfc24548e513775077df76b Mon Sep 17 00:00:00 2001 From: Aaron Drew Date: Tue, 10 Jan 2023 13:53:16 +1100 Subject: [PATCH 1/4] Fix endian swap on SocketAddrV6. flowinfo and scope_id should not be byte swapped. --- CHANGELOG.md | 9 +++++++++ src/sys/socket/addr.rs | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a332bc5f09..648f2d8104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). +## [Unreleased] - ReleaseDate +### Added +### Changed +### Fixed +- Fix `SockaddrIn6` bug that was swapping flowinfo and scope_id byte ordering. + ([#1964](https://github.com/nix-rust/nix/pull/1964)) + +### Removed + ## [0.26.1] - 2022-11-29 ### Added ### Changed diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index 8b23b10cf0..4e565a5b68 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -1476,8 +1476,8 @@ impl From for net::SocketAddrV6 { net::SocketAddrV6::new( net::Ipv6Addr::from(addr.0.sin6_addr.s6_addr), u16::from_be(addr.0.sin6_port), - u32::from_be(addr.0.sin6_flowinfo), - u32::from_be(addr.0.sin6_scope_id), + addr.0.sin6_flowinfo, + addr.0.sin6_scope_id, ) } } @@ -3167,6 +3167,18 @@ mod tests { SockaddrIn6::size() as usize ); } + + #[test] + // Ensure that we can convert to-and-from std::net variants without change. + fn to_and_from() { + let s = "[1234:5678:90ab:cdef::1111:2222]:8080"; + let mut nix_sin6 = SockaddrIn6::from_str(s).unwrap(); + nix_sin6.0.sin6_flowinfo = 0x12345678; + nix_sin6.0.sin6_scope_id = 0x9abcdef0; + + let std_sin6 : std::net::SocketAddrV6 = nix_sin6.into(); + assert_eq!(nix_sin6, std_sin6.into()); + } } mod sockaddr_storage { From 975a3d5c7cdb6948944d86edddfc58dcad31fd2f Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 17 Jan 2023 14:19:16 -0700 Subject: [PATCH 2/4] Tidy up the CHANGELOG a bit. --- CHANGELOG.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 648f2d8104..dd14ec7005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,23 +4,15 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] - ReleaseDate -### Added -### Changed ### Fixed - Fix `SockaddrIn6` bug that was swapping flowinfo and scope_id byte ordering. ([#1964](https://github.com/nix-rust/nix/pull/1964)) -### Removed - ## [0.26.1] - 2022-11-29 -### Added -### Changed ### Fixed - Fix UB with `sys::socket::sockopt::SockType` using `SOCK_PACKET`. ([#1821](https://github.com/nix-rust/nix/pull/1821)) -### Removed - ## [0.26.0] - 2022-11-29 ### Added From 4a83f8b8b5ea93b0dd6e747ada37c5f588b230d5 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 3 Dec 2022 16:46:42 -0700 Subject: [PATCH 3/4] Drop x86_64-unknown-darwin to Tier 2 And promote aarch64-unknown-darwin to Tier 1. Because that's what Cirrus CI is doing. Fixes #1904 --- .cirrus.yml | 14 +++++++------- README.md | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index ab1178dd1a..1e073d707e 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -67,13 +67,13 @@ task: - if [ -z "$NOHACK" ]; then cargo hack check --each-feature --target i686-unknown-freebsd; fi before_cache_script: rm -rf $CARGO_HOME/registry/index -# Test macOS x86_64 in a full VM +# Test macOS aarch64 in a full VM task: - name: macOS x86_64 + name: macOS aarch64 env: - TARGET: x86_64-apple-darwin - osx_instance: - image: big-sur-xcode + TARGET: aarch64-apple-darwin + macos_instance: + image: ghcr.io/cirruslabs/macos-ventura-base:latest setup_script: - curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs - sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN @@ -235,9 +235,9 @@ task: - name: Linux x32 env: TARGET: x86_64-unknown-linux-gnux32 - - name: macOS aarch64 + - name: macOS x86_64 env: - TARGET: aarch64-apple-darwin + TARGET: x86_64-apple-darwin - name: NetBSD x86_64 env: TARGET: x86_64-unknown-netbsd diff --git a/README.md b/README.md index 7597ba0afc..2c42b905f7 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ limitations. Support for platforms is split into three tiers: The following targets are supported by `nix`: Tier 1: + * aarch64-apple-darwin * aarch64-unknown-linux-gnu * arm-unknown-linux-gnueabi * armv7-unknown-linux-gnueabihf @@ -58,13 +59,11 @@ Tier 1: * mips64el-unknown-linux-gnuabi64 * mipsel-unknown-linux-gnu * powerpc64le-unknown-linux-gnu - * x86_64-apple-darwin * x86_64-unknown-freebsd * x86_64-unknown-linux-gnu * x86_64-unknown-linux-musl Tier 2: - * aarch64-apple-darwin * aarch64-apple-ios * aarch64-linux-android * arm-linux-androideabi @@ -75,6 +74,7 @@ Tier 2: * s390x-unknown-linux-gnu * x86_64-apple-ios * x86_64-linux-android + * x86_64-apple-darwin * x86_64-unknown-illumos * x86_64-unknown-netbsd From 8aa85bbf2743ab30a329e86b548d2744bb2383df Mon Sep 17 00:00:00 2001 From: Jonathan Date: Sat, 31 Dec 2022 23:16:46 +0000 Subject: [PATCH 4/4] fix: clippy::size_of_ref --- src/sys/socket/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 2d7159a63a..8513b6fbe7 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -1298,7 +1298,7 @@ impl<'a> ControlMessage<'a> { } #[cfg(any(target_os = "android", target_os = "linux"))] ControlMessage::AlgSetIv(iv) => { - mem::size_of_val(&iv) + iv.len() + mem::size_of::<&[u8]>() + iv.len() }, #[cfg(any(target_os = "android", target_os = "linux"))] ControlMessage::AlgSetOp(op) => {