From owner-freebsd-arch@freebsd.org Sun Oct 4 18:48:14 2020 Return-Path: Delivered-To: freebsd-arch@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 9D21742FD8B for ; Sun, 4 Oct 2020 18:48:14 +0000 (UTC) (envelope-from roy@marples.name) Received: from relay2.marples.name (relay2.marples.name [IPv6:2a00:da00:1800:80d6::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay2.marples.name", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C4CRK2rGtz44Kw for ; Sun, 4 Oct 2020 18:48:13 +0000 (UTC) (envelope-from roy@marples.name) Received: from mail.marples.name (mail.marples.name [IPv6:2001:470:690c:1::59]) by relay2.marples.name (Postfix) with ESMTPS id D1A94761 for ; Sun, 4 Oct 2020 18:48:10 +0000 (UTC) Received: from [10.73.1.30] (uberpc.marples.name [10.73.1.30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.marples.name (Postfix) with ESMTPSA id 460E353FC for ; Sun, 4 Oct 2020 19:48:09 +0100 (BST) From: Roy Marples Subject: Implementing SO_RERROR To: freebsd-arch@freebsd.org Message-ID: Date: Sun, 4 Oct 2020 19:48:08 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4C4CRK2rGtz44Kw X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.18 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[marples.name:s=mail]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+a:relay2.marples.name:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arch@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.05)[-1.051]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_MEDIUM(-1.03)[-1.026]; DKIM_TRACE(0.00)[marples.name:+]; DMARC_POLICY_ALLOW(-0.50)[marples.name,quarantine]; NEURAL_HAM_SHORT(-0.11)[-0.105]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8560, ipnet:2a00:da00::/32, country:DE]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-arch] X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Oct 2020 18:48:14 -0000 Hi Currently in the FreeBSD kernel packets are silently dropped when delivery is attempted to a socket who has no space left in it's buffer. There are comments in the code which imply that someone should be notified of this. Here is an example: https://svnweb.freebsd.org/base/head/sys/netinet6/icmp6.c?revision=362909&view=markup#l1976 I have submitted https://reviews.freebsd.org/D26652 for review to rectify this was asked to discuss the change here. To put it simply, all callers of sbappendaddr() now call soroverflow() when the packet cannot be delivered. If the application enabled SO_RERROR on the socket then it will be woken up and the next subsequent read on it will return ENOBUFS. For the curious, this error code is allowed to be returned from read(2) by POSIX. This is a general solution to a very specific case where network aware programs rely on the reliable delivery of route(4) messages. If a message is dropped, we need to so we can perform a full scan of the host to see what has changed and if we need to react to it. Another use case for this is syslogd can now know if a locally sent message was dropped telling the admin to increase the buffer size to avoid this in the future. Currently if a locally sent message cannot be delivered to syslogd it is also silenty dropped if the syslogd socket buffer is full. If the view of FreeBSD is that this isn't wanted then please remove comments from the codebase implying that it is and ideally replace with a comment explaining why. Thanks for your consideration. Roy