https://www.kernel.org/doc/html/latest/networking/msg_zerocopy.html
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
}
do {
- bytes_sent = send(fd, buffer, SOCKET_SEND_BUFFER_SIZE, 0);
+ bytes_sent = send(fd, buffer, SOCKET_SEND_BUFFER_SIZE, MSG_ZEROCOPY);
} while (bytes_sent < 0 && (errno == EAGAIN || errno == EWOULDBLOCK));
// Update statistics
goto ERROR;
}
+ // Enable zero-copy
+ r = setsockopt(fd, SOL_SOCKET, SO_ZEROCOPY, &flags, sizeof(flags));
+ if (r) {
+ ERROR(conf, "Could not set SO_ZEROCOPY on socket %d: %s\n",
+ fd, strerror(errno));
+ goto ERROR;
+ }
+
// Set socket buffer sizes
r = set_socket_buffer_sizes(conf, fd);
if (r)