Skip to content

Commit

Permalink
Raising the CMSG_LEN constant for unix
Browse files Browse the repository at this point in the history
  • Loading branch information
recatek committed Feb 10, 2025
1 parent f2d7508 commit 194ff4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions quinn-udp/src/cmsg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl<M: MsgHdr> Drop for Encoder<'_, M> {
/// `cmsg` must refer to a native cmsg containing a payload of type `T`
pub(crate) unsafe fn decode<T: Copy, C: CMsgHdr>(cmsg: &impl CMsgHdr) -> T {
assert!(mem::align_of::<T>() <= mem::align_of::<C>());
// If you're hitting this, you might need to raise the CMSG_LEN constants
debug_assert_eq!(cmsg.len(), C::cmsg_len(mem::size_of::<T>()));
ptr::read(cmsg.cmsg_data() as *const T)
}
Expand Down
7 changes: 6 additions & 1 deletion quinn-udp/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ impl UdpSocketState {
unsafe { libc::CMSG_SPACE(mem::size_of::<libc::in6_pktinfo>() as _) as usize };
}

if cfg!(target_os = "linux") {
cmsg_platform_space +=
unsafe { libc::CMSG_SPACE(mem::size_of::<libc::timeval>() as _) as usize };
}

assert!(
CMSG_LEN
>= unsafe { libc::CMSG_SPACE(mem::size_of::<libc::c_int>() as _) as usize }
Expand Down Expand Up @@ -551,7 +556,7 @@ fn recv(io: SockRef<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta]) ->
Ok(1)
}

const CMSG_LEN: usize = 88;
const CMSG_LEN: usize = 96;

fn prepare_msg(
transmit: &Transmit<'_>,
Expand Down

0 comments on commit 194ff4d

Please sign in to comment.