-
Notifications
You must be signed in to change notification settings - Fork 222
Add support for SO_TXTIME #1409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
|
|
||
| /// `getsockopt(fd, SOL_SOCKET, SO_TXTIME)` — Get transmit timing settings. | ||
| #[cfg(all(target_os = "linux", feature = "time"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be #[cfg(linux_kernel)]? I don't get the distinction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linux_kernel is equivalent to any(target_os = "linux", target_os = "android")). If this feature compiles on Android, then we can enable it there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with linux_kernel, so I guess we'll see what happens in CI :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that's a no on android.
|
I just realized this needs the |
f9105fd to
b87a4b0
Compare
| BoottimeAlarm = bitcast!(c::CLOCK_BOOTTIME_ALARM), | ||
| } | ||
|
|
||
| #[cfg(not(any(apple, target_os = "wasi")))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this would be straightforward, but it's really not. libc has clockid_t, while linux-raw-sys has __kernel_clockid_t. Some platforms have neither. What's the best way to proceed with this? I need it for get_txtime, since the kernel returns the configured clock.
Nevermind, importing __kernel_clockid_t as clockid_t fixed it.
25f2f89 to
7372c46
Compare
|
Added |
|
linux-raw-sys 0.9.3 is now released, with sunfishcode/linux-raw-sys#153. |
9a91e1d to
45c36e3
Compare
Great, thanks :) I rebased now and removed the hardcoded declarations. |
This is an undocumented linux feature that lets you time outgoing packets.
|
Hi @sunfishcode, anything needed from me on this? |
This is not actually sufficient for error handling in sendmmsg. The following cases are unconsidered: - Only some of the buffer are sent - Only some of one of the iovecs is sent We'll handle this when we migrate to rustix's sendmmsg, which is waiting on the following PRs: - bytecodealliance/rustix#1171 - bytecodealliance/rustix#1409 Note that those cases should be gracefully-ish handled by FEC and the protocol (they're equivalent to dropped or biffed packets).
|
Thanks! |
|
This is now released in rustix 1.1.1. |
`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)")
* Fix cfgs in sockopt tests `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 (#1409)") * Test `socket_passcred` only for Unix domain sockets 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
This is an undocumented linux feature that lets you time outgoing packets.
This depends on sunfishcode/linux-raw-sys#153.