Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ targets = [
]

[dependencies]
libc = { version = "=0.2.172", features = ["extra_traits"] }
libc = { version = "=0.2.175", features = ["extra_traits"] }
bitflags = "2.3.3"
cfg-if = "1.0"
pin-utils = { version = "0.1.0", optional = true }
Expand Down
5 changes: 5 additions & 0 deletions changelog/2666.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Added the UDP GSO/GRO socket options and CMsgs on Android. This includes the following types:
- UdpGsoSegment
- UdpGroSegment
- ControlMessage::UdpGsoSegments
- ControlMessageOwned::UdpGroSegments
14 changes: 7 additions & 7 deletions src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ pub enum ControlMessageOwned {
///
/// `UdpGroSegment` socket option should be enabled on a socket
/// to allow receiving GRO packets.
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
UdpGroSegments(i32),
Expand Down Expand Up @@ -1087,7 +1087,7 @@ impl ControlMessageOwned {
let dl = unsafe { ptr::read_unaligned(p as *const libc::sockaddr_in) };
ControlMessageOwned::Ipv4OrigDstAddr(dl)
},
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
(libc::SOL_UDP, libc::UDP_GRO) => {
let gso_size: i32 = unsafe { ptr::read_unaligned(p as *const _) };
Expand Down Expand Up @@ -1265,7 +1265,7 @@ pub enum ControlMessage<'a> {
/// passed through this control message.
/// Send buffer should consist of multiple fixed-size wire payloads
/// following one by one, and the last, possibly smaller one.
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
UdpGsoSegments(&'a u16),
Expand Down Expand Up @@ -1437,7 +1437,7 @@ impl ControlMessage<'_> {
ControlMessage::AlgSetAeadAssoclen(len) => {
len as *const _ as *const u8
},
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
ControlMessage::UdpGsoSegments(gso_size) => {
gso_size as *const _ as *const u8
Expand Down Expand Up @@ -1515,7 +1515,7 @@ impl ControlMessage<'_> {
ControlMessage::AlgSetAeadAssoclen(len) => {
mem::size_of_val(len)
},
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
ControlMessage::UdpGsoSegments(gso_size) => {
mem::size_of_val(gso_size)
Expand Down Expand Up @@ -1572,7 +1572,7 @@ impl ControlMessage<'_> {
#[cfg(linux_android)]
ControlMessage::AlgSetIv(_) | ControlMessage::AlgSetOp(_) |
ControlMessage::AlgSetAeadAssoclen(_) => libc::SOL_ALG,
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
ControlMessage::UdpGsoSegments(_) => libc::SOL_UDP,
#[cfg(any(linux_android, target_os = "netbsd", apple_targets))]
Expand Down Expand Up @@ -1624,7 +1624,7 @@ impl ControlMessage<'_> {
ControlMessage::AlgSetAeadAssoclen(_) => {
libc::ALG_SET_AEAD_ASSOCLEN
},
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
ControlMessage::UdpGsoSegments(_) => {
libc::UDP_SEGMENT
Expand Down
4 changes: 2 additions & 2 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ sockopt_impl!(
libc::IP_ORIGDSTADDR,
bool
);
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Expand All @@ -1132,7 +1132,7 @@ sockopt_impl!(
libc::UDP_SEGMENT,
libc::c_int
);
#[cfg(target_os = "linux")]
#[cfg(linux_android)]
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Expand Down
2 changes: 1 addition & 1 deletion test/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ cfg_if! {
}

cfg_if! {
if #[cfg(target_os = "linux")] {
if #[cfg(linux_android)] {
#[macro_export] macro_rules! require_kernel_version {
($name:expr, $version_requirement:expr) => {
use semver::{Version, VersionReq};
Expand Down
2 changes: 1 addition & 1 deletion test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ mod recvfrom {
assert_eq!(AddressFamily::Inet, from.unwrap().family().unwrap());
}

#[cfg(target_os = "linux")]
#[cfg(linux_android)]
mod udp_offload {
use super::*;
use nix::sys::socket::sockopt::{UdpGroSegment, UdpGsoSegment};
Expand Down