Skip to content

Commit abc8a5c

Browse files
committed
Fix mistakes, switch to libc fork
1 parent 1611ece commit abc8a5c

File tree

11 files changed

+16
-18
lines changed

11 files changed

+16
-18
lines changed

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ once_cell = { version = "1.5.2", optional = true }
3939
#linux-raw-sys = { version = "0.4.11", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
4040
linux-raw-sys = { git = "https://github.com/arctic-alpaca/linux-raw-sys", branch = "v0.4.11", version = "0.4.11", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
4141
libc_errno = { package = "errno", version = "0.3.8", default-features = false, optional = true }
42-
libc = { version = "0.2.150", default-features = false, features = ["extra_traits"], optional = true }
42+
#libc = { version = "0.2.150", default-features = false, features = ["extra_traits"], optional = true }
43+
libc = { git = "https://github.com/arctic-alpaca/libc", default-features = false, features = ["extra_traits"], optional = true }
4344

4445
# Dependencies for platforms where only libc is supported:
4546
#
4647
# On all other Unix-family platforms, and under Miri, we always use the libc
4748
# backend, so enable its dependencies unconditionally.
4849
[target.'cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies]
4950
libc_errno = { package = "errno", version = "0.3.8", default-features = false }
50-
libc = { version = "0.2.150", default-features = false, features = ["extra_traits"] }
51+
#libc = { version = "0.2.150", default-features = false, features = ["extra_traits"] }
52+
libc = { git = "https://github.com/arctic-alpaca/libc", default-features = false, features = ["extra_traits"] }
5153

5254
# Additional dependencies for Linux with the libc backend:
5355
#
@@ -76,7 +78,8 @@ default-features = false
7678

7779
[dev-dependencies]
7880
tempfile = "3.5.0"
79-
libc = "0.2.150"
81+
#libc = "0.2.150"
82+
libc = {git = "https://github.com/arctic-alpaca/libc"}
8083
libc_errno = { package = "errno", version = "0.3.8", default-features = false }
8184
serial_test = "2.0.0"
8285
memoffset = "0.9.0"

src/backend/libc/net/msghdr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pub(crate) fn with_unix_msghdr<R>(
129129
}
130130

131131
/// Create a message header intended to send with an IPv6 address.
132+
#[cfg(target_os = "linux")]
132133
pub(crate) fn with_xdp_msghdr<R>(
133134
addr: &SocketAddrXdp,
134135
iov: &[IoSlice<'_>],

src/backend/libc/net/read_sockaddr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ pub(crate) unsafe fn read_sockaddr(
201201
return Err(io::Errno::INVAL);
202202
}
203203
let decode = &*storage.cast::<c::sockaddr_xdp>();
204-
SocketAddrAny::Xdp(SocketAddrXdp::new(
204+
Ok(SocketAddrAny::Xdp(SocketAddrXdp::new(
205205
SockaddrXdpFlags::from_bits_retain(decode.sxdp_flags),
206206
u32::from_be(decode.sxdp_ifindex),
207207
u32::from_be(decode.sxdp_queue_id),
208208
u32::from_be(decode.sxdp_shared_umem_fd),
209-
))
209+
)))
210210
}
211211
_ => Err(io::Errno::INVAL),
212212
}

src/backend/libc/net/sockopt.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ use alloc::borrow::ToOwned;
7171
target_os = "illumos"
7272
))]
7373
use alloc::string::String;
74-
use bitflags::Flags;
7574
#[cfg(apple)]
7675
use c::TCP_KEEPALIVE as TCP_KEEPIDLE;
7776
#[cfg(not(any(apple, target_os = "openbsd", target_os = "haiku", target_os = "nto")))]

src/backend/libc/net/syscalls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub(crate) fn sendto_unix(
149149
}
150150
}
151151

