Download raw body.
wireguard - prepend mbuf allocations
On Sat, Sep 28, 2024 at 10:47:33AM -0400, David Hill wrote:
> 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);
This code should not use m_copyback() it does not do what it think it
does. It is there for a different reason.
> /* 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);
>
--
:wq Claudio
wireguard - prepend mbuf allocations