From: David Hill Subject: Re: wireguard - prepend mbuf allocations To: tech@openbsd.org Date: Sat, 28 Sep 2024 10:47:33 -0400 Something like this? Index: net/if_wg.c =================================================================== RCS file: /cvs/src/sys/net/if_wg.c,v retrieving revision 1.38 diff -u -p -r1.38 if_wg.c --- net/if_wg.c 9 Apr 2024 12:53:08 -0000 1.38 +++ net/if_wg.c 28 Sep 2024 14:46:51 -0000 @@ -860,10 +860,14 @@ wg_send_buf(struct wg_softc *sc, struct { struct mbuf *m; int ret = 0; + size_t mlen = len + max_hdr; retry: m = m_gethdr(M_WAIT, MT_DATA); + if (mlen > MHLEN) + MCLGETL(m, M_WAIT, mlen); m->m_len = 0; + m_align(m, len); m_copyback(m, 0, len, buf, M_WAIT); /* As we're sending a handshake packet here, we want high priority */ @@ -1522,8 +1526,9 @@ wg_encap(struct wg_softc *sc, struct mbu * noise_remote_encrypt about mbufs, but we would need to sort out the * p_encap_queue situation first. */ - if ((mc = m_clget(NULL, M_NOWAIT, out_len)) == NULL) + if ((mc = m_clget(NULL, M_NOWAIT, out_len + max_hdr)) == NULL) goto error; + m_align(mc, out_len); data = mtod(mc, struct wg_pkt_data *); m_copydata(m, 0, m->m_pkthdr.len, data->buf);