summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryasuoka <yasuoka@openbsd.org>2019-04-16 13:15:32 +0000
committeryasuoka <yasuoka@openbsd.org>2019-04-16 13:15:32 +0000
commit47e36d94cf73fe2760b8471620a58feafe448c87 (patch)
tree535f9bab299036b0933c71449f0c654479bdcc21
parentPrevent attaching drivers to devices for which we attached a driver early. (diff)
downloadwireguard-openbsd-47e36d94cf73fe2760b8471620a58feafe448c87.tar.xz
wireguard-openbsd-47e36d94cf73fe2760b8471620a58feafe448c87.zip
Use the actual cluster size instead of fixed MCLBYTES for the
condition in sb_compress(). Currently the actual cluster size might be 9KB even if the mtu is 1500, in this case a lot of memory space had been wasted, since sbcompress() doesn't compress because of previous condition. ok dlg claudio
-rw-r--r--sys/kern/uipc_socket2.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index 4b9b79100fb..41bd63b1269 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.100 2019/02/15 05:55:21 dlg Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.101 2019/04/16 13:15:32 yasuoka Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -886,7 +886,8 @@ sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
}
if (n && (n->m_flags & M_EOR) == 0 &&
/* m_trailingspace() checks buffer writeability */
- m->m_len <= MCLBYTES / 4 && /* XXX Don't copy too much */
+ m->m_len <= ((n->m_flags & M_EXT)? n->m_ext.ext_size :
+ MCLBYTES) / 4 && /* XXX Don't copy too much */
m->m_len <= m_trailingspace(n) &&
n->m_type == m->m_type) {
memcpy(mtod(n, caddr_t) + n->m_len, mtod(m, caddr_t),