From 2d4075f0063caad436577c45f9091be6444e9cd4 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 28 Apr 2021 21:38:05 -0400 Subject: 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 --- src/if_wg.c | 3 +-- 1 file changed, 1 insertion(+), 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) { -- cgit v1.2.3-59-g8ed1b