Hello, recv() in Linux 2.6 kernel has a fix for returning the original length of the packet even when the packet is truncated using the MSG_TRUNC flag. However, is there a fix for this in FREEBSD??? recv() does not return the original length of the packet in freebsd. I need to get the original length of the packet on freebsd. Please HELP !!!! Thanks, Ramya
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped
https://reviews.freebsd.org/D35909 adds the required bits for handling MSG_TRUNC
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=be1f485d7d6bebc53b055cc165a11ada0ab5fb17 commit be1f485d7d6bebc53b055cc165a11ada0ab5fb17 Author: Alexander V. Chernikov <melifaro@FreeBSD.org> AuthorDate: 2022-07-25 19:46:40 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2022-07-30 18:21:51 +0000 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 lib/libc/sys/recv.2 | 12 +++ sys/kern/uipc_socket.c | 13 ++- sys/kern/uipc_usrreq.c | 29 ++++-- tests/sys/kern/Makefile | 1 + tests/sys/kern/socket_msg_trunc.c (new) | 169 ++++++++++++++++++++++++++++++++ 5 files changed, 212 insertions(+), 12 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=adaf752192c165b66875e81db62d274a09591d0c commit adaf752192c165b66875e81db62d274a09591d0c Author: Alexander V. Chernikov <melifaro@FreeBSD.org> AuthorDate: 2022-07-25 19:46:40 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2023-02-09 18:01:49 +0000 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 (cherry picked from commit be1f485d7d6bebc53b055cc165a11ada0ab5fb17) lib/libc/sys/recv.2 | 12 +++ sys/kern/uipc_socket.c | 13 ++- tests/sys/kern/Makefile | 1 + tests/sys/kern/socket_msg_trunc.c (new) | 169 ++++++++++++++++++++++++++++++++ 4 files changed, 191 insertions(+), 4 deletions(-)