aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_sockbuf.c
diff options
context:
space:
mode:
authorAndrew Gallatin <gallatin@FreeBSD.org>2020-03-30 23:29:53 +0000
committerAndrew Gallatin <gallatin@FreeBSD.org>2020-03-30 23:29:53 +0000
commitc4ad247b7aa09f2fd9c90c92a23eeebe5c72f256 (patch)
treec7b092d6307518fe7f9682f090fb404e83553896 /sys/kern/uipc_sockbuf.c
parentc506a6386fe1483fd968e467cf5610bea5998d88 (diff)
downloadsrc-c4ad247b7aa09f2fd9c90c92a23eeebe5c72f256.tar.gz
src-c4ad247b7aa09f2fd9c90c92a23eeebe5c72f256.zip
Notes
Diffstat (limited to 'sys/kern/uipc_sockbuf.c')
-rw-r--r--sys/kern/uipc_sockbuf.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index f92f0d55fdff..a1a40cd76c86 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -112,6 +112,41 @@ sbready_compress(struct sockbuf *sb, struct mbuf *m0, struct mbuf *end)
for (m = m0; m != end; m = m->m_next) {
MPASS((m->m_flags & M_NOTREADY) == 0);
+ /*
+ * NB: In sbcompress(), 'n' is the last mbuf in the
+ * socket buffer and 'm' is the new mbuf being copied
+ * into the trailing space of 'n'. Here, the roles
+ * are reversed and 'n' is the next mbuf after 'm'
+ * that is being copied into the trailing space of
+ * 'm'.
+ */
+ n = m->m_next;
+#ifdef KERN_TLS
+ /* Try to coalesce adjacent ktls mbuf hdr/trailers. */
+ if ((n != NULL) && (n != end) && (m->m_flags & M_EOR) == 0 &&
+ (m->m_flags & M_NOMAP) &&
+ (n->m_flags & M_NOMAP) &&
+ !mbuf_has_tls_session(m) &&
+ !mbuf_has_tls_session(n)) {
+ struct mbuf_ext_pgs *mpgs, *npgs;
+ int hdr_len, trail_len;
+
+ mpgs = m->m_ext.ext_pgs;
+ npgs = n->m_ext.ext_pgs;
+ hdr_len = npgs->hdr_len;
+ trail_len = mpgs->trail_len;
+ if (trail_len != 0 && hdr_len != 0 &&
+ trail_len + hdr_len <= MBUF_PEXT_TRAIL_LEN) {
+ /* copy n's header to m's trailer */
+ memcpy(&mpgs->trail[trail_len], npgs->hdr,
+ hdr_len);
+ mpgs->trail_len += hdr_len;
+ m->m_len += hdr_len;
+ npgs->hdr_len = 0;
+ n->m_len -= hdr_len;
+ }
+ }
+#endif
/* Compress small unmapped mbufs into plain mbufs. */
if ((m->m_flags & M_NOMAP) && m->m_len <= MLEN &&
@@ -124,15 +159,6 @@ sbready_compress(struct sockbuf *sb, struct mbuf *m0, struct mbuf *end)
}
}
- /*
- * NB: In sbcompress(), 'n' is the last mbuf in the
- * socket buffer and 'm' is the new mbuf being copied
- * into the trailing space of 'n'. Here, the roles
- * are reversed and 'n' is the next mbuf after 'm'
- * that is being copied into the trailing space of
- * 'm'.
- */
- n = m->m_next;
while ((n != NULL) && (n != end) && (m->m_flags & M_EOR) == 0 &&
M_WRITABLE(m) &&
(m->m_flags & M_NOMAP) == 0 &&