Skip to content

Commit

Permalink
Tolerate wide IP_TOS cmsgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith authored and djc committed Dec 29, 2021
1 parent b2c24d9 commit 91dd91f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion quinn-udp/src/unix.rs
Expand Up @@ -488,7 +488,16 @@ fn decode_recv(
match (cmsg.cmsg_level, cmsg.cmsg_type) {
// FreeBSD uses IP_RECVTOS here, and we can be liberal because cmsgs are opt-in.
(libc::IPPROTO_IP, libc::IP_TOS) | (libc::IPPROTO_IP, libc::IP_RECVTOS) => unsafe {
ecn_bits = cmsg::decode::<u8>(cmsg);
// Linux reportedly returns 4-byte values here instead of the expected, documented
// 1-byte, e.g. in kernel 4.4.0-19041-Microsoft or on Github Actions. Future work:
// find out why, report upstream?
if cmsg.cmsg_len as usize
== libc::CMSG_LEN(mem::size_of::<libc::c_int>() as _) as usize
{
ecn_bits = cmsg::decode::<libc::c_int>(cmsg) as u8;
} else {
ecn_bits = cmsg::decode::<u8>(cmsg);
}
},
(libc::IPPROTO_IPV6, libc::IPV6_TCLASS) => unsafe {
// Temporary hack around broken macos ABI. Remove once upstream fixes it.
Expand Down

0 comments on commit 91dd91f

Please sign in to comment.