From nobody Tue Aug 2 13:32:58 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lxwvl47Rqz4Y77S; Tue, 2 Aug 2022 13:34:43 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from forward502j.mail.yandex.net (forward502j.mail.yandex.net [5.45.198.238]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lxwvj1nWGz3Tjt; Tue, 2 Aug 2022 13:34:41 +0000 (UTC) (envelope-from melifaro@ipfw.ru) Received: from sas1-0701b3ebb6ca.qloud-c.yandex.net (sas1-0701b3ebb6ca.qloud-c.yandex.net [IPv6:2a02:6b8:c08:21a5:0:640:701:b3eb]) by forward502j.mail.yandex.net (Yandex) with ESMTP id 0CEE4112521A; Tue, 2 Aug 2022 16:33:01 +0300 (MSK) Received: by sas1-0701b3ebb6ca.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id UxRylAkBAo-WxhKppYk; Tue, 02 Aug 2022 16:33:00 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfw.ru; s=mail; t=1659447180; bh=peVxZHyZq9LMDwwGp/nvJdMPZ3IsR+yUM8iVrSXrBLQ=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=hKOYCEDKMCo/ORHHsfQJbgHABSOHL3DFKp84G/7DBfp8IwP8ydYkTJUFcodTXdhcZ fNp9n3tSVDub22SEVp/fOZ84Ynj/X0ERYvqkCmFXpytvLAlHNRd37DduIebadoxgrZ fBijtqZfqqdJRD7vRi5yb78n2+9vBgTkrcSWHYvQ= Content-Type: text/plain; charset=utf-8 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: git: be1f485d7d6b - main - sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg(). From: "Alexander V. Chernikov" In-Reply-To: <0aec0f80-0bb2-7bf7-a87b-e97e18674a19@FreeBSD.org> Date: Tue, 2 Aug 2022 14:32:58 +0100 Cc: "Alexander V. Chernikov" , "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , "dev-commits-src-main@freebsd.org" Content-Transfer-Encoding: quoted-printable Message-Id: <48AE1817-F3C5-4DBD-94DA-CAFC699B2C4D@ipfw.ru> References: <202207301846.26UIko7G080500@gitrepo.freebsd.org> <0aec0f80-0bb2-7bf7-a87b-e97e18674a19@FreeBSD.org> To: John Baldwin X-Mailer: Apple Mail (2.3696.100.31) X-Rspamd-Queue-Id: 4Lxwvj1nWGz3Tjt X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=ipfw.ru header.s=mail header.b=hKOYCEDK; dmarc=none; spf=pass (mx1.freebsd.org: domain of melifaro@ipfw.ru designates 5.45.198.238 as permitted sender) smtp.mailfrom=melifaro@ipfw.ru X-Spamd-Result: default: False [-3.00 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:5.45.192.0/19]; R_DKIM_ALLOW(-0.20)[ipfw.ru:s=mail]; MIME_GOOD(-0.10)[text/plain]; DKIM_TRACE(0.00)[ipfw.ru:+]; TO_DN_EQ_ADDR_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MLMMJ_DEST(0.00)[dev-commits-src-all@FreeBSD.org,dev-commits-src-main@FreeBSD.org]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[ipfw.ru]; RCPT_COUNT_FIVE(0.00)[5]; ASN(0.00)[asn:13238, ipnet:5.45.192.0/18, country:RU]; FREEFALL_USER(0.00)[melifaro]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N > On 1 Aug 2022, at 17:51, John Baldwin wrote: >=20 > On 7/30/22 11:46 AM, Alexander V. Chernikov wrote: >> The branch main has been updated by melifaro: >> URL: = https://cgit.FreeBSD.org/src/commit/?id=3Dbe1f485d7d6bebc53b055cc165a11ada= 0ab5fb17 >> commit be1f485d7d6bebc53b055cc165a11ada0ab5fb17 >> Author: Alexander V. Chernikov >> AuthorDate: 2022-07-25 19:46:40 +0000 >> Commit: Alexander V. Chernikov >> 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). >=20 > In general I like this as I've long wanted a kind of FIONREAD but just > for the next messsage rather than whole socket buffer. >=20 > Two thoughts: >=20 > 1) Why is it permissible (vs an EINVAL error) to pass MSG_TRUNC = without > MSG_PEEK? If a developer wants to skip a message they can do a normal My impression is that the use cases can be largely the same as in = (output) MSG_TRUNC. One, for example, cares only about the packet = header, thus they submit a small buffer, but want to see the original = length for accounting or debugging purposes. > read with a zero-sized buffer already which is more portable. It > seems to me that we should return an error here rather than > permitting it? >=20 > 2) It might nice to have a similar option for MSG_CTRUNC so that one > could pass in MSG_PEEK | MSG_TRUNC | MSG_CTRUNC to get the sizes of > both the data and control back from recvmsg(). I don=E2=80=99t have any objections on that, but don=E2=80=99t have any = cycles to implement it either - this is already third level of recursion = from my original goal :-) >=20 > Also, I think you missed the .Dd bump on recv.2. Indeed! Thank you, should be fixed by 426afc8f5218. >=20 > --=20 > John Baldwin