Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Daniel Lenski <dlenski@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: Allowing space for packet headers in Wintun Tx/Rx
Date: Wed, 7 Apr 2021 16:15:45 -0700	[thread overview]
Message-ID: <CAOw_LSHa5aERnm8etcBywJV4QmW_9BesXvBYSvjKPVZ=a+whXg@mail.gmail.com> (raw)
In-Reply-To: <6e259ab359c7f93f8f1119df0ba7b285cd4f53d1.camel@infradead.org>

On Wed, Apr 7, 2021 at 4:49 AM David Woodhouse <dwmw2@infradead.org> wrote:
> If WintunSendPacket took an additional 'offset' argument to disregard a
> certain number of bytes at the beginning of the buffer, that would
> probably suffice. Or is it possible to simply add to the pointer
> returned by WintunAllocateSendPacket()?

To expand on this possibility a little bit, I had proposed kludging a
“shift” into the allocation for the outgoing packet:

    /* Always use this instead for an outgoing packet, instead of
     * malloc(sizeof(struct pkt) + payload_len */
    BYTE *tun_pkt = WintunAllocateSendPacket(
        vpninfo->wintun_session,
        paylod_len                 /* packet payload size */
        + sizeof(struct pkt)     /* OpenConnect's internal packet header size */
    );

    /* Then after we build and populate the outgoing packet, just tell
     * Wintun to send from an offset that's NOT at the beginning of the
     * buffer it allocated for us. No memcpy! */
    WintunSendPacket(vpninfo->wintun_session, tun_pkt + sizeof(struct pkt));

The concern here is that Wintun may not have been written with this
possibility in mind, and might not always like sending from an address
other than the exact start of a buffer it's allocated for us.

Thanks,
Dan

  reply	other threads:[~2021-04-10 14:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 11:49 David Woodhouse
2021-04-07 23:15 ` Daniel Lenski [this message]
2021-04-08 14:37   ` David Woodhouse
2021-04-08 16:42     ` Daniel Lenski
2021-04-08 17:10       ` David Woodhouse
2021-04-08 17:37         ` Daniel Lenski
2021-04-10 13:38         ` Simon Rozman
2021-04-10 14:35           ` David Woodhouse
2021-04-10 18:32             ` Daniel Lenski
2021-04-12 11:38               ` Simon Rozman
2021-04-12 13:00                 ` David Woodhouse
2021-04-12 17:03                   ` Jason A. Donenfeld
2021-04-13 22:09                     ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOw_LSHa5aERnm8etcBywJV4QmW_9BesXvBYSvjKPVZ=a+whXg@mail.gmail.com' \
    --to=dlenski@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).