Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/uipc_socket.c
Show First 20 Lines • Show All 2,050 Lines • ▼ Show 20 Lines | dontblock: | ||||
* Process one or more MT_CONTROL mbufs present before any data mbufs | * Process one or more MT_CONTROL mbufs present before any data mbufs | ||||
* in the first mbuf chain on the socket buffer. If MSG_PEEK, we | * in the first mbuf chain on the socket buffer. If MSG_PEEK, we | ||||
* just copy the data; if !MSG_PEEK, we call into the protocol to | * just copy the data; if !MSG_PEEK, we call into the protocol to | ||||
* perform externalization (or freeing if controlp == NULL). | * perform externalization (or freeing if controlp == NULL). | ||||
*/ | */ | ||||
if (m != NULL && m->m_type == MT_CONTROL) { | if (m != NULL && m->m_type == MT_CONTROL) { | ||||
struct mbuf *cm = NULL, *cmn; | struct mbuf *cm = NULL, *cmn; | ||||
struct mbuf **cme = &cm; | struct mbuf **cme = &cm; | ||||
#ifdef KERN_TLS | |||||
struct cmsghdr *cmsg; | |||||
struct tls_get_record tgr; | |||||
/* | |||||
* For MSG_TLSAPPDATA, check for a non-application data | |||||
* record. If found, return ENXIO without removing | |||||
* it from the receive queue. This allows a subsequent | |||||
* call without MSG_TLSAPPDATA to receive it. | |||||
* Note that, for TLS, there should only be a single | |||||
* control mbuf with the TLS_GET_RECORD message in it. | |||||
*/ | |||||
if (flags & MSG_TLSAPPDATA) { | |||||
cmsg = mtod(m, struct cmsghdr *); | |||||
if (cmsg->cmsg_type == TLS_GET_RECORD && | |||||
cmsg->cmsg_len == CMSG_LEN(sizeof(tgr))) { | |||||
memcpy(&tgr, CMSG_DATA(cmsg), sizeof(tgr)); | |||||
/* This will need to change for TLS 1.3. */ | |||||
if (tgr.tls_type != TLS_RLTYPE_APP) { | |||||
SOCKBUF_UNLOCK(&so->so_rcv); | |||||
error = ENXIO; | |||||
goto release; | |||||
} | |||||
} | |||||
} | |||||
#endif | |||||
do { | do { | ||||
if (flags & MSG_PEEK) { | if (flags & MSG_PEEK) { | ||||
if (controlp != NULL) { | if (controlp != NULL) { | ||||
*controlp = m_copym(m, 0, m->m_len, | *controlp = m_copym(m, 0, m->m_len, | ||||
M_NOWAIT); | M_NOWAIT); | ||||
controlp = &(*controlp)->m_next; | controlp = &(*controlp)->m_next; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,332 Lines • Show Last 20 Lines |