Skip to content

Commit a90b454

Browse files
committed
Expose UDP GSO/GRO on android
1 parent 09d66fe commit a90b454

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ targets = [
2828
]
2929

3030
[dependencies]
31-
libc = { version = "=0.2.172", features = ["extra_traits"] }
31+
libc = { version = "=0.2.175", features = ["extra_traits"] }
3232
bitflags = "2.3.3"
3333
cfg-if = "1.0"
3434
pin-utils = { version = "0.1.0", optional = true }

changelog/0.added.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Added the UDP GSO/GRO socket options and CMsgs on Android. This includes the following types:
2+
- UdpGsoSegment
3+
- UdpGroSegment
4+
- ControlMessage::UdpGsoSegments
5+
- ControlMessageOwned::UdpGroSegments

src/sys/socket/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ pub enum ControlMessageOwned {
912912
///
913913
/// `UdpGroSegment` socket option should be enabled on a socket
914914
/// to allow receiving GRO packets.
915-
#[cfg(target_os = "linux")]
915+
#[cfg(linux_android)]
916916
#[cfg(feature = "net")]
917917
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
918918
UdpGroSegments(i32),
@@ -1087,7 +1087,7 @@ impl ControlMessageOwned {
10871087
let dl = unsafe { ptr::read_unaligned(p as *const libc::sockaddr_in) };
10881088
ControlMessageOwned::Ipv4OrigDstAddr(dl)
10891089
},
1090-
#[cfg(target_os = "linux")]
1090+
#[cfg(linux_android)]
10911091
#[cfg(feature = "net")]
10921092
(libc::SOL_UDP, libc::UDP_GRO) => {
10931093
let gso_size: i32 = unsafe { ptr::read_unaligned(p as *const _) };
@@ -1265,7 +1265,7 @@ pub enum ControlMessage<'a> {
12651265
/// passed through this control message.
12661266
/// Send buffer should consist of multiple fixed-size wire payloads
12671267
/// following one by one, and the last, possibly smaller one.
1268-
#[cfg(target_os = "linux")]
1268+
#[cfg(linux_android)]
12691269
#[cfg(feature = "net")]
12701270
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
12711271
UdpGsoSegments(&'a u16),
@@ -1437,7 +1437,7 @@ impl ControlMessage<'_> {
14371437
ControlMessage::AlgSetAeadAssoclen(len) => {
14381438
len as *const _ as *const u8
14391439
},
1440-
#[cfg(target_os = "linux")]
1440+
#[cfg(linux_android)]
14411441
#[cfg(feature = "net")]
14421442
ControlMessage::UdpGsoSegments(gso_size) => {
14431443
gso_size as *const _ as *const u8
@@ -1515,7 +1515,7 @@ impl ControlMessage<'_> {
15151515
ControlMessage::AlgSetAeadAssoclen(len) => {
15161516
mem::size_of_val(len)
15171517
},
1518-
#[cfg(target_os = "linux")]
1518+
#[cfg(linux_android)]
15191519
#[cfg(feature = "net")]
15201520
ControlMessage::UdpGsoSegments(gso_size) => {
15211521
mem::size_of_val(gso_size)
@@ -1572,7 +1572,7 @@ impl ControlMessage<'_> {
15721572
#[cfg(linux_android)]
15731573
ControlMessage::AlgSetIv(_) | ControlMessage::AlgSetOp(_) |
15741574
ControlMessage::AlgSetAeadAssoclen(_) => libc::SOL_ALG,
1575-
#[cfg(target_os = "linux")]
1575+
#[cfg(linux_android)]
15761576
#[cfg(feature = "net")]
15771577
ControlMessage::UdpGsoSegments(_) => libc::SOL_UDP,
15781578
#[cfg(any(linux_android, target_os = "netbsd", apple_targets))]
@@ -1624,7 +1624,7 @@ impl ControlMessage<'_> {
16241624
ControlMessage::AlgSetAeadAssoclen(_) => {
16251625
libc::ALG_SET_AEAD_ASSOCLEN
16261626
},
1627-
#[cfg(target_os = "linux")]
1627+
#[cfg(linux_android)]
16281628
#[cfg(feature = "net")]
16291629
ControlMessage::UdpGsoSegments(_) => {
16301630
libc::UDP_SEGMENT

src/sys/socket/sockopt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ sockopt_impl!(
11201120
libc::IP_ORIGDSTADDR,
11211121
bool
11221122
);
1123-
#[cfg(target_os = "linux")]
1123+
#[cfg(linux_android)]
11241124
#[cfg(feature = "net")]
11251125
sockopt_impl!(
11261126
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -1132,7 +1132,7 @@ sockopt_impl!(
11321132
libc::UDP_SEGMENT,
11331133
libc::c_int
11341134
);
1135-
#[cfg(target_os = "linux")]
1135+
#[cfg(linux_android)]
11361136
#[cfg(feature = "net")]
11371137
sockopt_impl!(
11381138
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]

test/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ cfg_if! {
111111
}
112112

113113
cfg_if! {
114-
if #[cfg(target_os = "linux")] {
114+
if #[cfg(linux_android)] {
115115
#[macro_export] macro_rules! require_kernel_version {
116116
($name:expr, $version_requirement:expr) => {
117117
use semver::{Version, VersionReq};

test/sys/test_socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ mod recvfrom {
462462
assert_eq!(AddressFamily::Inet, from.unwrap().family().unwrap());
463463
}
464464

465-
#[cfg(target_os = "linux")]
465+
#[cfg(linux_android)]
466466
mod udp_offload {
467467
use super::*;
468468
use nix::sys::socket::sockopt::{UdpGroSegment, UdpGsoSegment};

0 commit comments

Comments
 (0)