From nobody Wed May 21 07:22:29 2025 X-Original-To: freebsd-current@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 4b2NDJ1zfSz5wyfn for ; Wed, 21 May 2025 07:22:40 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4b2NDG4Z91z3D8m for ; Wed, 21 May 2025 07:22:38 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Authentication-Results: mx1.freebsd.org; dkim=none; spf=pass (mx1.freebsd.org: domain of phk@critter.freebsd.dk designates 130.225.244.222 as permitted sender) smtp.mailfrom=phk@critter.freebsd.dk; dmarc=none Received: from critter.freebsd.dk (unknown [192.168.55.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by phk.freebsd.dk (Postfix) with ESMTPS id B40E9B0A1A for ; Wed, 21 May 2025 07:22:29 +0000 (UTC) Received: (from phk@localhost) by critter.freebsd.dk (8.18.1/8.16.1/Submit) id 54L7MTqw025632; Wed, 21 May 2025 07:22:29 GMT (envelope-from phk) Message-Id: <202505210722.54L7MTqw025632@critter.freebsd.dk> To: FreeBSD CURRENT Subject: Un-sucking EINVAL (was: ip# on bridge members) In-reply-to: From: "Poul-Henning Kamp" List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25630.1747812149.1@critter.freebsd.dk> Content-Transfer-Encoding: quoted-printable Date: Wed, 21 May 2025 07:22:29 +0000 X-Rspamd-Queue-Id: 4b2NDG4Z91z3D8m X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.67 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.67)[-0.672]; FORGED_SENDER(0.30)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FREEFALL_USER(0.00)[phk]; ASN(0.00)[asn:1835, ipnet:130.225.0.0/16, country:EU]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; MLMMJ_DEST(0.00)[freebsd-current@freebsd.org]; DMARC_NA(0.00)[freebsd.dk]; FROM_NEQ_ENVFROM(0.00)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; ARC_NA(0.00)[] The ip# on bridge member interfaces is yet another example of why "EINVAL" is the undisputedly least helpful errno of them all. The laconic "Invalid argument" leaves both the userland programmer and the user to guess what might be wrong. That's ok-ish for read(2) where the possibilities are so few that the manpage can tell you what you did wrong. It breaks down totally for ioctl(2), setsockopt(2) and similar syscalls which can attempt very, complex operations with many parameters and subparameters. Ifconfig(8) is ground zero for this and the manpage is not even trying: DIAGNOSTICS Messages indicating the specified interface does not exist, the requ= ested address is unknown, or the user is not privileged and tried to alter= an interface's configuration. We should give errno a text-partner, so kernel code can: if (p->n_mazel-vanes < 6 * p->n_dingle_arms) { error_text("Too few mazel-vanes per dingle-arm (min: 6)"); return (EINVAL) } The err(3) family of functions should retrieve the string, and when there is one, print it as part of the error message: Invalid argument: Too few mazel-vanes per dingle-arm (min: 6) -- = Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe = Never attribute to malice what can adequately be explained by incompetence= .