Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(udp): use libc::recvmmsg on Android x86 #1964

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 18 additions & 1 deletion quinn-udp/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ unsafe fn recvmmsg_with_fallback(
let flags = 0;
let timeout = ptr::null_mut::<libc::timespec>();

#[cfg(not(any(target_os = "freebsd", target_os = "netbsd")))]
#[cfg(not(any(
target_os = "freebsd",
target_os = "netbsd",
all(target_os = "android", target_arch = "x86")
)))]
{
let ret =
libc::syscall(libc::SYS_recvmmsg, sockfd, msgvec, vlen, flags, timeout) as libc::c_int;
Expand All @@ -468,6 +472,19 @@ unsafe fn recvmmsg_with_fallback(
}
}

// On Android x86 seccomp only allows `recvmmsg` dispatched through
// `socketcall`. The bionic libc implementation automatically dispatches
// `recvmmsg` through `socketcall` when calling `libc::recvmmsg`. Calling
// `SYS-recvmmsg` directly (i.e. `syscall(SYS_recvmmsg)`) does not dispatch
// through `socketcall` and is thus disallowed by seccomp.
#[cfg(all(target_os = "android", target_arch = "x86"))]
{
let ret = libc::recvmmsg(sockfd, msgvec, vlen, flags, timeout) as libc::c_int;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks identical to the *BSD call above. Should we fold them together?

if ret != -1 {
return ret;
}
}

let e = io::Error::last_os_error();
match e.raw_os_error() {
Some(libc::ENOSYS) => {
Expand Down