Skip to content

Conversation

@pekkarr
Copy link
Contributor

@pekkarr pekkarr commented Oct 25, 2025

This makes the txtime sockopt tests to be run only when the time feature is enabled, otherwise cargo test --features net would fail with a compile error.

Also change the socket_passcred tests to use a Unix domain socket, because on Linux 6.16 and newer the SO_PASSCRED socket option is restricted to only Unix, netlink and Bluetooth sockets.

See the individual commit messages for more details.

`rustix::time` and the txtime socket options are only available with the `time`
feature, but they are unconditionally used in sockopt tests. Mark them with
`cfg(feature = "time")` to enable compiling sockopt tests with just the `net`
feature enabled. Otherwise `cargo test --features net` would end up with a
compile error.

Fixes: 65b04ae ("Add support for SO_TXTIME / SCM_TXTIME (bytecodealliance#1409)")
Since Linux 6.16, `SO_PASSCRED` is allowed only for `AF_UNIX`, `AF_NETLINK` and
`AF_BLUETOOTH` sockets. The tests used to get/set this option for IP sockets,
which doesn't work with new kernels, so make the tests use a Unix domain socket
instead.

On new kernels, the tests fail with:

```
---- sockopt::test_sockopts_ipv6 stdout ----

thread 'sockopt::test_sockopts_ipv6' panicked at tests/net/sockopt.rs:44:42:
called `Result::unwrap()` on an `Err` value: Os { code: 95, kind: Unsupported, message: "Operation not supported" }

---- sockopt::test_sockopts_ipv4 stdout ----

thread 'sockopt::test_sockopts_ipv4' panicked at tests/net/sockopt.rs:44:42:
called `Result::unwrap()` on an `Err` value: Os { code: 95, kind: Unsupported, message: "Operation not supported" }
```

The restriction was introduced to Linux in this commit:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7d8d93fdde50b86bbbf46a203c368ed320e729ab
@sunfishcode sunfishcode merged commit 7f6024b into bytecodealliance:main Oct 25, 2025
39 of 50 checks passed
@sunfishcode
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants