MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sbcompress_ktls_rx

Function sbcompress_ktls_rx

freebsd/kern/uipc_sockbuf.c:1372–1421  ·  view source on GitHub ↗

* A version of sbcompress() for encrypted TLS RX mbufs. These mbufs * are appended to the 'sb_mtls' chain instead of 'sb_mb' and are also * a bit simpler (no EOR markers, always MT_DATA, etc.). */

Source from the content-addressed store, hash-verified

1370 * a bit simpler (no EOR markers, always MT_DATA, etc.).
1371 */
1372static void
1373sbcompress_ktls_rx(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
1374{
1375
1376 SOCKBUF_LOCK_ASSERT(sb);
1377
1378 while (m) {
1379 KASSERT((m->m_flags & M_EOR) == 0,
1380 ("TLS RX mbuf %p with EOR", m));
1381 KASSERT(m->m_type == MT_DATA,
1382 ("TLS RX mbuf %p is not MT_DATA", m));
1383 KASSERT((m->m_flags & M_NOTREADY) != 0,
1384 ("TLS RX mbuf %p ready", m));
1385 KASSERT((m->m_flags & M_EXTPG) == 0,
1386 ("TLS RX mbuf %p unmapped", m));
1387
1388 if (m->m_len == 0) {
1389 m = m_free(m);
1390 continue;
1391 }
1392
1393 /*
1394 * Even though both 'n' and 'm' are NOTREADY, it's ok
1395 * to coalesce the data.
1396 */
1397 if (n &&
1398 M_WRITABLE(n) &&
1399 ((sb->sb_flags & SB_NOCOALESCE) == 0) &&
1400 !(n->m_flags & (M_EXTPG)) &&
1401 m->m_len <= MCLBYTES / 4 && /* XXX: Don't copy too much */
1402 m->m_len <= M_TRAILINGSPACE(n)) {
1403 m_copydata(m, 0, m->m_len, mtodo(n, n->m_len));
1404 n->m_len += m->m_len;
1405 sb->sb_ccc += m->m_len;
1406 sb->sb_tlscc += m->m_len;
1407 m = m_free(m);
1408 continue;
1409 }
1410 if (n)
1411 n->m_next = m;
1412 else
1413 sb->sb_mtls = m;
1414 sb->sb_mtlstail = m;
1415 sballoc_ktls_rx(sb, m);
1416 n = m;
1417 m = m->m_next;
1418 n->m_next = NULL;
1419 }
1420 SBLASTMBUFCHK(sb);
1421}
1422#endif
1423
1424/*

Callers 1

sbappend_ktls_rxFunction · 0.85

Calls 3

m_copydataFunction · 0.85
sballoc_ktls_rxFunction · 0.85
m_freeFunction · 0.50

Tested by

no test coverage detected