summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2000-11-19 22:22:47 +0000
committerdwmalone <dwmalone@FreeBSD.org>2000-11-19 22:22:47 +0000
commit0d441a8a27905f539fb1e7f85a8ba1cde59cfced (patch)
tree6f4cb0ff6a0d1a28cc9c8553ff200bf5e56c2ed2
parent69fac9d9a29871e0ab89ce7b2cd2de9e5f0a917c (diff)
downloadFreeBSD-src-0d441a8a27905f539fb1e7f85a8ba1cde59cfced.zip
FreeBSD-src-0d441a8a27905f539fb1e7f85a8ba1cde59cfced.tar.gz
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 <iedowse@maths.tcd.ie> and myself. Reviewed by: bmilekic Obtained From: BSDi Submitted by: iedowse
-rw-r--r--sys/kern/uipc_sockbuf.c6
-rw-r--r--sys/kern/uipc_socket2.c6
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);
OpenPOWER on IntegriCloud