152-
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
152+
#[cfg(target_os = "linux")]
153153
pub(crate) fn sendto_xdp(
154154
fd: BorrowedFd<'_>,
155155
buf: &[u8],
@@ -245,8 +245,8 @@ pub(crate) fn bind_xdp(sockfd: BorrowedFd<'_>, addr: &SocketAddrXdp) -> io::Resu
245245
unsafe {
246246
ret(c::bind(
247247
borrowed_fd(sockfd),
248-
as_ptr(&encode_sockaddr_xdp(xdp)).cast(),
249-
size_of::<c::sockaddr_xdp, _>(),
248+
as_ptr(&encode_sockaddr_xdp(addr)).cast(),
249+
size_of::<c::sockaddr_xdp>() as c::socklen_t,
250250
))
251251
}
252252
}

src/backend/libc/net/write_sockaddr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::backend::c;
99
#[cfg(target_os = "linux")]
1010
use crate::net::xdp::SocketAddrXdp;
1111
use crate::net::{SocketAddrAny, SocketAddrV4, SocketAddrV6};
12-
use bitflags::Flags;
1312
use core::mem::size_of;
1413

1514
pub(crate) unsafe fn write_sockaddr(

src/backend/linux_raw/net/sockopt.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::net::{
2424
use alloc::borrow::ToOwned;
2525
#[cfg(feature = "alloc")]
2626
use alloc::string::String;
27-
use bitflags::Flags;
2827
use core::mem::MaybeUninit;
2928
use core::time::Duration;
3029
use linux_raw_sys::general::{__kernel_old_timeval, __kernel_sock_timeval};

src/backend/linux_raw/net/syscalls.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ pub(crate) fn sendto_unix(
621621
}
622622
}
623623

624+
#[cfg(target_os = "linux")]
624625
#[inline]
625626
pub(crate) fn sendto_xdp(
626627
fd: BorrowedFd<'_>,

src/backend/linux_raw/net/write_sockaddr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::backend::c;
66
#[cfg(target_os = "linux")]
77
use crate::net::xdp::SocketAddrXdp;
88
use crate::net::{SocketAddrAny, SocketAddrStorage, SocketAddrUnix, SocketAddrV4, SocketAddrV6};
9-
use bitflags::Flags;
109
use core::mem::size_of;
1110

1211
pub(crate) unsafe fn write_sockaddr(

src/net/socket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::net::{SocketAddr, SocketAddrAny, SocketAddrV4, SocketAddrV6};
33
use crate::{backend, io};
44
use backend::fd::{AsFd, BorrowedFd};
55

6-
use crate::io::Errno;
6+
#[cfg(target_os = "linux")]
77
use crate::net::xdp::SocketAddrXdp;
88
pub use crate::net::{AddressFamily, Protocol, Shutdown, SocketFlags, SocketType};
99
#[cfg(unix)]
@@ -281,7 +281,7 @@ pub fn bind_unix<Fd: AsFd>(sockfd: Fd, addr: &SocketAddrUnix) -> io::Result<()>
281281
/// - [Linux]
282282
///
283283
/// [Linux]: https://man7.org/linux/man-pages/man2/bind.2.html
284-
#[cfg(unix)]
284+
#[cfg(target_os = "linux")]
285285
#[inline]
286286
#[doc(alias = "bind")]
287287
pub fn bind_xdp<Fd: AsFd>(sockfd: Fd, addr: &SocketAddrXdp) -> io::Result<()> {

src/net/sockopt.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,8 @@
143143
#![doc(alias = "getsockopt")]
144144
#![doc(alias = "setsockopt")]
145145

146-
use crate::net::xdp::{XdpMmapOffsets, XdpUmemReg};
147146
#[cfg(target_os = "linux")]
148-
use crate::net::xdp::{XdpOptionsFlags, XdpStatistics};
147+
use crate::net::xdp::{XdpMmapOffsets, XdpOptionsFlags, XdpStatistics, XdpUmemReg};
149148
#[cfg(not(any(
150149
apple,
151150
windows,
@@ -185,8 +184,6 @@ use alloc::string::String;
185184
use backend::c;
186185
use backend::fd::AsFd;
187186
use core::time::Duration;
188-
#[cfg(target_os = "linux")]
189-
use linux_raw_sys::xdp::xdp_mmap_offsets;
190187

191188
/// Timeout identifier for use with [`set_socket_timeout`] and
192189
/// [`get_socket_timeout`].

0 commit comments

Comments
 (0)