From: Stefano Brivio <sbrivio@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [RFC] tcp: Replace TCP buffer structure by an iovec array
Date: Wed, 13 Mar 2024 16:27:47 +0100 [thread overview]
Message-ID: <20240313162747.120169de@elisabeth> (raw)
In-Reply-To: <8e56f30b-cdcc-4276-acbe-9fc87fa51a7e@redhat.com>
On Wed, 13 Mar 2024 15:42:27 +0100
Laurent Vivier <lvivier@redhat.com> wrote:
> On 3/13/24 12:37, Stefano Brivio wrote:
> > On Mon, 11 Mar 2024 14:33:56 +0100
> > Laurent Vivier <lvivier@redhat.com> wrote:
> >
> ...
> >> diff --git a/tcp.c b/tcp.c
> >> index d5eedf4d0138..5c8488108ef7 100644
> >> --- a/tcp.c
> >> +++ b/tcp.c
> >> @@ -318,39 +318,7 @@
> ...
> >> -#define MSS4 ROUND_DOWN(USHRT_MAX - sizeof(struct tcp4_l2_head), 4)
> >> -#define MSS6 ROUND_DOWN(USHRT_MAX - sizeof(struct tcp6_l2_head), 4)
> >>
> >> +#define MSS (USHRT_MAX - sizeof(struct tcphdr))
> >
> > We can't exceed USHRT_MAX at Layer-2 level, though, so the MSS for IPv4
> > should now be:
> >
> > #define MSS4 ROUND_DOWN(USHRT_MAX - sizeof(struct ethhdr) -
> > sizeof(struct iphdr) -
> > sizeof(struct tcphdr),
> > 4)
> >
> > ...and similar for IPv6.
>
> Is there a specification that limits the MSS?
Well, on Linux, virtual network interfaces such as virtio-net still
have their maximum configurable MTU defined as ETH_MAX_MTU (same as the
maximum IPv4 MTU, 65535), and that's a symmetric value (in standards,
drivers, and elsewhere in the network stack).
Side note: the TCP MSS doesn't need to be the same value for both
directions, instead.
But other than that, no, there are no normative references. It's an
implementation "detail" if you want.
> Or is it only a compatibility problem with the network stack implementation?
Kind of, yes. Except that:
> At headers level the only limitation we have is the length field size in the IP header
> that is a 16bit (it's why I put "USHRT_MAX - sizeof(struct tcphdr)").
...in IPv4, that field also contains the length of the *IP header*, so,
ignoring for a moment Linux and virtio-net with ETH_MAX_MTU, you would
be limited to 65495 bytes (65535 minus 20 bytes of IP header, minus 20
bytes of TCP header). As RFC 791, section 3.1, states:
Total Length: 16 bits
Total Length is the length of the datagram, measured in octets,
including internet header and data. This field allows the length of
a datagram to be up to 65,535 octets. [...]
...but 65535 is the *MTU*, not MSS.
And if it needs to fit ETH_MAX_MTU, you're now back to 65520 bytes of
MTU (it needs to match IPv4 32-bit words, if I recall correctly), hence
65480 bytes of MSS.
IPv6 is different, in that the equivalent field doesn't include the
size of the IPv6 header. But the header is 40 bytes long, so the
outcome is the same. Well, except that you could have jumbograms (RFC
2675) and exceed 65535 bytes of IPv6 MTU, but that won't work anyway
with Ethernet-like interfaces.
So, well, I haven't actually tried to send an Ethernet frame to a
virtio-net interface that's bigger than 65535 bytes. As far as
normative references are concerned, you could send 65549 (65535 bytes
maximum IPv4 MTU, plus 14 bytes of 802.3 header on top) bytes. I guess
it will be dropped by the kernel, but it's perhaps worth a try.
--
Stefano
next prev parent reply other threads:[~2024-03-13 15:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 13:33 [RFC] tcp: Replace TCP buffer structure by an iovec array Laurent Vivier
2024-03-12 22:56 ` Stefano Brivio
2024-03-13 11:37 ` Stefano Brivio
2024-03-13 14:42 ` Laurent Vivier
2024-03-13 15:27 ` Stefano Brivio [this message]
2024-03-13 15:20 ` Laurent Vivier
2024-03-13 16:58 ` Stefano Brivio
2024-03-14 14:07 ` Laurent Vivier
2024-03-14 15:47 ` Stefano Brivio
2024-03-14 15:54 ` Laurent Vivier
2024-03-14 16:26 ` Stefano Brivio
2024-03-15 0:46 ` David Gibson
2024-03-14 4:22 ` David Gibson
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=20240313162747.120169de@elisabeth \
--to=sbrivio@redhat.com \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).