From f7431971b40f9516e6c8d280db353fd55d7ac7d7 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Thu, 23 May 2024 00:13:35 +0100 Subject: [PATCH] fix ControlMessageOwned::UdpGroSegments UDP packets processing type. (#2406) * fix ControlMessageOwned::UdpGroSegments UDP packets processing type. The kernel, since 5.0, process the segmentation offload with a signed int. close #2403. * changelog --- changelog/2406.fixed.md | 1 + src/sys/socket/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog/2406.fixed.md diff --git a/changelog/2406.fixed.md b/changelog/2406.fixed.md new file mode 100644 index 0000000000..41bc9c7789 --- /dev/null +++ b/changelog/2406.fixed.md @@ -0,0 +1 @@ +Fixed ControlMessageOwned::UdpGroSegments wrapped type from u16 to i32 to reflect the used kernel's one. diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 10afacf02d..1f1869e90d 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -780,7 +780,7 @@ pub enum ControlMessageOwned { #[cfg(target_os = "linux")] #[cfg(feature = "net")] #[cfg_attr(docsrs, doc(cfg(feature = "net")))] - UdpGroSegments(u16), + UdpGroSegments(i32), /// SO_RXQ_OVFL indicates that an unsigned 32 bit value /// ancilliary msg (cmsg) should be attached to recieved @@ -956,7 +956,7 @@ impl ControlMessageOwned { #[cfg(target_os = "linux")] #[cfg(feature = "net")] (libc::SOL_UDP, libc::UDP_GRO) => { - let gso_size: u16 = unsafe { ptr::read_unaligned(p as *const _) }; + let gso_size: i32 = unsafe { ptr::read_unaligned(p as *const _) }; ControlMessageOwned::UdpGroSegments(gso_size) }, #[cfg(any(linux_android, target_os = "fuchsia"))]