Fix IPv6 UDP server TX: use connected socket for single-connection
All checks were successful
CI / test (push) Successful in 1m27s
All checks were successful
CI / test (push) Successful in 1m27s
pcap analysis proved: connected send() achieves 462k pps on IPv6, while unconnected send_to() hits ENOBUFS at 5k pps then stalls. Reverted the "always unconnected for IPv6" workaround. Now only multi-connection mode uses unconnected sockets. Single-connection always connects, which works for both IPv4 and IPv6 TX and RX. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -678,12 +678,11 @@ async fn run_udp_test_server(
|
||||
// (base_port, base_port+1, ..., base_port+N-1) all to our single server port.
|
||||
// A connect()'d UDP socket only accepts from the one connected address,
|
||||
// silently dropping packets from the other ports.
|
||||
// So: only connect() for single-connection mode (enables send() without addr).
|
||||
// For multi-connection, we leave the socket unconnected and use send_to()/recv_from().
|
||||
// Don't connect() UDP socket when:
|
||||
// - Multi-connection mode (MikroTik sends from multiple source ports)
|
||||
// - IPv6 (macOS connected IPv6 UDP sockets have receive issues)
|
||||
let use_unconnected = cmd.tcp_conn_count > 0 || peer.is_ipv6();
|
||||
// Only use unconnected socket for multi-connection mode (MikroTik sends
|
||||
// from multiple source ports). For single-connection, always connect() —
|
||||
// this is critical for IPv6 where send_to() hits ENOBUFS but send() works.
|
||||
// recv_from() works fine on connected sockets for single source.
|
||||
let use_unconnected = cmd.tcp_conn_count > 0;
|
||||
if !use_unconnected {
|
||||
udp.connect(client_udp_addr).await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user