HomeFreeBSD

sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().

Description

sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().

Implement Linux-variant of MSG_TRUNC input flag used in recv(), recvfrom() and recvmsg().
Posix defines MSG_TRUNC as an output flag, indicating packet/datagram truncation.
Linux extended it a while (~15+ years) ago to act as input flag,
resulting in returning the full packet size regarless of the input
buffer size.
It's a (relatively) popular pattern to do recvmsg( MSG_PEEK | MSG_TRUNC) to get the
packet size, allocate the buffer and issue another call to fetch the packet.
In particular, it's popular in userland netlink code, which is the primary driving factor of this change.

This commit implements the MSG_TRUNC support for SOCK_DGRAM sockets (udp, unix and all soreceive_generic() users).

PR: kern/176322
Reviewed by: pauamma(doc)
Differential Revision: https://reviews.freebsd.org/D35909
MFC after: 1 month

Details

Provenance
melifaroAuthored on Jul 25 2022, 7:46 PM
Differential Revision
D35909: sockets: implement MSG_TRUNC recv/recvmsg flag
Parents
rGd8dd6b329e46: LinuxKPI: 802.11: add missing linuxkpi_cfg80211_bss_flush()
Branches
Unknown
Tags
Unknown