From nobody Mon Aug 1 16:51:43 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 4LxPKY5BhYz4X2WZ; Mon, 1 Aug 2022 16:51:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LxPKY4ZhFz3XW5; Mon, 1 Aug 2022 16:51:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659372705; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dMmRtjb0j4ZUFqhWK1ecfOWJZc34VlgAbo/cbsYAzCU=; b=avkQw9bGCHp4heXgdlYY7+nSTToI7DRzR9/nViPuyxMmM4iFc65P1KRWbN0FiMXDlBn8e0 Ugjk1xDE7Z4wt7QTv8UiEtGNaGWcuS3T7t2P19NINVNCaNHm1wLmq1DjAk05LO/SQysSSZ xpDRR0d91f/bxxxRIKy9CMngUpQp6bwg1yvlSctidPmrgwRxeW0/2IUccxYlfC/vNAFGHe 2jai2zt8bgLIPfdg7xfH0EBPWwlNtikQ5RJeajiTCwY2RDUmwXDR0YOG+HAo90obCs4Thq kvtOBPYQNIBJgkzlcnwyL1HbfuluQpce22uV0JczOrLDeg2XusJ/ds2L8G0vxg== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4LxPKY0Qhdz152h; Mon, 1 Aug 2022 16:51:44 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <0aec0f80-0bb2-7bf7-a87b-e97e18674a19@FreeBSD.org> Date: Mon, 1 Aug 2022 09:51:43 -0700 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 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: git: be1f485d7d6b - main - sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg(). Content-Language: en-US To: "Alexander V. Chernikov" , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202207301846.26UIko7G080500@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: <202207301846.26UIko7G080500@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659372705; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dMmRtjb0j4ZUFqhWK1ecfOWJZc34VlgAbo/cbsYAzCU=; b=YtUYHKzeuUFIpRGq/VKUkJcnLhkczycbwI6tLDG2HqnImSRkEN+zNc67QchPwiDDFXTT5B +L19Itm3CTzbuCe43GEhJ2vsI9YC2iuLtJhc4GKujsmZbWqoocdZjvBO+Acp8UJnWCka96 YAyciw9VY+XZHbAWTLCmFU4JgmzV7fpdm+pciLCH45vSBC/4JCzLW2lWsOK2t3U6lmSXXa Y2I/g669B8YDaXdID14XACbjkyVVy2pzdrbbDX+8GbuhQK2hAY5LFr9eMyS6ijmzMyAoxd n0C15qJCqPwNAuAFsXcKdpWOfDKFP3hL4fA19HYrqPAop8iiaiKHgtm3lGcs+w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659372705; a=rsa-sha256; cv=none; b=kAJOl8s72iMhwrch0qg8Eo+9x35Aqq3dLjsWgJkNaYfyOT2Okw8FJN0A2CSwsaf5kYMH95 j3dWowsa7SU8ywrRxX+c0Wv2H4iFTGWXiHVbYeO2AkUAQdJS9C1Z62TQeMcR/I7IEsl/P8 03N8xyGPbofBUTzxNhoUNDmYuUPdNoj0bM6iJufxr4xmqOyVKUrYiYHsT4uqvN+aquTFwy gsUGs6HuPoZR9KZ4RyxwlQ7RrFppcDtSnZy/RDKJl97NXEaQtPKIViAN8uzZ403BNPPAWc VFqBdsjKbqjB+fo4Byz7eaFQixlqNWu5Jqvaw2Lr1fCI9LdwxPjz0Dh/dMA5Pg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N 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=be1f485d7d6bebc53b055cc165a11ada0ab5fb17 > > 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). 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. Two thoughts: 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 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? 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(). Also, I think you missed the .Dd bump on recv.2. -- John Baldwin