enable sendmmsg/recvmmsg on solaris

This commit is contained in:
Zhang Jingqiang 2025-03-31 22:43:10 +08:00
parent d0278049da
commit dafc49263e
20 changed files with 50 additions and 2 deletions

View file

@ -25,6 +25,7 @@ use g3_io_ext::{AsyncUdpRecv, UdpRelayRemoteError, UdpRelayRemoteRecv};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use g3_io_ext::{RecvMsgHdr, UdpRelayPacket, UdpRelayPacketMeta};
use g3_types::net::UpstreamAddr;
@ -103,6 +104,7 @@ where
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
inner: &mut T,
@ -160,6 +162,7 @@ where
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,

View file

@ -29,6 +29,7 @@ use g3_io_ext::{AsyncUdpSend, UdpRelayRemoteError, UdpRelayRemoteSend};
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
use g3_io_ext::{SendMsgHdr, UdpRelayPacket};
use g3_resolver::{ResolveError, ResolveLocalError};
@ -285,6 +286,7 @@ where
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_send_packets(
inner: &mut T,
@ -341,6 +343,7 @@ where
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -29,6 +29,7 @@ use g3_io_ext::{AsyncUdpRecv, UdpRelayRemoteError, UdpRelayRemoteRecv};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use g3_io_ext::{RecvMsgHdr, UdpRelayPacket, UdpRelayPacketMeta};
use g3_socks::v5::UdpInput;
@ -135,6 +136,7 @@ where
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,

View file

@ -26,6 +26,7 @@ use g3_io_ext::{AsyncUdpSend, UdpRelayRemoteError, UdpRelayRemoteSend};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use g3_io_ext::{SendMsgHdr, UdpRelayPacket};
use g3_socks::v5::SocksUdpHeader;
@ -86,6 +87,7 @@ where
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -27,6 +27,7 @@ use g3_io_ext::{AsyncUdpRecv, UdpRelayClientError, UdpRelayClientRecv};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use g3_io_ext::{RecvMsgHdr, UdpRelayPacket, UdpRelayPacketMeta};
use g3_socks::v5::UdpInput;
@ -242,6 +243,7 @@ where
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,

View file

@ -26,6 +26,7 @@ use g3_io_ext::{AsyncUdpSend, UdpRelayClientError, UdpRelayClientSend};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use g3_io_ext::{SendMsgHdr, UdpRelayPacket};
use g3_socks::v5::SocksUdpHeader;
@ -83,6 +84,7 @@ where
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -27,6 +27,7 @@ use g3_io_ext::{AsyncUdpRecv, UdpCopyClientError, UdpCopyClientRecv};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use g3_io_ext::{RecvMsgHdr, UdpCopyPacket, UdpCopyPacketMeta};
use g3_socks::v5::UdpInput;
@ -168,6 +169,7 @@ where
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,

View file

@ -25,6 +25,7 @@ use g3_io_ext::{AsyncUdpSend, UdpCopyClientError, UdpCopyClientSend};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use g3_io_ext::{SendMsgHdr, UdpCopyPacket};
use g3_socks::v5::UdpOutput;
@ -81,6 +82,7 @@ where
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -26,6 +26,7 @@ use thiserror::Error;
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use super::UdpCopyPacket;
@ -63,6 +64,7 @@ pub trait UdpCopyClientRecv {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,
@ -86,6 +88,7 @@ pub trait UdpCopyClientSend {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -157,6 +157,7 @@ impl<T: UdpCopyClientRecv + ?Sized> UdpCopyRecv for ClientRecv<'_, T> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,
@ -194,6 +195,7 @@ impl<T: UdpCopyRemoteRecv + ?Sized> UdpCopyRecv for RemoteRecv<'_, T> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,
@ -256,6 +258,7 @@ impl<T: UdpCopyClientSend + ?Sized> UdpCopySend for ClientSend<'_, T> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,
@ -288,6 +291,7 @@ impl<T: UdpCopyRemoteSend + ?Sized> UdpCopySend for RemoteSend<'_, T> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -26,6 +26,7 @@ use thiserror::Error;
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use super::UdpCopyPacket;
@ -63,6 +64,7 @@ pub trait UdpCopyRemoteRecv {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,
@ -86,6 +88,7 @@ pub trait UdpCopyRemoteSend {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -230,6 +230,7 @@ impl UdpSocketExt for UdpSocket {
target_os = "netbsd",
target_os = "openbsd",
target_os = "illumos",
target_os = "solaris",
))]
let flags: SendFlags = SendFlags::DONTWAIT | SendFlags::NOSIGNAL;
#[cfg(target_os = "macos")]
@ -266,6 +267,7 @@ impl UdpSocketExt for UdpSocket {
target_os = "netbsd",
target_os = "openbsd",
target_os = "illumos",
target_os = "solaris",
))]
let flags: SendFlags = SendFlags::DONTWAIT | SendFlags::NOSIGNAL;
#[cfg(target_os = "macos")]

View file

@ -31,6 +31,7 @@ use tokio::time::{Instant, Sleep};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use super::RecvMsgHdr;
use crate::limit::{DatagramLimitAction, DatagramLimiter};
@ -52,6 +53,7 @@ pub trait AsyncUdpRecv {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_batch_recvmsg<const C: usize>(
&mut self,
@ -219,6 +221,7 @@ where
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_batch_recvmsg<const C: usize>(
&mut self,

View file

@ -28,6 +28,7 @@ use g3_types::net::UpstreamAddr;
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use super::UdpRelayPacket;
@ -67,6 +68,7 @@ pub trait UdpRelayClientRecv {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,
@ -91,6 +93,7 @@ pub trait UdpRelayClientSend {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -175,6 +175,7 @@ impl<T: UdpRelayClientRecv + ?Sized> UdpRelayRecv for ClientRecv<'_, T> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,
@ -213,6 +214,7 @@ impl<T: UdpRelayRemoteRecv + ?Sized> UdpRelayRecv for RemoteRecv<'_, T> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,
@ -275,6 +277,7 @@ impl<T: UdpRelayClientSend + ?Sized> UdpRelaySend for ClientSend<'_, T> {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_send_packets(
&mut self,

View file

@ -71,6 +71,7 @@ pub trait UdpRelayRemoteRecv {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv_packets(
&mut self,

View file

@ -31,6 +31,7 @@ use tokio::time::{Instant, Sleep};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use super::SendMsgHdr;
use crate::limit::{DatagramLimitAction, DatagramLimiter};
@ -59,6 +60,7 @@ pub trait AsyncUdpSend {
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_batch_sendmsg<const C: usize>(
&mut self,
@ -286,6 +288,7 @@ where
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_batch_sendmsg<const C: usize>(
&mut self,

View file

@ -32,6 +32,7 @@ use super::{AsyncUdpRecv, AsyncUdpSend, UdpSocketExt};
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
use super::{RecvMsgHdr, SendMsgHdr};
@ -107,6 +108,7 @@ impl AsyncUdpSend for SendHalf {
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
fn poll_batch_sendmsg<const C: usize>(
&mut self,
@ -160,6 +162,7 @@ impl AsyncUdpRecv for RecvHalf {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_batch_recvmsg<const C: usize>(
&mut self,

View file

@ -240,6 +240,7 @@ impl AsyncUdpSocket for Socks5UdpSocket {
target_os = "netbsd",
target_os = "openbsd",
target_os = "macos",
target_os = "solaris",
))]
fn poll_recv(
&self,
@ -284,7 +285,7 @@ impl AsyncUdpSocket for Socks5UdpSocket {
}
}
#[cfg(any(windows, target_os = "dragonfly"))]
#[cfg(any(windows, target_os = "dragonfly", target_os = "illumos"))]
fn poll_recv(
&self,
cx: &mut Context,

View file

@ -53,6 +53,7 @@ impl Sinker {
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
))]
async fn send_udp(&self, packets: &[Vec<u8>]) -> io::Result<()> {
use g3_io_ext::{SendMsgHdr, UdpSocketExt};
@ -88,7 +89,7 @@ impl Sinker {
Ok(())
}
#[cfg(any(windows, target_os = "dragonfly"))]
#[cfg(any(windows, target_os = "dragonfly", target_os = "illumos"))]
async fn send_udp(&self, packets: &[Vec<u8>]) -> io::Result<()> {
for pkt in packets {
self.socket.send(pkt.as_slice()).await?;