-
Notifications
You must be signed in to change notification settings - Fork 193
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,8 @@ | |
#![doc(alias = "getsockopt")] | ||
#![doc(alias = "setsockopt")] | ||
|
||
#[cfg(all(target_os = "linux", feature = "time"))] | ||
use crate::clockid::ClockId; | ||
#[cfg(target_os = "linux")] | ||
use crate::net::xdp::{XdpMmapOffsets, XdpOptionsFlags, XdpStatistics, XdpUmemReg}; | ||
#[cfg(not(any( | ||
|
@@ -172,6 +174,8 @@ use crate::net::Protocol; | |
use crate::net::SocketAddrV4; | ||
#[cfg(linux_kernel)] | ||
use crate::net::SocketAddrV6; | ||
#[cfg(all(target_os = "linux", feature = "time"))] | ||
use crate::net::TxTimeFlags; | ||
use crate::net::{Ipv4Addr, Ipv6Addr, SocketType}; | ||
use crate::{backend, io}; | ||
#[cfg(feature = "alloc")] | ||
|
@@ -1524,6 +1528,20 @@ pub fn socket_peercred<Fd: AsFd>(fd: Fd) -> io::Result<super::UCred> { | |
backend::net::sockopt::socket_peercred(fd.as_fd()) | ||
} | ||
|
||
/// `getsockopt(fd, SOL_SOCKET, SO_TXTIME)` — Get transmission timing configuration. | ||
#[cfg(all(target_os = "linux", feature = "time"))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that's a no on android. |
||
#[doc(alias = "SO_TXTIME")] | ||
pub fn get_txtime<Fd: AsFd>(fd: Fd) -> io::Result<(ClockId, TxTimeFlags)> { | ||
backend::net::sockopt::get_txtime(fd.as_fd()) | ||
} | ||
|
||
/// `setsockopt(fd, SOL_SOCKET, SO_TXTIME)` — Configure transmission timing. | ||
#[cfg(all(target_os = "linux", feature = "time"))] | ||
#[doc(alias = "SO_TXTIME")] | ||
pub fn set_txtime<Fd: AsFd>(fd: Fd, clockid: ClockId, flags: TxTimeFlags) -> io::Result<()> { | ||
backend::net::sockopt::set_txtime(fd.as_fd(), clockid, flags) | ||
} | ||
|
||
/// `setsockopt(fd, SOL_XDP, XDP_UMEM_REG, value)` | ||
/// | ||
/// On kernel versions only supporting v1, the flags are ignored. | ||
|
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 hasclockid_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 forget_txtime
, since the kernel returns the configured clock.Nevermind, importing
__kernel_clockid_t as clockid_t
fixed it.