# surprising value of LARGE_PACKET_MAX

3 messages from 2021-11-04 to 2021-11-05. Participants: Joey Hess, Matheus Tavares.
Thread: https://gitlist.dev/t/56845

## Joey Hess, 2021-11-04 18:59

Subject: surprising value of LARGE_PACKET_MAX
Message-ID: <YYQtjWSb+z4taphX@kitenet.net>
URL: https://gitlist.dev/e/YYQtjWSb%2Bz4taphX%40kitenet.net

```
I implemented a git-filter-server using the long-running process
protocol, and was surprised to discover in testing that git rejected
a maximally sized pkt-line starting with "ffff" as having an invalid
size.

The docs don't say what the maximum size is, so I assumed I could make
it as large as the length header allows, which I think is a natural
conclusion to draw from the documentation. But looking in git's source,
fff0 is the maximum:

#define LARGE_PACKET_MAX 65520
#define LARGE_PACKET_DATA_MAX (LARGE_PACKET_MAX - 4)

Which dates back to commit d47f3db75c58139cdcbca5cc63b17bf5db293b6a in
2006, which does not give a rationalle for the slightly small
size. Whatever the reason, it seems likely that changing that would be
likely to break interoperability with older versions of git.

Perhaps the best thing to do would be to document it in
Documentation/technical/protocol-common.txt

-- 
see shy jo

```

## Matheus Tavares, 2021-11-04 20:12

Subject: Re: surprising value of LARGE_PACKET_MAX
Message-ID: <CAHd-oW6q67u=XGCGK=n25Kjph+ceuqPHLxQ0LH=Vydn4xctZ-A@mail.gmail.com>
URL: https://gitlist.dev/e/CAHd-oW6q67u%3DXGCGK%3Dn25Kjph%2BceuqPHLxQ0LH%3DVydn4xctZ-A%40mail.gmail.com
In-Reply-To: <YYQtjWSb+z4taphX@kitenet.net>

```
On Thu, Nov 4, 2021 at 4:08 PM Joey Hess <id@joeyh.name> wrote:
>
> The docs don't say what the maximum size is, so I assumed I could make
> it as large as the length header allows, which I think is a natural
> conclusion to draw from the documentation. But looking in git's source,
> fff0 is the maximum:
>
> #define LARGE_PACKET_MAX 65520
> #define LARGE_PACKET_DATA_MAX (LARGE_PACKET_MAX - 4)
[...]
> Perhaps the best thing to do would be to document it in
> Documentation/technical/protocol-common.txt

Could it be that you consulted an older version of this file? The
current [1] version of the doc says:

"The maximum length of a pkt-line's data component is 65516 bytes.
Implementations MUST NOT send pkt-line whose length exceeds 65520
(65516 bytes of payload + 4 bytes of length data)."

[1]: https://github.com/git/git/blob/master/Documentation/technical/protocol-common.txt

```

## Joey Hess, 2021-11-05 14:57

Subject: Re: surprising value of LARGE_PACKET_MAX
Message-ID: <YYVGVoaJBzMDfyqi@kitenet.net>
URL: https://gitlist.dev/e/YYVGVoaJBzMDfyqi%40kitenet.net
In-Reply-To: <CAHd-oW6q67u=XGCGK=n25Kjph+ceuqPHLxQ0LH=Vydn4xctZ-A@mail.gmail.com>

```
Matheus Tavares wrote:
> Could it be that you consulted an older version of this file? The
> current [1] version of the doc says:
> 
> "The maximum length of a pkt-line's data component is 65516 bytes.
> Implementations MUST NOT send pkt-line whose length exceeds 65520
> (65516 bytes of payload + 4 bytes of length data)."

I'm sure I did read the current version, so I think I must have glanced
at 65516 and seen 65535. I don't see FFFF in decimal very often.

I think FFF0 would have stood out better to me, but still the current
docs are ok.

-- 
see shy jo

```
