From owner-dev-commits-src-all@freebsd.org  Mon Sep 13 19:25:37 2021
Return-Path: <owner-dev-commits-src-all@freebsd.org>
Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id 435666A8525;
 Mon, 13 Sep 2021 19:25:37 +0000 (UTC)
 (envelope-from michael.tuexen@macmic.franken.de)
Received: from drew.franken.de (drew.ipv6.franken.de
 [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client CN "*.franken.de",
 Issuer "Sectigo RSA Domain Validation Secure Server CA" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 4H7bzh6qSpz4pVB;
 Mon, 13 Sep 2021 19:25:36 +0000 (UTC)
 (envelope-from michael.tuexen@macmic.franken.de)
Received: from smtpclient.apple (unknown
 [IPv6:2a02:8109:1140:c3d:1442:bd8b:13ff:7b32])
 (Authenticated sender: macmic)
 by mail-n.franken.de (Postfix) with ESMTPSA id 19AC5721E2825;
 Mon, 13 Sep 2021 21:25:24 +0200 (CEST)
Content-Type: text/plain;
	charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\))
Subject: Re: git: b864b67a0d19 - main - socket: Do not include control
 messages in FIONREAD return value
From: Michael Tuexen <michael.tuexen@macmic.franken.de>
In-Reply-To: <270ac6c6-1fdf-879a-cbea-ef43200ef12a@FreeBSD.org>
Date: Mon, 13 Sep 2021 21:25:23 +0200
Cc: Mark Johnston <markj@FreeBSD.org>,
 "src-committers@freebsd.org" <src-committers@FreeBSD.org>,
 "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>,
 "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <BFB7C96E-CB33-4EB8-804C-E9AACC4BCAB7@macmic.franken.de>
References: <202109122039.18CKdpwW094531@gitrepo.freebsd.org>
 <270ac6c6-1fdf-879a-cbea-ef43200ef12a@FreeBSD.org>
To: John Baldwin <jhb@freebsd.org>
X-Mailer: Apple Mail (2.3654.120.0.1.13)
X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00
 autolearn=disabled version=3.4.1
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail-n.franken.de
X-Rspamd-Queue-Id: 4H7bzh6qSpz4pVB
X-Spamd-Bar: ----
Authentication-Results: mx1.freebsd.org;
	none
X-Spamd-Result: default: False [-4.00 / 15.00];
	 REPLY(-4.00)[]
X-BeenThere: dev-commits-src-all@freebsd.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Commit messages for all branches of the src repository
 <dev-commits-src-all.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/dev-commits-src-all>, 
 <mailto:dev-commits-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/dev-commits-src-all/>
List-Post: <mailto:dev-commits-src-all@freebsd.org>
List-Help: <mailto:dev-commits-src-all-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all>, 
 <mailto:dev-commits-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 13 Sep 2021 19:25:37 -0000

> On 13. Sep 2021, at 18:29, John Baldwin <jhb@freebsd.org> wrote:
>=20
> On 9/12/21 1:39 PM, Mark Johnston wrote:
>> The branch main has been updated by markj:
>> URL: =
https://cgit.FreeBSD.org/src/commit/?id=3Db864b67a0d197f59ecf6698940600956=
ceee2cae
>> commit b864b67a0d197f59ecf6698940600956ceee2cae
>> Author:     Mark Johnston <markj@FreeBSD.org>
>> AuthorDate: 2021-09-12 20:05:49 +0000
>> Commit:     Mark Johnston <markj@FreeBSD.org>
>> CommitDate: 2021-09-12 20:39:44 +0000
>>     socket: Do not include control messages in FIONREAD return value
>>          Some system software expects to be able to read at least the =
number of
>>     bytes returned by FIONREAD.  When control messages are counted in =
this
>>     return value, this assumption is violated.  Follow Linux and =
OpenBSD
>>     here (as well as our own kevent(EVFILT_READ)) and only return the =
number
>>     of data bytes available.
>>          Reported by:    avg
>>     MFC after:      2 weeks
>=20
> In a somewhat similar vein, it would be nice to eventually have new =
ioctls
> to know how much data and control are available in the next message =
for
> datagram-oriented sockets.  Right now if you are working with a =
datagram
> socket with variable-sized messages there's no good way to know how =
big the
> next message is (to resize a read buffer) as FIONREAD can count =
multiple
> messages.  There's also no way at all to cope with control messages =
aside
> from retrying with some naive algorithm like doubling the size if =
MSG_CTRUNC
> is set, but that also requires always using MSG_PEEK so that you =
always
> end up reading a message at least twice.
That still requires two system calls. In SCTP, there is a CMSG you can
receive with a messages, which contains the metadata of the next message
you will receive.
So it might be an idea to define a CMSG containing the length of the =
next
message (if available).

Best regards
Michael
>=20
> --=20
> John Baldwin