#include <net/sock.h>
 #include <net/tcp.h>
 #include <net/tls.h>
+#include <net/tls_prot.h>
 #include <net/handshake.h>
 #include <linux/blk-mq.h>
 #include <crypto/hash.h>
 {
        struct nvme_tcp_icreq_pdu *icreq;
        struct nvme_tcp_icresp_pdu *icresp;
+       char cbuf[CMSG_LEN(sizeof(char))] = {};
+       u8 ctype;
        struct msghdr msg = {};
        struct kvec iov;
        bool ctrl_hdgst, ctrl_ddgst;
        memset(&msg, 0, sizeof(msg));
        iov.iov_base = icresp;
        iov.iov_len = sizeof(*icresp);
+       if (queue->ctrl->ctrl.opts->tls) {
+               msg.msg_control = cbuf;
+               msg.msg_controllen = sizeof(cbuf);
+       }
        ret = kernel_recvmsg(queue->sock, &msg, &iov, 1,
                        iov.iov_len, msg.msg_flags);
        if (ret < 0)
                goto free_icresp;
-
+       if (queue->ctrl->ctrl.opts->tls) {
+               ctype = tls_get_record_type(queue->sock->sk,
+                                           (struct cmsghdr *)cbuf);
+               if (ctype != TLS_RECORD_TYPE_DATA) {
+                       pr_err("queue %d: unhandled TLS record %d\n",
+                              nvme_tcp_queue_id(queue), ctype);
+                       return -ENOTCONN;
+               }
+       }
        ret = -EINVAL;
        if (icresp->hdr.type != nvme_tcp_icresp) {
                pr_err("queue %d: bad type returned %d\n",