diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-04-28 21:38:05 -0400 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-04-28 21:40:25 -0400 |
commit | 2d4075f0063caad436577c45f9091be6444e9cd4 (patch) | |
tree | 593bcbda90b1f9f00d4a71413eb795bc7ee65f38 /src/if_wg.c | |
parent | if_wg: do not double-free after m_pullup (diff) | |
download | wireguard-freebsd-2d4075f0063caad436577c45f9091be6444e9cd4.tar.xz wireguard-freebsd-2d4075f0063caad436577c45f9091be6444e9cd4.zip |
if_wg: allocate entire mbuf all at once
Rather than making a tiny mbuf and then allocating another one in
m_copyback, just make one larger one. These packets are generally pretty
small anyway.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/if_wg.c')
-rw-r--r-- | src/if_wg.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/if_wg.c b/src/if_wg.c index cde9511..8ff90fd 100644 --- a/src/if_wg.c +++ b/src/if_wg.c @@ -933,12 +933,11 @@ wg_send_buf(struct wg_softc *sc, struct wg_endpoint *e, uint8_t *buf, size_t len bool retried = false; retry: - m = m_gethdr(M_NOWAIT, MT_DATA); + m = m_get2(len, M_NOWAIT, MT_DATA, M_PKTHDR); if (!m) { ret = ENOMEM; goto out; } - m->m_len = 0; m_copyback(m, 0, len, buf); if (ret == 0) { |