summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_ipcomp.c
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2016-09-13 19:56:55 +0000
committermarkus <markus@openbsd.org>2016-09-13 19:56:55 +0000
commit5db30710efad2fc261c0d000da047a3d4bf759c7 (patch)
tree666db9a1276e56803a47722944569dc8c5e28c7d /sys/netinet/ip_ipcomp.c
parentDo not mention the libiconv module; it has been removed. (diff)
downloadwireguard-openbsd-5db30710efad2fc261c0d000da047a3d4bf759c7.tar.xz
wireguard-openbsd-5db30710efad2fc261c0d000da047a3d4bf759c7.zip
avoid extensive mbuf allocation for IPsec by replacing m_inject(4)
with m_makespace(4) from freebsd; ok mpi@, bluhm@, mikeb@, dlg@
Diffstat (limited to 'sys/netinet/ip_ipcomp.c')
-rw-r--r--sys/netinet/ip_ipcomp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c
index 120511bf37e..721fe0f40e0 100644
--- a/sys/netinet/ip_ipcomp.c
+++ b/sys/netinet/ip_ipcomp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipcomp.c,v 1.46 2016/08/18 06:01:10 dlg Exp $ */
+/* $OpenBSD: ip_ipcomp.c,v 1.47 2016/09/13 19:56:55 markus Exp $ */
/*
* Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org)
@@ -540,7 +540,7 @@ ipcomp_output_cb(struct cryptop *crp)
struct tdb_crypto *tc;
struct tdb *tdb;
struct mbuf *m, *mo;
- int error, s, skip, rlen;
+ int error, s, skip, rlen, roff;
u_int16_t cpi;
struct ip *ip;
#ifdef INET6
@@ -605,7 +605,7 @@ ipcomp_output_cb(struct cryptop *crp)
}
/* Inject IPCOMP header */
- mo = m_inject(m, skip, IPCOMP_HLENGTH, M_DONTWAIT);
+ mo = m_makespace(m, skip, IPCOMP_HLENGTH, &roff);
if (mo == NULL) {
DPRINTF(("ipcomp_output_cb(): failed to inject IPCOMP header "
"for IPCA %s/%08x\n", ipsp_address(&tdb->tdb_dst, buf,
@@ -616,7 +616,7 @@ ipcomp_output_cb(struct cryptop *crp)
}
/* Initialize the IPCOMP header */
- ipcomp = mtod(mo, struct ipcomp *);
+ ipcomp = (struct ipcomp *)(mtod(mo, caddr_t) + roff);
memset(ipcomp, 0, sizeof(struct ipcomp));
cpi = (u_int16_t) ntohl(tdb->tdb_spi);
ipcomp->ipcomp_cpi = htons(cpi);