Development discussion of WireGuard
 help / color / mirror / Atom feed
From: "Daniel Gröber" <dxld@darkboxed.org>
To: M P Robert <mprobert@gmail.com>
Cc: wireguard@lists.zx2c4.com
Subject: Re: wg-quick set_mtu_up - largest or smallest MTU?
Date: Sun, 19 Nov 2023 15:41:51 +0100	[thread overview]
Message-ID: <20231119144151.2wcvbph4hplfydfj@House.clients.dxld.at> (raw)
In-Reply-To: <81DE093A-5905-49CA-A412-5F934E0E0EBB@gmail.com>

Hi Matt,

On Fri, Nov 03, 2023 at 01:12:22PM +0000, M P Robert wrote:
> I was looking at the auto MTU detection in wg-quick.
> 
> It appears that wg-quick is taking the LARGEST of all endpoint MTUs
> 
> https://github.com/WireGuard/wireguard-tools/blob/13f4ac4cb74b5a833fa7f825ba785b1e5774e84f/src/wg-quick/linux.bash#L134

My reading of the code is that we iterate over all peers' endpoints do a
route lookup to get the destination specific MTU and fall back to default
route's MTU if that didn't return anything. In both cases we use the "mtu"
route attribute or failing that the actual interface MTU.

Incidentally the docs don't mention the details of the MTU selection
behaviour. wg-quick(1) has this:

       •      MTU — if not specified, the MTU is automatically determined from
              the endpoint addresses or the system  default  route,  which  is
              usually  a  sane  choice. However, to manually specify an MTU to
              override this automatic discovery, this value may  be  specified
              explicitly.

> In a scenario where you have different peers on different network devices
> or routes with different MTUs, I would think you would want to take the
> SMALLEST mtu from all peers in order to avoid having fragmentation
> talking to the peers on networks with smaller MTUs.

I agree using the smallest MTU would probably be best for most users.

> Or perhaps fragmentation for some peers is faster than selecting a
> smaller packet size for all peers?  Or I am missing something (more
> likely).  Happy to be educated on this point.

In principle hosts that have (some) interfaces using jumbo frames may want
to make use of the largest MTU for efficiency, in this case one may be
willing to take the fragmentation hit on interfaces with smaller MTU.

In this case it'd still be possible to override the automatic MTU selection
by configuring MTU= statically so this isn't a blocker.

> I don't have git-send-email setup at this point, but just in case this is
> a valid issue, I've attached a sample fix for set_mtu_up that will take
> the smallest of the discovered peer MTUs rather than the largest.  I'm
> not a bash guy, so just take it for illustration purposes.

Looks like Thomas already whipped up a patch. You could test it and report
back :)

--Daniel

      reply	other threads:[~2023-11-19 14:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 13:12 M P Robert
2023-11-19 14:41 ` Daniel Gröber [this message]

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=20231119144151.2wcvbph4hplfydfj@House.clients.dxld.at \
    --to=dxld@darkboxed.org \
    --cc=mprobert@gmail.com \
    --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).