In this article
A GRO receive buffer can contain several datagrams; missing or truncated control data must not silently turn the aggregate into one application message.
The receiver counts an aggregate as one message
A UDP-based internal transport enables receive offload to reduce processing overhead. Its parser assumes each receive call yields one application datagram and passes the entire buffer to a decoder. With UDP_GRO, several datagrams can arrive together. A valid network optimization has exposed an invalid application assumption. The receiver must reconstruct message boundaries from the documented metadata, not infer them from the length of one receive result.
Read the GRO delivery contract
The Linux UDP reference documents that an enabled UDP_GRO socket may receive multiple datagrams in one large buffer together with a control message carrying segment size. The aggregate can exceed the interface MTU without representing an oversized wire datagram. Conversely, a socket can still receive ordinary traffic without aggregation. Preserve whether the option was successfully enabled and whether the specific receive result includes the relevant control message.
Parse metadata before decoding payloads
Use the reported segment size to delimit the datagrams represented by an accepted aggregate, respecting the actual returned payload length. The final portion need not justify reading beyond the buffer merely to fill a nominal segment. Do not derive segmentation from a model’s expected tensor size, a sender’s current configuration or an unrelated previous receive result. Each accepted message needs correct association with its own framing and source context before being passed to higher-level request or transfer logic.
Payload and control buffers can fail separately
The recvmsg contract distinguishes MSG_TRUNC for discarded payload from MSG_CTRUNC for discarded ancillary information. Providing a data buffer sized for an ordinary datagram may be insufficient for an aggregate; providing too little control space can lose the metadata needed to interpret it. Treat these as explicit failure or recovery conditions under the application protocol. A nonnegative byte count alone does not establish a complete, correctly framed set of messages.
Qualify an offload-aware parser
In an isolated fixture, send known datagram sequences with independently verifiable payload identities. Cover aggregated and nonaggregated delivery, a shorter final portion, insufficient payload capacity and insufficient control capacity. Verify reconstructed message count and content, and reject ambiguous truncated results rather than silently accepting a combined message. The test must not require that the kernel aggregate every eligible sequence: aggregation is conditional, while the parser must handle every valid delivery form it actually receives.
Keep transport reliability separate
GRO does not add reliable delivery, deduplication or application ordering to UDP. Those remain protocol responsibilities, and an accepted aggregate is not proof that no earlier datagram was lost. The capture offload guide explains why host representations differ from wire packets, while counter accounting separates socket and device observations. Report logical datagrams after validated reconstruction rather than treating receive calls as message counts. Any reduction in processing cost requires a separate measured comparison that preserves these correctness checks.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.