From: Olivier Houchard Date: Tue, 24 Nov 2026 17:33:04 +0000 (+0100) Subject: BUG/MEDIUM: rawsock: don't take a short kTLS read for the end of data X-Git-Url: https://git.kaiwu.me/web//%22%22?a=commitdiff_plain;h=ece67ea458f516f05ab75b4e4228ece9045bac6a;p=haproxy.git BUG/MEDIUM: rawsock: don't take a short kTLS read for the end of data When a read returns less than requested, raw_sock_to_buf() considers the socket buffer empty, and reports a shutdown if the poller already saw one. But on a kTLS socket recvmsg() returns at most one record, so the following records are never read when the peer's FIN is already there. With "ktls on" on a server closing without a close_notify right after its response, the response is lost and a 502 is returned. Let's not do this for reads using a control message buffer, which are only used for kTLS. This was introduced in 3.3-dev7 by commit 3d685fcb7 ("MINOR: xprt: Add recvmsg() and sendmsg() parameters to rcv_buf() and snd_buf()."). It must be backported to 3.3. --- diff --git a/src/raw_sock.c b/src/raw_sock.c index 08c13ec54..619ad793e 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -311,7 +311,8 @@ static size_t raw_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu if (ret > 0) { b_add(buf, ret); done += ret; - if (ret < try) { + /* with kTLS a short read is only the end of a record */ + if (ret < try && !msg_control) { /* socket buffer exhausted */ fd_cant_recv(conn->handle.fd);