From 0d441a8a27905f539fb1e7f85a8ba1cde59cfced Mon Sep 17 00:00:00 2001 From: dwmalone Date: Sun, 19 Nov 2000 22:22:47 +0000 Subject: Make sbcompress use the new M_WRITABLE macro. Previously sbcompress could not compress into clusters. This could result in lots of wasted clusters while recieving small packets from an interface that uses clusters for all it's packets. Patch is partially from BSDi (limiting the size of the copy) and based on a patch for 4.1 by Ian Dowse and myself. Reviewed by: bmilekic Obtained From: BSDi Submitted by: iedowse --- sys/kern/uipc_sockbuf.c | 6 ++++-- sys/kern/uipc_socket2.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index 4ed67e5..5da42b0 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -718,8 +718,10 @@ sbcompress(sb, m, n) m = m_free(m); continue; } - if (n && (n->m_flags & (M_EXT | M_EOR)) == 0 && - (n->m_data + n->m_len + m->m_len) < &n->m_dat[MLEN] && + if (n && (n->m_flags & M_EOR) == 0 && + M_WRITABLE(n) && + m->m_len <= MCLBYTES / 4 && /* XXX: Don't copy too much */ + m->m_len <= M_TRAILINGSPACE(n) && n->m_type == m->m_type) { bcopy(mtod(m, caddr_t), mtod(n, caddr_t) + n->m_len, (unsigned)m->m_len); diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 4ed67e5..5da42b0 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -718,8 +718,10 @@ sbcompress(sb, m, n) m = m_free(m); continue; } - if (n && (n->m_flags & (M_EXT | M_EOR)) == 0 && - (n->m_data + n->m_len + m->m_len) < &n->m_dat[MLEN] && + if (n && (n->m_flags & M_EOR) == 0 && + M_WRITABLE(n) && + m->m_len <= MCLBYTES / 4 && /* XXX: Don't copy too much */ + m->m_len <= M_TRAILINGSPACE(n) && n->m_type == m->m_type) { bcopy(mtod(m, caddr_t), mtod(n, caddr_t) + n->m_len, (unsigned)m->m_len); -- cgit v1.1