mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 12:36:52 +01:00
WriteBatch hands up to 64 datagrams to one sendmsg_x call instead of one sendto each. The socket is unconnected, so xnu still runs every message through sendit, per-send MAC checks included; the saving is the syscall crossings. xnu's per-message loop stops at the first message that fails. For EWOULDBLOCK, ENOBUFS and EMSGSIZE it reports how many went out, or the errno alone when none did; for any other error it returns only the errno, with the messages before it already sent. So each call carries one run of datagrams to a single destination, and nothing is resent after the kernel may have taken it. A datagram that fails on its own account (a full interface queue, an oversize packet) goes to sendto, which delivers or reports it, so it costs only itself, as without batching; a refused destination costs its run. ENOSYS/EOPNOTSUPP, or EPERM/EINVAL on a datagram sendto then delivers, switch the socket back to sendto for good. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>