Make ktls_frame() never fail. Caller must supply correct mbufs.
This makes sendfile code a bit simplier.
This commit is contained in:
parent
f4d9fa6809
commit
f85e1a806b
@ -1046,12 +1046,8 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
|
||||
|
||||
CURVNET_SET(so->so_vnet);
|
||||
#ifdef KERN_TLS
|
||||
if (tls != NULL) {
|
||||
error = ktls_frame(m, tls, &tls_enq_cnt,
|
||||
TLS_RLTYPE_APP);
|
||||
if (error != 0)
|
||||
goto done;
|
||||
}
|
||||
if (tls != NULL)
|
||||
ktls_frame(m, tls, &tls_enq_cnt, TLS_RLTYPE_APP);
|
||||
#endif
|
||||
if (nios == 0) {
|
||||
/*
|
||||
|
@ -1231,7 +1231,7 @@ ktls_seq(struct sockbuf *sb, struct mbuf *m)
|
||||
* encryption. The returned value should be passed to ktls_enqueue
|
||||
* when scheduling encryption of this chain of mbufs.
|
||||
*/
|
||||
int
|
||||
void
|
||||
ktls_frame(struct mbuf *top, struct ktls_session *tls, int *enq_cnt,
|
||||
uint8_t record_type)
|
||||
{
|
||||
@ -1250,10 +1250,8 @@ ktls_frame(struct mbuf *top, struct ktls_session *tls, int *enq_cnt,
|
||||
* records whose payload does not exceed the maximum
|
||||
* frame length.
|
||||
*/
|
||||
if (m->m_len > maxlen || m->m_len == 0)
|
||||
return (EINVAL);
|
||||
tls_len = m->m_len;
|
||||
|
||||
KASSERT(m->m_len <= maxlen && m->m_len > 0,
|
||||
("ktls_frame: m %p len %d\n", m, m->m_len));
|
||||
/*
|
||||
* TLS frames require unmapped mbufs to store session
|
||||
* info.
|
||||
@ -1261,6 +1259,7 @@ ktls_frame(struct mbuf *top, struct ktls_session *tls, int *enq_cnt,
|
||||
KASSERT((m->m_flags & M_NOMAP) != 0,
|
||||
("ktls_frame: mapped mbuf %p (top = %p)\n", m, top));
|
||||
|
||||
tls_len = m->m_len;
|
||||
pgs = m->m_ext.ext_pgs;
|
||||
|
||||
/* Save a reference to the session. */
|
||||
@ -1346,7 +1345,6 @@ ktls_frame(struct mbuf *top, struct ktls_session *tls, int *enq_cnt,
|
||||
*enq_cnt += pgs->npgs;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1591,12 +1591,8 @@ sosend_generic(struct socket *so, struct sockaddr *addr, struct uio *uio,
|
||||
M_NOMAP |
|
||||
((flags & MSG_EOR) ? M_EOR : 0));
|
||||
if (top != NULL) {
|
||||
error = ktls_frame(top, tls,
|
||||
ktls_frame(top, tls,
|
||||
&tls_enq_cnt, tls_rtype);
|
||||
if (error) {
|
||||
m_freem(top);
|
||||
goto release;
|
||||
}
|
||||
}
|
||||
tls_rtype = TLS_RLTYPE_APP;
|
||||
} else
|
||||
|
@ -177,7 +177,7 @@ int ktls_crypto_backend_register(struct ktls_crypto_backend *be);
|
||||
int ktls_crypto_backend_deregister(struct ktls_crypto_backend *be);
|
||||
int ktls_enable_tx(struct socket *so, struct tls_enable *en);
|
||||
void ktls_destroy(struct ktls_session *tls);
|
||||
int ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt,
|
||||
void ktls_frame(struct mbuf *m, struct ktls_session *tls, int *enqueue_cnt,
|
||||
uint8_t record_type);
|
||||
void ktls_seq(struct sockbuf *sb, struct mbuf *m);
|
||||
void ktls_enqueue(struct mbuf *m, struct socket *so, int page_count);
|
||||
|
Loading…
Reference in New Issue
Block a user